How do you use buttons in Tkinter?
Post a Reply
|Oldest Newest Rating|
· December 20, 2014
Here you have a short code on the basics of a button. If you want to learn more about it i suggest googeling tkinter button tutorial or something, but this code should give you an idea of how it works
#Create the main window widget
self.main_window = tkinter.Tk()
#Create a Button widget. The text "Click Me!"
#should appear on the face of the Button. The
#do_something method sould be executed when the
#user clicks the Button
self.my_button = tkinter.Button(self.main_window, \
text="Click me!", \
command = self.do_something)
#Pack the button
#Enter the tkinter main loop
#The do_something method is a callback function
#for the Button widget
#Display an info dialog box
"Thanks for clicking the button")
my_gui = MyGUI()
This section is all about snakes! Just kidding.
|Bucky Roberts Administrator|