Font size
WorksheetsExploring Tkinter in Python
Total questions: 142
Worksheet time: 1hrs 15mins
What is Tkinter in Python?
Tkinter is a data analysis library for Python.
Tkinter is a GUI toolkit for Python.
Tkinter is a database management system.
Tkinter is a web framework for Python.
How do you create a basic Tkinter window?
window = Tk()
window.start()
import tkinter as T
import tkinter as tk window = tk.Tk() window.title('My Tkinter Window') window.mainloop()
Which method is used to start the Tkinter event loop?
execute()
runloop()
startloop()
mainloop()
What is the purpose of the Tk() class in Tkinter?
To manage the layout of widgets in Tkinter.
To handle events in Tkinter.
The purpose of the Tk() class is to create the main application window in Tkinter.
To create a button in Tkinter.
How can you set the title of a Tkinter window?
Use the title method: root.title("Your Title Here")
Use the set_title method: root.set_title('Your Title Here')
Call the configure method: root.configure(title='Your Title Here')
Set the window name: root.name('Your Title Here')
What is a widget in Tkinter?
A widget in Tkinter is a type of database.
A widget in Tkinter is a GUI element that allows user interaction.
A widget in Tkinter is a programming language.
A widget in Tkinter is a file format for images.
Name three common widgets used in Tkinter applications.
Slider
Button, Label, Entry
Canvas
TextBox
How do you add a button widget in Tkinter?
Use the Button class from Tkinter to create a button and pack it into the main window.
Use the Label class to create a button and place it in a frame.
Add a button by using the Canvas widget to draw it on the screen.
Create a button using the Entry class and insert it into the window.
What layout manager is used to arrange widgets in a grid?
GridLayout
FlowLayout
BorderLayout
BoxLayout
How do you create a label widget in Tkinter?
label = root.Label('Your Text Here')
label = Label(root, text='Your Text Here')
label = createLabel(root, 'Your Text Here')
label = Text(root, 'Your Text Here')
What is event handling in Tkinter?
Event handling in Tkinter is only for managing database connections.
Event handling in Tkinter refers to the layout design of the application.
Event handling in Tkinter is the mechanism to respond to user interactions with the GUI.
Event handling in Tkinter is the process of creating new GUI elements.
How do you bind a function to a button click event?
buttonElement.onClick(myFunction);
buttonElement.click(myFunction);
myFunction.bind(buttonElement);
buttonElement.addEventListener('click', myFunction);
What method is used to retrieve text from an Entry widget?
get()
retrieve()
fetch()
extract()
How can you change the background color of a Tkinter window?
Use the pack method to set the background color.
Use the config method or set the bg option to change the background color.
Adjust the window size to modify the background color.
Change the font size to alter the background color.
What is the purpose of the pack() method in Tkinter?
The purpose of the pack() method in Tkinter is to manage the layout of widgets.
To change the color of widgets.
To create a new window in Tkinter.
To delete widgets from the layout.
How do you create a dropdown menu in Tkinter?
Create a listbox for multiple selections.
Implement a button that opens a new window.
Use the OptionMenu widget with a Tkinter variable and a list of options.
Use the Label widget to display text only.
What is the difference between the grid() and pack() methods?
grid() allows for grid-based layout, while pack() provides a linear layout.
grid() arranges widgets in a circular layout, while pack() stacks them vertically.
grid() is for creating menus, while pack() is for handling events.
grid() is used for image display, while pack() is for text alignment.
How can you create a checkbox widget in Tkinter?
Use the Button class to create a checkbox in Tkinter.
Utilize the Label widget for checkbox functionality in Tkinter.
Implement a Radiobutton for checkbox-like behavior in Tkinter.
Use the Checkbutton class with an IntVar to create a checkbox in Tkinter.
What is the purpose of the Frame widget in Tkinter?
The purpose of the Frame widget in Tkinter is to serve as a container for organizing and managing other widgets.
To handle user input and events.
To display images and graphics.
To create pop-up dialogs and alerts.
How do you display an image in a Tkinter application?
Display the image in a Text widget.
Use a Button widget to display the image.
Load the image using a String variable.
Use PhotoImage to load the image and a Label or Canvas to display it.
How can you create a scrollbar in a Tkinter application?
Use the Scrollbar class and attach it to a widget.
Implement a Frame widget to create a scrollbar.
Use the Canvas widget to draw a scrollbar manually.
Scrollbars cannot be created in Tkinter applications.
What method is used to configure the properties of a widget in Tkinter?
configure()
update()
modify()
set()
How do you create a message box in Tkinter?
Message boxes are not supported in Tkinter.
Implement a Frame to create a custom message box.
Use the Label widget to display a message box.
Use the messagebox module and call messagebox.showinfo().
What method is used to destroy a Tkinter window?
close()
quit()
destroy()
exit()
How can you create a radio button in Tkinter?
Implement the Radiobutton class with a Tkinter variable to create a radio button.
Use the Button class to create a radio button.
Use the Label widget to simulate a radio button.
Utilize the Checkbutton class for radio button functionality.
What is the purpose of the LabelFrame widget in Tkinter?
The LabelFrame widget is used to create a container with a border and a title.
To display images and graphics.
To handle user input and events.
To create pop-up dialogs and alerts.
Which command used to change the screen size?
window = Tk()
window.mainloop()
window.geometry("400x300")
Which of the following is easy to use from the user?
Command Line
GUI (Graphical User Interface)
Which command used to change the screen size?
window = Tk()
window.mainloop()
window.geometry("400x300")
Which of the following is easy to use from the user?
Command Line
GUI (Graphical User Interface)
__________ is an element of GUI.
Widget
GUI
Application
Which is the correct way to use tkinter in python
program?
include tkinter *
import tkinter *
from tkinter import *
from tkinter include *
Which of the following function used to create window in
python tkinter.
window()
tk()
toolkit()
wd()
Which of the following attribute used to change the text
color of a Label widget in python tkinter
fg
foreground
bg
background
Which of the following attribute used to change the
background color of a Label widget in python tkinter
background
bg
fg
foreground
What is the full form of GUI?
Graphic Unit Interface
Graphical User Interface
Graphic Unit Input
______________ library provides fast and easy way to create GUI applications in Python.
Tkinter
IbtikarMaker
Graph
Choose the correct statement to display title.
window.title("My First Program")
window.title(My First Program)
window.title "My First Program"
Label , Button , Sliders are all examples of Widgets.
True
False
Which function is used to set the size of the tkinter
window?
setsize()
size()
geometry()
dimension()
What is the use of mainloop() function in tkinter window?
To create the window screen
To hold the window screen
To delete the window screen
To disable the window screen
What is tkinter?
A Python GUI module
A Python Scripting module
It provides a scrollbar to the use so that the use can scroll the window up and down.
Scrollbar()
Spinbox()
Menu()
Entry()
Your program code should end with .mainloop()
(a)
You can write your program without importing tkinter
(a)
How to initiate Tkinter window?
Tk( )
CTk( )
TTK( )
TK( )
How to initiate Customtkinter window?
Tk( )
CTk( )
CTK( )
cTk( )
What's the purpose of 'functions'?
reduce the lines of code
To perform repeated tasks
Code readability
Break down the codes
Functions don't get executed unless they are called to perform a task. Yes or No?
(a)
To create a function, you need to start with 'def'.
Yes or No?
(a)
When do you use indent space?
(a)
When should I use .get( ) ?
(a)
button = Button (window, text = 'click to calculate', command = calculate).
What's the role of 'command' in the above code?
(a)
value = entry . get( )
In the above code, the input value from the entry widget will be assigned to value. True or False?
(a)
results_e . configure(text = 'new value')
In the above code, .configure ( ) is to update the values. Yes or No?
(a)
Your program code should end with .mainloop()
(a)
You can write your program without importing tkinter
(a)
How to initiate Tkinter window?
Tk( )
CTk( )
TTK( )
TK( )
How to initiate Customtkinter window?
Tk( )
CTk( )
CTK( )
cTk( )
What's the purpose of 'functions'?
reduce the lines of code
To perform repeated tasks
Code readability
Break down the codes
Functions don't get executed unless they are called to perform a task. Yes or No?
(a)
To create a function, you need to start with 'def'.
Yes or No?
(a)
When do you use indent space?
(a)
When should I use .get( ) ?
(a)
button = Button (window, text = 'click to calculate', command = calculate).
What's the role of 'command' in the above code?
(a)
value = entry . get( )
In the above code, the input value from the entry widget will be assigned to value. True or False?
(a)
results_e . configure(text = 'new value')
In the above code, .configure ( ) is to update the values. Yes or No?
(a)
How do you create a Label widget in Tkinter?
Which method is used to change the font color in a tkinter widget?
change_color()
config(fontcolor=)
set_fontcolor()
configure(fg="color")
What is the command to create a basic window in tkinter?
What does GUI stand for in computer programming?
Graphical User Interaction
General Use Interface
Graphical User Interface
General User Interaction
Which widget is used to input single-line text from the user in Tkinter?
Label
Text
Entry
Frame
What is the function of the pack() method in Tkinter?
Organizing widgets in a grid
Organizing widgets in blocks before placing them in the parent widget
Placing widgets on specific positions in the window
Organizing the layout of multiple windows
Which of the following is a Python library used for creating GUI applications?
Pandas
Matplotlib
Tkinter
NumPy
What is the purpose of creating Frame widgets in a Tkinter application?
To add decorative images
To group related widgets or provide padding
To control the application flow
To set text color schemes
What is the purpose of Tkinter in Python programming?
Handling databases
Creating Graphical User Interfaces (GUIs)
Working with big data
Developing machine learning models
Which widget is used to display text or images that cannot be edited by the user in Tkinter?
Button
Entry
Text
Label
Which parameter in the Button widget defines the text displayed on the button?
text
width
height
Command
What geometry management technique allows specific positioning of widgets in Tkinter?
grid
place() method
pack() method
place() and pack()
Which geometry manager is commonly used in Tkinter for organizing widgets?
Place
Grid
Pack
Layout
What is the purpose of the grid() method?
It creates a new window for the Tkinter application.
Organizes the widgets in a (table-like structure) before placing them in the parent widget.
It sets the font style and size of the label widget.
It displays the window and starts the Tkinter event loop.
What is the purpose of the mainloop() function in Tkinter?
Ends the program execution
Closes the GUI window
Starts the main event loop
Defines the main GUI layout
What is a widget in the context of graphical user interfaces (GUIs)?
A small furry creature that lives on the desktop.
An element or component that users can interact with to perform tasks or access information in a GUI application.
A tool used by developers to debug GUI code.
A virtual container for storing data in a GUI application.
Which widget is commonly used to trigger actions when clicked in Tkinter?
Entry
Label
Button
Frame
Which of the following is NOT a widget in Tkinter?
Button
Label
Frame
Series
What is the purpose of the update_clock() function when creating a digital clock?
It sets the title of the Tkinter window to "Digital Clock".
It retrieves the current time and updates the text of the clock_label widget every second.
It creates a new Label widget named clock_label with a font size of 50.
It initializes the Tkinter event loop and starts the application.
When creating a simple GUI login interface, what should happen if the username is "admin" and the password is "password"?
Display a message indicating invalid credentials
Verify the credentials upon clicking the login button
Exit the program with an error message
Display a success message for incorrect credentials
Is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, instead of text-based UIs, typed command labels or text navigation.
Python
G.U.I
IDE
IDLE
This library provides a powerful object-oriented interface to the GUI toolkit.
Pygames
PyGUI
tthinker
tkinter
what is the widget been programmed?
if else
messagebox
label
button
what is the widget been programmed?
text
window title
label
button
what is the correct execution of the code as seen in the picture?
def clicked():
lbl.configure(text="Button was clicked !!")
def pindot(): lbl.configure(text="Button was clicked !!")
def clicked(): lbl.configurate(text="Button was clicked !!")
def clicked(): button.configure(text="Button was clicked !!")
what is the correct execution of the code as seen in the picture?
lbl = label(window, text="Hello")
lbl = Label(window, text="Hello")
lbl = Text(window, text="Hello")
lbl = txt(window, text="Hello")
what is the widget been programmed?
radiobutton
selectbox
combobox
checkbox
what is the widget been programmed?
radiobutton
button
combobox
checkbox
what is the widget been programmed?
message box
info message
alert box
message content
what is the correct code for the picture?
btn = Button(window, text="Click Me", bg="org", fg="rd")
btn = Button(window, text="Click Me", bg="blue", fg="red")
btn = Button(window, text="Click Me", bg="orange", fg="red")
btn = Button(window, text="Click Me", bg="red", fg="orange")
How do you create a Label widget in Tkinter?
What is the command to create a basic window in tkinter?
What is the function of the pack() method in Tkinter?
Organizing widgets in a grid
Organizing widgets in blocks before placing them in the parent widget
Placing widgets on specific positions in the window
Organizing the layout of multiple windows
What is the purpose of creating Frame widgets in a Tkinter application?
To add decorative images
To group related widgets or provide padding
To control the application flow
To set text color schemes
Which widget is used to display text or images that cannot be edited by the user in Tkinter?
Button
Entry
Text
Label
Which geometry manager is commonly used in Tkinter for organizing widgets?
Place
Grid
Pack
Layout
What is a widget in the context of graphical user interfaces (GUIs)?
A small furry creature that lives on the desktop.
An element or component that users can interact with to perform tasks or access information in a GUI application.
A tool used by developers to debug GUI code.
A virtual container for storing data in a GUI application.
Which widget is commonly used to trigger actions when clicked in Tkinter?
Entry
Label
Button
Frame
What is the purpose of the update_clock() function when creating a digital clock?
It sets the title of the Tkinter window to "Digital Clock".
It retrieves the current time and updates the text of the clock_label widget every second.
It creates a new Label widget named clock_label with a font size of 50.
It initializes the Tkinter event loop and starts the application.
Which is the correct way to use tkinter in python
program?
include tkinter *
import tkinter *
from tkinter import *
from tkinter include *
Which of the following function used to create window in
python tkinter.
window()
tk()
toolkit()
wd()
Which of the following attribute used to change the
background color of a Label widget in python tkinter
background
bg
fg
foreground
Choose the correct statement to display title.
window.title("My First Program")
window.title(My First Program)
window.title "My First Program"
title.window("My First Program")
what is the correct execution of the code as seen in the picture?
def clicked():
lbl.configure(text="Button was clicked !!")
def pindot(): lbl.configure(text="Button was clicked !!")
def clicked(): lbl.configurate(text="Button was clicked !!")
def clicked(): button.configure(text="Button was clicked !!")
what is the correct execution of the code as seen in the picture?
lbl = label(window, text="Hello")
lbl = Label(window, text="Hello")
lbl = Text(window, text="Hello")
lbl = txt(window, text="Hello")
what is the widget been programmed?
radiobutton
selectbox
combobox
checkbox
what is the widget been programmed?
radiobutton
button
combobox
checkbox
what is the widget been programmed?
message box
info message
alert box
message content
what is the correct code for the picture?
btn = Button(window, text="Click Me", bg="org", fg="rd")
btn = Button(window, text="Click Me", bg="blue", fg="red")
btn = Button(window, text="Click Me", bg="orange", fg="red")
btn = Button(window, text="Click Me", bg="red", fg="orange")
what is the widget been programmed?
Entry
Canvas
Relief Style
Bitmaps
To create a border style for a Label or Button, which property should we change?
anchor
bd
relief
text
To add images to Tkinter, which library do we use?
PIL
pip
tkinter
os
Which of the following class declarations is correct
Class<class name>
Class<class name>:
class<class name>
class<class name>:
Which of the following is not a concept in object-oriented programming?
Object
String
Attribute (field, attribute)
Method
What does OOP stand for?
Object Oriented Programming
Object Oriented Processing
Open Object Programming
Object Open Programming
Which of the following statements about Python is false?
Python is a high-level programming language
Python is an object-oriented programming language
Python is a structured programming language
Python is a versatile programming language
What does GUI stand for?
Game User Interface
Graphical User Internation
Graphical Under Interface
Graphical User Interface
Which library do we use to program GUI?
tkinter
os
math
random
Which of the following ways to declare the tkinter library is incorrect?
import tkinter
from tkinter import*
import tkinter as k
from tkinter
What is the command to initialize a window in tkinter?
Tk()
tk()
bg()
Bg()
What syntax is used to set up an event for a Button?
command
relief
justify
anchor
Which command do we use to display a warning?
messagebox.showinfo()
messagebox.showwarning()
messagebox.showerror()
messagebox.askquestion()
What command do we use to hide the Entry content with a *?
show='*'
bd='*'
bg='*'
relief='*'
Which command is used to disable an Entry or Button?
show=’ disable’
relief=’ disable’
state=’ disable’
bd=’ disable’
What command do we use to create a parent window?
Top()
TopLevel()
Level()
Tk()
Which of the following statements about grid is incorrect?
To facilitate the placement of control objects on the form
The workspace is divided into rows and columns
Rows and columns are counted from 0
Can be used together with the pack() command
To retrieve information from entry, Radiobutton, Textbox, which command should we use?
.get()
.textvariable
.StringVar()
.IntVar()
What is the function of eval?
Calculate an integer expression
Calculate a string expression
To draw a circle
Calculate the result of strings
What is the purpose of the try – except statement?
Used to handle errors.
Used to handle conditions like if – else
To create a loop
To fix program errors
Which of the following statements is false about lambda functions
A lambda function is a function defined without a name
A lambda function can have multiple parameters but only one expression
A lambda function cannot return a value
A lambda function is also known as an anonymous function
What is the syntax of a lambda function?
def lambda (<parameter>):
<expression>
lambda <parameter>: <expression>
lambda <parameter>, <expression>
lambda (<parameter>, <expression>)
What command is used to set up events for items in the menu button?
command
tearoff
separator
add_command()
What command do we use to create a color palette?
chooser.askcolor()
color.askcolor()
colorchooser.askcolor()
bg.askcolor()
To create a parent menu, which structure do we use?
add_cascade()
add_cascade
add_command()
add_command
What structure is used to create a slider?
Scale(window,from_=<start value>,to=<end value>)
ttk.Scale(window,from_=<start value>,to=<end value>)
tk.Scale(window,from_=<start value>,to=<end value>)
Tk.Scale(window,from_=<start value>,to=<end value>)
