diff options
author | Guido van Rossum <guido@python.org> | 1996-07-21 02:20:06 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-07-21 02:20:06 (GMT) |
commit | 17f2b2dfeddc117ba5e9c6188f1a405dce88e67c (patch) | |
tree | d4df29ba1fa795eeef42bac2f0851e3fdc3c8411 /Lib/lib-tk/SimpleDialog.py | |
parent | 421bb0e389ad9c0c3353dfd89fd8ef4e4756d1cb (diff) | |
download | cpython-17f2b2dfeddc117ba5e9c6188f1a405dce88e67c.zip cpython-17f2b2dfeddc117ba5e9c6188f1a405dce88e67c.tar.gz cpython-17f2b2dfeddc117ba5e9c6188f1a405dce88e67c.tar.bz2 |
Don't use tktools, dummy! Reworded test message slightly.
Diffstat (limited to 'Lib/lib-tk/SimpleDialog.py')
-rw-r--r-- | Lib/lib-tk/SimpleDialog.py | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/Lib/lib-tk/SimpleDialog.py b/Lib/lib-tk/SimpleDialog.py index d82773d..7354779 100644 --- a/Lib/lib-tk/SimpleDialog.py +++ b/Lib/lib-tk/SimpleDialog.py @@ -2,7 +2,6 @@ from Tkinter import * -import tktools class SimpleDialog: @@ -10,7 +9,13 @@ class SimpleDialog: def __init__(self, master, text='', buttons=[], default=None, cancel=None, title=None, class_=None): - self.root = tktools.make_toplevel(master, title=title, class_=class_) + if class_: + self.root = Toplevel(master, class_=class_) + else: + self.root = Toplevel(master) + if title: + self.root.title(title) + self.root.iconname(title) self.message = Message(self.root, text=text, aspect=400) self.message.pack(expand=1, fill=BOTH) self.frame = Frame(self.root) @@ -27,7 +32,28 @@ class SimpleDialog: b.config(relief=RIDGE, borderwidth=8) b.pack(side=LEFT, fill=BOTH, expand=1) self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window) - tktools.set_transient(self.root, master) + self._set_transient(master) + + def _set_transient(self, master, relx=0.5, rely=0.3): + widget = self.root + widget.withdraw() # Remain invisible while we figure out the geometry + widget.transient(master) + widget.update_idletasks() # Actualize geometry information + if master.winfo_ismapped(): + m_width = master.winfo_width() + m_height = master.winfo_height() + m_x = master.winfo_rootx() + m_y = master.winfo_rooty() + else: + m_width = master.winfo_screenwidth() + m_height = master.winfo_screenheight() + m_x = m_y = 0 + w_width = widget.winfo_reqwidth() + w_height = widget.winfo_reqheight() + x = m_x + (m_width - w_width) * relx + y = m_y + (m_height - w_height) * rely + widget.geometry("+%d+%d" % (x, y)) + widget.deiconify() # Become visible at the desired location def go(self): self.root.grab_set() @@ -58,8 +84,8 @@ def test(): d = SimpleDialog(root, text="This is a test dialog. " "Would this have been an actual dialog, " - "the buttons below would have glowed " - "in soft pink light. " + "the buttons below would have been glowing " + "in soft pink light.\n" "Do you believe this?", buttons=["Yes", "No", "Cancel"], default=0, |