[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
default = 0, strings = ('spam', 'SPAM')) if name == 'main': OldDialogDemo().mainloop() If you supply Dialog a tuple of button la ...
def dialog(): win = Toplevel() # make a new window Label(win, text='Hard drive reformatted!').pack() # add a few widgets Button( ...
open. Because of that, you can never make more than one copy of the pop up on-screen at once, as shown in Figure 8-19. Figure 8- ...
Other ways to be modal Modal dialogs are typically implemented by waiting for a newly created pop-up win- dow’s destroy event, a ...
We’ll see how to build form-like dialogs with labels and input fields later in this chapter when we meet Entry, and again when w ...
def onDoubleLeftClick(event): print('Got double left mouse click', end=' ') showPosEvent(event) tkroot.quit() tkroot = Tk() labe ...
window show up as black on red, with a large Courier font. You’ll have to take my word for it (or run this on your own). But the ...
Got left mouse button drag: Widget=.25763696 X=145 Y=50 Got left mouse button drag: Widget=.25763696 X=146 Y=51 Got left mouse b ...
Other bind Events Besides those illustrated in this example, a tkinter script can register to catch additional kinds of bindable ...
script method calls and window closures in general, including those at program exit. If you bind this on a window, it will be tr ...
Example 8-16. PP4E\Gui\tour\message.py from tkinter import * msg = Message(text="Oh by the way, which one's Pink?") msg.config(b ...
Figure 8-22. entry1 caught in the act On startup, the entry1 script fills the input field in this GUI with the text “Type words ...
ent.delete('0', END) # delete from start to end ent.insert(END, 'some text') # add at end of empty text Either way, if you don’t ...
if name == 'main': root = Tk() ents = makeform(root, fields) root.bind('', (lambda event: fetch(ents))) Button(root, text='Fetch ...
Example 8-19 uses the prior example’s makeform and fetch functions to generate a form and prints its contents, much as before. H ...
To avoid this problem, we can either be careful to fetch before destroying, or use tkinter variables, the subject of the next se ...
def makeform(root, fields): form = Frame(root) # make outer frame left = Frame(form) # make two columns rite = Frame(form) form. ...
will really change and fetch the corresponding display’s input field value.* The variable object get method returns as a string ...
We laid out input forms two ways in this section: by row frames with fixed-width labels (entry2), and by column frames (entry3). ...
Both kinds of buttons provide both command a n d variable o p t i o n s. T h e command option lets you register a callback to be ...
«
20
21
22
23
24
25
26
27
28
29
»
Free download pdf