[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
Button(frm, text='State', command=self.report).pack(fill=X) Quitter(frm).pack(fill=X) if name == 'main': Demo().mainloop() In te ...
Check buttons and variables When I first studied check buttons, my initial reaction was: why do we need tkinter variables here a ...
Figure 8-27. Manual check button state window Manually maintained state toggles are updated on every button press and are printe ...
Radio Buttons Radio buttons are toggles too, but they are generally used in groups: just like the me- chanical station selector ...
Figure 8-28 shows what this script generates when run. Pressing any of this window’s radio buttons triggers its command handler, ...
fact, to make radio buttons work normally at all, it’s crucial that they are all associated with the same tkinter variable and h ...
If you press 1, 4, or 7 now, all three of these are selected, and any existing selections are cleared (they don’t have the value ...
Example 8-28. PP4E\Gui\Tour\demo-radio-auto.py radio buttons, the easy way from tkinter import * root = Tk() # IntVars work too ...
This should come up with button “5” selected initially, but it doesn’t. The variable referenced by local tmp is reclaimed on fun ...
class Demo(Frame): def init(self, parent=None, options): Frame.init(self, parent, options) self.pack() Label(self, text="Scale d ...
Note that scales are also packed in their container, just like other tkinter widgets. Let’s see how these ideas translate in pra ...
simply register movement callbacks or call the scale get method to fetch scale values on demand, as in the simpler scale example ...
variable object with both scales. As we learned in the last section, changing a widget changes its variable, but changing a vari ...
part.config(bd=2, relief=GROOVE) # or pass configs to Demo() part.pack(side=LEFT, expand=YES, fill=BOTH) # grow, stretch with wi ...
demo objects was something more useful, like a text editor, calculator, or clock, you’ll better appreciate the point of this exa ...
However, the preceding code is not legal Python syntax—the module name in import statements and dot expressions must be a Python ...
part.config(bd=2, relief=GROOVE) # or pass configs to Demo() part.pack(side=LEFT, expand=YES, fill=BOTH) # grow, stretch with wi ...
Independent Windows Once you have a set of component classes coded as frames, any parent will work— both other frames and brand- ...
Figure 8-34. demoAll_win: new Toplevel windows The main root window of this program appears in the lower left of this screenshot ...
Running Programs To be more independent, Example 8-34 spawns each of the four demo launchers as independent programs (processes) ...
«
21
22
23
24
25
26
27
28
29
30
»
Free download pdf