]> granicus.if.org Git - python/commitdiff
Do a better job of keeping the dialog visible when the master window
authorGuido van Rossum <guido@python.org>
Sun, 28 Dec 1997 03:42:50 +0000 (03:42 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 28 Dec 1997 03:42:50 +0000 (03:42 +0000)
is near or beyond the edge of the screen.  Patch by Skip Montanaro.

Lib/lib-tk/SimpleDialog.py

index 7354779c8058f9f98dbfb214d6eb97b122ff8082..950df2f5beb1181f105ca80694f32c794999553c 100644 (file)
@@ -52,6 +52,14 @@ class SimpleDialog:
        w_height = widget.winfo_reqheight()
        x = m_x + (m_width - w_width) * relx
        y = m_y + (m_height - w_height) * rely
+       if x+w_width > master.winfo_screenwidth():
+           x = master.winfo_screenwidth() - w_width
+       elif x < 0:
+           x = 0
+       if y+w_height > master.winfo_screenheight():
+           y = master.winfo_screenheight() - w_height
+       elif y < 0:
+           y = 0
        widget.geometry("+%d+%d" % (x, y))
        widget.deiconify() # Become visible at the desired location