annotate Lib/lib-tk/tkSimpleDialog.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 5cec436d64a2
children 787b969d37f0 c79ec63e6c08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47182
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1 #
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
2 # An Introduction to Tkinter
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
3 # tkSimpleDialog.py
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
4 #
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
5 # Copyright (c) 1997 by Fredrik Lundh
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
6 #
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
7 # fredrik@pythonware.com
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
8 # http://www.pythonware.com
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
9 #
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
10
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
11 # --------------------------------------------------------------------
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
12 # dialog base class
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
13
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
14 '''Dialog boxes
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
15
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
16 This module handles dialog boxes. It contains the following
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
17 public symbols:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
18
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
19 Dialog -- a base class for dialogs
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
20
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
21 askinteger -- get an integer from the user
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
22
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
23 askfloat -- get a float from the user
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
24
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
25 askstring -- get a string from the user
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
26 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
27
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
28 from Tkinter import *
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
29
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
30 class Dialog(Toplevel):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
31
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
32 '''Class to open dialogs.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
33
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
34 This class is intended as a base class for custom dialogs
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
35 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
36
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
37 def __init__(self, parent, title = None):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
38
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
39 '''Initialize a dialog.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
40
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
41 Arguments:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
42
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
43 parent -- a parent window (the application window)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
44
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
45 title -- the dialog title
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
46 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
47 Toplevel.__init__(self, parent)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
48
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
49 # If the master is not viewable, don't
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
50 # make the child transient, or else it
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
51 # would be opened withdrawn
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
52 if parent.winfo_viewable():
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
53 self.transient(parent)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
54
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
55 if title:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
56 self.title(title)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
57
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
58 self.parent = parent
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
59
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
60 self.result = None
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
61
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
62 body = Frame(self)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
63 self.initial_focus = self.body(body)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
64 body.pack(padx=5, pady=5)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
65
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
66 self.buttonbox()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
67
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
68 self.wait_visibility() # window needs to be visible for the grab
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
69 self.grab_set()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
70
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
71 if not self.initial_focus:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
72 self.initial_focus = self
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
73
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
74 self.protocol("WM_DELETE_WINDOW", self.cancel)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
75
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
76 if self.parent is not None:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
77 self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
78 parent.winfo_rooty()+50))
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
79
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
80 self.initial_focus.focus_set()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
81
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
82 self.wait_window(self)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
83
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
84 def destroy(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
85 '''Destroy the window'''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
86 self.initial_focus = None
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
87 Toplevel.destroy(self)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
88
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
89 #
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
90 # construction hooks
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
91
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
92 def body(self, master):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
93 '''create dialog body.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
94
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
95 return widget that should have initial focus.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
96 This method should be overridden, and is called
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
97 by the __init__ method.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
98 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
99 pass
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
100
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
101 def buttonbox(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
102 '''add standard button box.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
103
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
104 override if you do not want the standard buttons
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
105 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
106
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
107 box = Frame(self)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
108
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
109 w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
110 w.pack(side=LEFT, padx=5, pady=5)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
111 w = Button(box, text="Cancel", width=10, command=self.cancel)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
112 w.pack(side=LEFT, padx=5, pady=5)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
113
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
114 self.bind("<Return>", self.ok)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
115 self.bind("<Escape>", self.cancel)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
116
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
117 box.pack()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
118
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
119 #
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
120 # standard button semantics
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
121
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
122 def ok(self, event=None):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
123
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
124 if not self.validate():
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
125 self.initial_focus.focus_set() # put focus back
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
126 return
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
127
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
128 self.withdraw()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
129 self.update_idletasks()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
130
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
131 try:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
132 self.apply()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
133 finally:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
134 self.cancel()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
135
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
136 def cancel(self, event=None):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
137
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
138 # put focus back to the parent window
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
139 if self.parent is not None:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
140 self.parent.focus_set()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
141 self.destroy()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
142
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
143 #
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
144 # command hooks
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
145
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
146 def validate(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
147 '''validate the data
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
148
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
149 This method is called automatically to validate the data before the
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
150 dialog is destroyed. By default, it always validates OK.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
151 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
152
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
153 return 1 # override
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
154
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
155 def apply(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
156 '''process the data
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
157
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
158 This method is called automatically to process the data, *after*
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
159 the dialog is destroyed. By default, it does nothing.
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
160 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
161
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
162 pass # override
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
163
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
164
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
165 # --------------------------------------------------------------------
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
166 # convenience dialogues
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
167
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
168 class _QueryDialog(Dialog):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
169
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
170 def __init__(self, title, prompt,
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
171 initialvalue=None,
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
172 minvalue = None, maxvalue = None,
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
173 parent = None):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
174
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
175 if not parent:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
176 import Tkinter
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
177 parent = Tkinter._default_root
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
178
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
179 self.prompt = prompt
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
180 self.minvalue = minvalue
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
181 self.maxvalue = maxvalue
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
182
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
183 self.initialvalue = initialvalue
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
184
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
185 Dialog.__init__(self, parent, title)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
186
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
187 def destroy(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
188 self.entry = None
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
189 Dialog.destroy(self)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
190
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
191 def body(self, master):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
192
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
193 w = Label(master, text=self.prompt, justify=LEFT)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
194 w.grid(row=0, padx=5, sticky=W)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
195
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
196 self.entry = Entry(master, name="entry")
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
197 self.entry.grid(row=1, padx=5, sticky=W+E)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
198
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
199 if self.initialvalue:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
200 self.entry.insert(0, self.initialvalue)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
201 self.entry.select_range(0, END)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
202
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
203 return self.entry
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
204
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
205 def validate(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
206
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
207 import tkMessageBox
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
208
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
209 try:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
210 result = self.getresult()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
211 except ValueError:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
212 tkMessageBox.showwarning(
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
213 "Illegal value",
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
214 self.errormessage + "\nPlease try again",
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
215 parent = self
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
216 )
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
217 return 0
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
218
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
219 if self.minvalue is not None and result < self.minvalue:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
220 tkMessageBox.showwarning(
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
221 "Too small",
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
222 "The allowed minimum value is %s. "
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
223 "Please try again." % self.minvalue,
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
224 parent = self
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
225 )
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
226 return 0
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
227
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
228 if self.maxvalue is not None and result > self.maxvalue:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
229 tkMessageBox.showwarning(
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
230 "Too large",
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
231 "The allowed maximum value is %s. "
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
232 "Please try again." % self.maxvalue,
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
233 parent = self
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
234 )
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
235 return 0
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
236
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
237 self.result = result
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
238
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
239 return 1
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
240
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
241
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
242 class _QueryInteger(_QueryDialog):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
243 errormessage = "Not an integer."
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
244 def getresult(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
245 return int(self.entry.get())
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
246
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
247 def askinteger(title, prompt, **kw):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
248 '''get an integer from the user
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
249
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
250 Arguments:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
251
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
252 title -- the dialog title
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
253 prompt -- the label text
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
254 **kw -- see SimpleDialog class
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
255
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
256 Return value is an integer
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
257 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
258 d = _QueryInteger(title, prompt, **kw)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
259 return d.result
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
260
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
261 class _QueryFloat(_QueryDialog):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
262 errormessage = "Not a floating point value."
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
263 def getresult(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
264 return float(self.entry.get())
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
265
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
266 def askfloat(title, prompt, **kw):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
267 '''get a float from the user
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
268
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
269 Arguments:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
270
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
271 title -- the dialog title
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
272 prompt -- the label text
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
273 **kw -- see SimpleDialog class
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
274
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
275 Return value is a float
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
276 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
277 d = _QueryFloat(title, prompt, **kw)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
278 return d.result
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
279
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
280 class _QueryString(_QueryDialog):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
281 def __init__(self, *args, **kw):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
282 if kw.has_key("show"):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
283 self.__show = kw["show"]
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
284 del kw["show"]
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
285 else:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
286 self.__show = None
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
287 _QueryDialog.__init__(self, *args, **kw)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
288
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
289 def body(self, master):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
290 entry = _QueryDialog.body(self, master)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
291 if self.__show is not None:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
292 entry.configure(show=self.__show)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
293 return entry
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
294
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
295 def getresult(self):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
296 return self.entry.get()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
297
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
298 def askstring(title, prompt, **kw):
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
299 '''get a string from the user
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
300
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
301 Arguments:
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
302
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
303 title -- the dialog title
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
304 prompt -- the label text
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
305 **kw -- see SimpleDialog class
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
306
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
307 Return value is a string
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
308 '''
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
309 d = _QueryString(title, prompt, **kw)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
310 return d.result
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
311
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
312 if __name__ == "__main__":
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
313
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
314 root = Tk()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
315 root.update()
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
316
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
317 print askinteger("Spam", "Egg count", initialvalue=12*12)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
318 print askfloat("Spam", "Egg weight\n(in tons)", minvalue=1, maxvalue=100)
5cec436d64a2 Tkinter renaming reversal: move modules back in their place.
Georg Brandl <georg@python.org>
parents:
diff changeset
319 print askstring("Spam", "Egg label")