tkinter_calc_ii
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tkinter_calc_ii [2024/04/20 00:42] – appledog | tkinter_calc_ii [2024/04/20 00:53] (current) – appledog | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| = TKInter Calc II | = TKInter Calc II | ||
| + | |||
| + | == Themed Widgets | ||
| + | Use ttk.button() //etc.// whenever possible. That's because ttk is the newest version. tk.button() and others are old, don't use them unless ttk. doesn' | ||
| == Binding | == Binding | ||
| Line 14: | Line 17: | ||
| button1 = ttk.Button(root, | button1 = ttk.Button(root, | ||
| - | button1.bind('< | + | button1.bind('< |
| Line 24: | Line 27: | ||
| === Binding Mouse | === Binding Mouse | ||
| + | Observe carefully that < | ||
| + | |||
| < | < | ||
| import tkinter | import tkinter | ||
| Line 40: | Line 45: | ||
| </ | </ | ||
| - | Here, a lambda is used to handle left clicks with < | + | Here, a lambda is used to handle left clicks with < |
| + | |||
| + | == Dragging | ||
| + | To capture a click-and-drag event use any of the < | ||
| + | |||
| + | < | ||
| + | import tkinter | ||
| + | |||
| + | root = tkinter.Tk() | ||
| + | label = tkinter.Label(root, | ||
| + | label.pack() | ||
| + | |||
| + | def drag_handler(event): | ||
| + | print(event.x, | ||
| + | |||
| + | label.bind("< | ||
| + | |||
| + | root.mainloop() | ||
| + | </ | ||
| + | |||
| + | === Hovering | ||
| + | Hovering over an element sends out two events in sequence, < | ||
| + | |||
| + | < | ||
| + | import tkinter | ||
| + | |||
| + | root = tkinter.Tk() | ||
| + | |||
| + | label = tkinter.Label(root, | ||
| + | label.bind("< | ||
| + | label.bind("< | ||
| + | label.pack() | ||
| + | |||
| + | root.mainloop() | ||
| + | </ | ||
tkinter_calc_ii.1713573743.txt.gz · Last modified: 2024/04/20 00:42 by appledog
