MCPcopy Index your code
hub / github.com/RustPython/RustPython / _place_window

Function _place_window

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

Source from the content-addressed store, hash-verified

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

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls 15

minFunction · 0.85
maxFunction · 0.85
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

Tested by

no test coverage detected