MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / _convert_window_to_tk

Function _convert_window_to_tk

PySimpleGUI/PySimpleGUI.py:25992–26062  ·  view source on GitHub ↗
(window)

Source from the content-addressed store, hash-verified

25990
25991
25992def _convert_window_to_tk(window):
25993 # """
25994 #
25995 # :type window: (Window)
25996 #
25997 # """
25998 master = window.TKroot
25999 master.title(window.Title)
26000 InitializeResults(window)
26001
26002 if window.watermark is True:
26003 Window._watermark_temp_forced = True
26004 _global_settings_get_watermark_info()
26005 elif window.watermark is False:
26006 Window._watermark = None
26007 Window._watermark_temp_forced = False
26008
26009 # Add watermak onto the window
26010 if Window._watermark is not None:
26011 window.add_row(Window._watermark(window))
26012
26013 # Call the massive pack function that does the entire window creation
26014 PackFormIntoFrame(window, master, window)
26015
26016 window.TKroot.configure(padx=window.Margins[0], pady=window.Margins[1])
26017
26018 # ....................................... DONE creating and laying out window ..........................#
26019 if window._Size != (None, None):
26020 master.geometry("%sx%s" % (window._Size[0], window._Size[1]))
26021 screen_width = master.winfo_screenwidth() # get window info to move to middle of screen
26022 screen_height = master.winfo_screenheight()
26023 if window.Location is not None:
26024 if window.Location != (None, None):
26025 x, y = window.Location
26026 elif DEFAULT_WINDOW_LOCATION != (None, None):
26027 x, y = DEFAULT_WINDOW_LOCATION
26028 else:
26029 master.update_idletasks() # don't forget to do updates or values are bad
26030 win_width = master.winfo_width()
26031 win_height = master.winfo_height()
26032 x = screen_width / 2 - win_width / 2
26033 y = screen_height / 2 - win_height / 2
26034 if y + win_height > screen_height:
26035 y = screen_height - win_height
26036 if x + win_width > screen_width:
26037 x = screen_width - win_width
26038
26039 if window.RelativeLoction != (None, None):
26040 x += window.RelativeLoction[0]
26041 y += window.RelativeLoction[1]
26042
26043 if x is not None and y is not None:
26044 move_string = '+%i+%i' % (int(x), int(y))
26045 master.geometry(move_string)
26046 window.config_last_location = (int(x), (int(y)))
26047 window.TKroot.x = int(x)
26048 window.TKroot.y = int(y)
26049 window.starting_window_position = (int(x), (int(y)))

Callers 1

StartupTKFunction · 0.85

Calls 5

InitializeResultsFunction · 0.85
PackFormIntoFrameFunction · 0.85
_no_titlebar_setupFunction · 0.85
add_rowMethod · 0.45

Tested by

no test coverage detected