[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
def label(root, side, text, extras): widget = Label(root, text=text, relief=RIDGE) # default config widget.pack(side=side, expan ...
Example 10-2. PP4E\Gui\Tools\guimixin.py """ ############################################################################### a " ...
view = ScrolledText(new, file=filename) # Text with Scrollbar view.text.config(height=30, width=85) # config Text in Frame view. ...
There are a few details worth highlighting here: The quit method serves some of the same purpose as the reusable Quitter button ...
GuiMaker: Automating Menus and Toolbars The last section’s mixin class makes common tasks simpler, but it still doesn’t address ...
toolBar = [] # change per instance in subclasses helpButton = True # set these in start() if need self def init(self, parent=Non ...
would need prebuilt gifs or PIL for thumbnails """ if self.toolBar: toolbar = Frame(self, cursor='hand2', relief=SUNKEN, bd=2) t ...
############################################################################### Self-test when file run standalone: 'python guim ...
arguments by using Python’s func(**kargs) call syntax. As is, labels are assumed to be text, but images could be supported too ( ...
GuiMaker Classes In return for conforming to GuiMaker protocols and templates, client subclasses get a Frame that knows how to a ...
We’ll put GuiMaker to more practical use in instances such as the PyEdit example in Chapter 11. The next section shows another w ...
class Hello(GuiMixin, GuiMakerWindowMenu): # or GuiMakerFrameMenu def start(self): self.hellos = 0 self.master.title("GuiMaker D ...
if self.hellos % 3: print("hi") else: self.infobox("Three", 'HELLO!') # on every third press def dialog(self): button = self.que ...
Finally, I should note that GuiMaker could be redesigned to use trees of embedded class instances that know how to apply themsel ...
Speaking of suggested enhancements, in Chapter 9, I showed you a first- cut way to use images instead of text for buttons in too ...
def start(self): # use GuiMaker if component self.setMenuBar() self.setToolBar() self.master.title("Shell Tools Listbox") self.m ...
return self.myMenu.items() def runCommand(self, cmd): self.myMenu[cmd]() The ShellGui class in this module knows how to use the ...
class TextPak2(DictMenuGui): def init(self): self.myMenu = {'Pack ': runPackDialog, # or use input here... 'Unpack': runUnpackDi ...
Adding GUI Frontends to Command Lines So far, we’ve coded a general shell tools class library, as well as an application-specifi ...
else: name = prefix + line[mlen:-1] # or make new output print('creating:', name) output = open(name, 'w') if name == 'main': un ...
«
28
29
30
31
32
33
34
35
36
37
»
Free download pdf