[source code] Python GUI with Tkinter - 6 - Binding Functions to Layouts

+1 Bucky Roberts · September 11, 2014
from tkinter import *

root = Tk()

def printName(event):
       print("Chello my name is Bucky.")

button_1 = Button(root, text="Print Message")
# <Button-1> is an event that means "clicked left mouse button"
button_1.bind("<Button-1>", printName)
button_1.pack()

root.mainloop()

Post a Reply

Replies

Oldest  Newest  Rating
0 Jörg Bummer · November 20, 2014
There is a typo on line eight.
the quotation marks at the end of the print message is missing
0 Bucky Roberts · November 20, 2014
Thanks, fixed it.
  • 1

Python

128,061 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator