[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
Figure 9-10. menuDemo: menus and toolbars Figure 9-11. Images and tear-offs on the job Menus | 519 ...
Using images in toolbars, too As shown in Figure 9-11, it’s easy to use images for menu items. Although not used in Example 9-8, ...
photos = 'ora-lp4e.gif', 'pythonPowered.gif', 'python_conf_ora.gif' self.toolPhotoObjs = [] for file in photos: img = PhotoImage ...
an added bonus, it supports both window and frame-style menus, so it can be used by both standalone programs and nested componen ...
list = Listbox(self, relief=SUNKEN) sbar.config(command=list.yview) # xlink sbar and list list.config(yscrollcommand=sbar.set) # ...
Programming Listboxes Listboxes are straightforward to use, but they are populated and processed in somewhat unique ways compare ...
selection modes. The default mode allows only a single item to be selected, but the selectmode argument supports four settings: ...
Moving a listbox vertically invokes the callback handler registered with its yscroll command option. In this script, the sbar.s ...
for navigating through the list. As Figure 9-16 shows, shrinking this script’s window cuts out part of the list but retains the ...
widget. Not entirely by coincidence, this brings us to the next point of interest on our widget tour. Text It’s been said that t ...
return self.text.get('1.0', END+'-1c') # first through last if name == 'main': root = Tk() if len(sys.argv) > 1: st = Scrolle ...
for i in range(250): f.write('%03d) All work and no play makes Jack a dull boy.\n' % i) f.close() C:\...\PP4E\Gui\Tour> pytho ...
When run with arguments, the script stores a file’s contents in the Text widget. When run without arguments, the script stuffs a ...
For added precision, you can add simple arithmetic extensions to index strings. The index expression END+'-1c' in the get call i ...
self.text.tag_add('alltext', '1.0', END) # tag all text in the widget self.text.tag_add(SEL, index1, index2) # select from index ...
Example 9-11. PP4E\Gui\Tour\simpleedit.py """ add common edit tools to ScrolledText by inheritance; composition (embedding) woul ...
self.text.focus() # select text widget if name == 'main': if len(sys.argv) > 1: SimpleEditor(file=sys.argv[1]).mainloop() # f ...
(Figure 9-21); in a full-blown editor, you might want to save this string away to repeat the find again (we will, in Chapter 11’ ...
is no reason that the text string cut couldn’t simply be stored in a Python instance variable. But the clipboard is actually a m ...
Quitter(frm).pack(side=LEFT) self.st = ScrolledText(self, file=file) # attach, not subclass self.st.text.config(font=('courier', ...
«
24
25
26
27
28
29
30
31
32
33
»
Free download pdf