[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
Figure 8-45. Simple thumbnail selection GUI, simple row frames Figure 8-46. Thumbnail viewer pop-up image window Viewing and Pro ...
Much of Example 8-45’s code should be straightforward by now. It lays out thumbnail buttons in row frames, much like prior examp ...
""" create thumbs in memory but don't cache to files """ thumbs = [] for imgfile in os.listdir(imgdir): imgpath = os.path.join(i ...
def viewer(imgdir, kind=Toplevel, cols=None): """ custom version that uses gridding """ win = kind() win.title('Viewer: ' + imgd ...
Example 8-48. PP4E\Gui\PIL\viewer-thumbs-fixed.py """ use fixed size for thumbnails, so align regularly; size taken from image o ...
handler = lambda savefile=imgfile: ViewOne(imgdir, savefile) link.config(command=handler, width=size, height=size) link.pack(sid ...
Even with the sample images directory used for this book, we lost the Quit button at the bottom of the display in the last two f ...
...
CHAPTER 9 A tkinter Tour, Part 2 “On Today’s Menu: Spam, Spam, and Spam” This chapter is the second in a two-part tour of the tk ...
also open other “cascading” submenus that list more options, pop up dialog windows, and so on. In tkinter, there are two kinds o ...
file = Menu(top) file.add_command(label='New...', command=notdone, underline=0) file.add_command(label='Open...', command=notdon ...
On Windows, for example, the Quit option in this script’s File menu can be se- lected with the mouse but also by pressing Alt, t ...
And finally, Figure 9-3 shows what happens after clicking the File menu’s tear-off line and selecting the cascading submenu in t ...
Label(win, bg='black', height=5, width=25).pack(expand=YES, fill=BOTH) Button(root, text="Bye", command=root.quit).pack() root.m ...
submenu = Menu(edit, tearoff=True) submenu.add_command(label='Spam', command=parent.quit, underline=0) submenu.add_command(label ...
Example 9-4. PP4E\Gui\Tour\menu_frm-multi.py from menu_frm import makemenu # can't use menu_win here--one window from tkinter im ...
Because they are not tied to the enclosing window, frame-based menus can also be used as part of another attachable component’s ...
options; clicking on the third “state” button fetches and prints the current values dis- played in the first two. Example 9-7. P ...
In addition to simple selections and cascades, menus can also contain disabled entries, check button and radio button selections ...
def makeToolBar(self): toolbar = Frame(self, cursor='hand2', relief=SUNKEN, bd=2) toolbar.pack(side=BOTTOM, fill=X) Button(toolb ...
«
23
24
25
26
27
28
29
30
31
32
»
Free download pdf