[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
To see the effects generated by these two scripts’ settings, try out a few changes on your computer. Most widgets can be given a ...
Example 8-3. PP4E\Gui\Tour\toplevel0.py import sys from tkinter import Toplevel, Button, Label win1 = Toplevel() # two independe ...
Toplevel and Tk Widgets A Toplevel is roughly like a Frame that is split off into its own window and has additional methods that ...
Notice how this GUI’s windows use a window’s destroy method to close just one window, instead of sys.exit to shut down the entir ...
Figure 8-4. Three Toplevel windows with configurations There are a few operational details worth noticing here, all of which are ...
Killing all windows: quit To kill all the windows at once and end the GUI application (really, its active mainloop call), the ro ...
elsewhere), and normal (large enough for window content). The methods lift and lower raise and lower a window with respect to it ...
on Unix only, see other Tk and tkinter resources for more details on this topic. For now, the next scheduled stop on this tour e ...
else: showinfo('No', 'Quit has been cancelled') errmsg = 'Sorry, no Spam allowed!' Button(text='Quit', command=callback).pack(fi ...
There is nothing the user can do with Figure 8-7’s dialog but press OK. If No is clicked in Figure 8-6’s quit verification dialo ...
windows than to distract the user with pop ups). But where appropriate, such pop ups save coding time and provide a nice native ...
If you press OK here, Quitter runs the Frame quit method to end the GUI to which this button is attached (really, the mainloop c ...
if name == 'main': Demo().mainloop() This script creates the window shown in Figure 8-11 when run as a standalone program; it’s ...
This dialog automatically checks the input for valid floating-point syntax before it re- turns, and it is representative of a co ...
They can be passed an initialdir (start directory), initialfile (for “File name”), title (for the dialog window), defaultextens ...
Figure 8-15. demoDlg color, askcolor dialog If you press its OK button, it returns a data structure that identifies the selected ...
from tkinter import * # get base widget set from dialogTable import demos # button callback handlers from quitter import Quitter ...
In earlier Pythons, default arguments were required to pass all values in from enclosing scopes explicitly, using either of thes ...
Letting users select colors on the fly The standard color selection dialog isn’t just another pretty face—scripts can pass the h ...
Color strings are also printed to the stdout stream (the console window); run this on your computer to experiment with available ...
«
19
20
21
22
23
24
25
26
27
28
»
Free download pdf