| 1 |
from Tkinter import * |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
def do_motion(event): |
| 6 |
app.button.place(x=event.x, y=event.y) |
| 7 |
|
| 8 |
def dothis(): |
| 9 |
print 'calling me!' |
| 10 |
|
| 11 |
def createWidgets(top): |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
f = Frame(top, width=200, height=200, background='green') |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
f.place(relx=0.0, rely=0.0) |
| 22 |
|
| 23 |
|
| 24 |
f.button = Button(f, foreground='red', text='amazing', command=dothis) |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
f.button.place(relx=0.5, rely=0.0, anchor=NW) |
| 29 |
|
| 30 |
|
| 31 |
f.bind('<Control-Shift-Motion>', do_motion) |
| 32 |
|
| 33 |
return f |
| 34 |
|
| 35 |
root = Tk() |
| 36 |
app = createWidgets(root) |
| 37 |
root.geometry("400x400") |
| 38 |
root.maxsize(1000, 1000) |
| 39 |
root.mainloop() |