wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Tkinter-Button

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.
In Tkinter, what is a Button?
a)
A graphical element for displaying text
b)
A container for other widgets
c)
A drawing tool
d)
A type of loop
2.
Which module needs to be imported to use Tkinter in Python?
a)
tk
b)
interface
c)
ui
d)
Tkinter
3.

Rohan wants to add a fun element to his Tkinter GUI. How can he create a cool Button that says 'Click Me'?

a)

button = tk.Button("Click Me")

b)

button = tk.create_button("Click Me")

c)

button = Button.create("Click Me")

d)

button = tk.Button(text="Click Me")

4.
What is the purpose of a Button in Tkinter?
a)
To display images
b)
To group and organize other widgets
c)
To create buttons
d)
To draw shapes
5.
How can you bind a function to a button click event in Tkinter?
a)
button.bind("click", function)
b)
button.onclick(function)
c)
button.bind("", function)
d)
button.config(command=function)
6.
Which geometry manager is commonly used to position a Button within its parent widget?
a)
Pack
b)
Grid
c)
Place
d)
Layout
7.

Siya, Aanya, and Myra are having a competition to see who can change the size of a Button in Tkinter the fastest! Which method should they use?

a)

button.size(width, height)

b)

button.config(size=(width, height))

c)

button.width = width, button.height = height

d)

button.config(width=width, height=height)

8.

Krish is customizing a Button component in his web project. What is the magic behind the command parameter in a Button?

a)

To set the text displayed on the button

b)

To specify a function to be executed when the button is clicked

c)

To change the button's position

d)

To change the button's color

9.
How can you create an image-based Button in Tkinter?
a)
button = tk.Button(image="image.png")
b)
button = tk.Button(image=Image.open("image.png"))
c)
button = Button.create(image="image.png")
d)
button = tk.Button(image=tk.PhotoImage(file="image.png"))
10.
What is the purpose of the relief parameter in a Button?
a)
To change the button's position
b)
To set the button's background color
c)
To specify the border style of the button
d)
To set the padding inside the button