(w, parent=None)
| 232 | # Place a toplevel window at the center of parent or screen |
| 233 | # It is a Python implementation of ::tk::PlaceWindow. |
| 234 | def _place_window(w, parent=None): |
| 235 | w.wm_withdraw() # Remain invisible while we figure out the geometry |
| 236 | w.update_idletasks() # Actualize geometry information |
| 237 | |
| 238 | minwidth = w.winfo_reqwidth() |
| 239 | minheight = w.winfo_reqheight() |
| 240 | maxwidth = w.winfo_vrootwidth() |
| 241 | maxheight = w.winfo_vrootheight() |
| 242 | if parent is not None and parent.winfo_ismapped(): |
| 243 | x = parent.winfo_rootx() + (parent.winfo_width() - minwidth) // 2 |
| 244 | y = parent.winfo_rooty() + (parent.winfo_height() - minheight) // 2 |
| 245 | vrootx = w.winfo_vrootx() |
| 246 | vrooty = w.winfo_vrooty() |
| 247 | x = min(x, vrootx + maxwidth - minwidth) |
| 248 | x = max(x, vrootx) |
| 249 | y = min(y, vrooty + maxheight - minheight) |
| 250 | y = max(y, vrooty) |
| 251 | if w._windowingsystem == 'aqua': |
| 252 | # Avoid the native menu bar which sits on top of everything. |
| 253 | y = max(y, 22) |
| 254 | else: |
| 255 | x = (w.winfo_screenwidth() - minwidth) // 2 |
| 256 | y = (w.winfo_screenheight() - minheight) // 2 |
| 257 | |
| 258 | w.wm_maxsize(maxwidth, maxheight) |
| 259 | w.wm_geometry('+%d+%d' % (x, y)) |
| 260 | w.wm_deiconify() # Become visible at the desired location |
| 261 | |
| 262 | |
| 263 | def _setup_dialog(w): |
no test coverage detected
searching dependent graphs…