| 1 |
ninoborges |
8 |
#test script from the Programing python book
|
| 2 |
|
|
## Do not run this from Python Win. It crashes it. It runs fine by itself. ie from shell
|
| 3 |
|
|
# Binding events... cool.
|
| 4 |
|
|
|
| 5 |
|
|
from Tkinter import *
|
| 6 |
|
|
|
| 7 |
|
|
def hello(event):
|
| 8 |
|
|
print "Press twice to exit."
|
| 9 |
|
|
|
| 10 |
|
|
def quit(event):
|
| 11 |
|
|
print "Hello, I must be going..."
|
| 12 |
|
|
import sys; sys.exit()
|
| 13 |
|
|
|
| 14 |
|
|
widget = Button(None, text="Hello event world")
|
| 15 |
|
|
widget.pack()
|
| 16 |
|
|
widget.bind('<Button-1>',hello)
|
| 17 |
|
|
widget.bind('<Double-1>',quit)
|
| 18 |
|
|
widget.mainloop() |