MCPcopy Index your code
hub / github.com/python/cpython / _place_window

Function _place_window

Lib/tkinter/simpledialog.py:234–260  ·  view source on GitHub ↗
(w, parent=None)

Source from the content-addressed store, hash-verified

232# Place a toplevel window at the center of parent or screen
233# It is a Python implementation of ::tk::PlaceWindow.
234def _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
263def _setup_dialog(w):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls 15

wm_withdrawMethod · 0.80
update_idletasksMethod · 0.80
winfo_reqwidthMethod · 0.80
winfo_reqheightMethod · 0.80
winfo_vrootwidthMethod · 0.80
winfo_vrootheightMethod · 0.80
winfo_ismappedMethod · 0.80
winfo_rootxMethod · 0.80
winfo_widthMethod · 0.80
winfo_rootyMethod · 0.80
winfo_heightMethod · 0.80
winfo_vrootxMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…