diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 00f6e534..3d02b105 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,10 +1,10 @@ #!/usr/bin/python3 -version = __version__ = "4.50.0 Released 17-Oct-2021" +version = __version__ = "4.51.0 Released 18-Oct-2021" _change_log = """ - Changelog since 4.50.0 release to PyPI on 17-Oct-2021 + Changelog since 4.51.0 release to PyPI on 18-Oct-2021 """ @@ -8308,7 +8308,7 @@ class Window: def __init__(self, title, layout=None, default_element_size=None, default_button_element_size=(None, None), - auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None), + auto_size_text=None, auto_size_buttons=None, location=(None, None), relative_location=(None, None), size=(None, None), element_padding=None, margins=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=None, force_toplevel=False, @@ -8334,6 +8334,8 @@ class Window: :type auto_size_text: (bool) :param auto_size_buttons: True if Buttons in this Window should be sized to exactly fit the text on this. :type auto_size_buttons: (bool) + :param relative_location: (x,y) location relative to the CENTER of the window, in pixels. Normally the window centers. This location is relative to THAT centered location. Note they can be negative. + :type relative_location: (int, int) :param location: (x,y) location, in pixels, to locate the upper left corner of the window on the screen. Default is to center on screen. :type location: (int, int) :param size: (width, height) size in pixels for this window. Normally the window is autosized to fit contents, not set to an absolute size by the user. Try not to set this value. You risk, the contents being cut off, etc. Let the layout determine the window size instead @@ -8433,6 +8435,7 @@ class Window: self.DefaultButtonElementSize = default_button_element_size if default_button_element_size != ( None, None) else DEFAULT_BUTTON_ELEMENT_SIZE self.Location = location + self.RelativeLoction = relative_location self.ButtonColor = button_color_to_tuple(button_color) self.BackgroundColor = background_color if background_color else DEFAULT_BACKGROUND_COLOR self.ParentWindow = None @@ -15070,6 +15073,10 @@ def _convert_window_to_tk(window): if x + win_width > screen_width: x = screen_width - win_width + if window.RelativeLoction != (None, None): + x += window.RelativeLoction[0] + y += window.RelativeLoction[1] + move_string = '+%i+%i' % (int(x), int(y)) master.geometry(move_string) window.config_last_location = (int(x), (int(y))) diff --git a/docs/call reference.md b/docs/call reference.md index 9858312c..ed9c0487 100644 --- a/docs/call reference.md +++ b/docs/call reference.md @@ -11363,6 +11363,7 @@ Window(title, auto_size_text = None, auto_size_buttons = None, location = (None, None), + relative_location = (None, None), size = (None, None), element_padding = None, margins = (None, None), @@ -11418,6 +11419,7 @@ Parameter Descriptions: | (int, int) | default_button_element_size | (width, height) size in characters (wide) and rows (high) for all Button elements in this window | | bool | auto_size_text | True if Elements in Window should be sized to exactly fir the length of text | | bool | auto_size_buttons | True if Buttons in this Window should be sized to exactly fit the text on this. | +| (int, int) | relative_location | (x,y) location relative to the CENTER of the window, in pixels. Normally the window centers. This location is relative to THAT centered location. Note they can be negative. | | (int, int) | location | (x,y) location, in pixels, to locate the upper left corner of the window on the screen. Default is to center on screen. | | (int, int) | size | (width, height) size in pixels for this window. Normally the window is autosized to fit contents, not set to an absolute size by the user. Try not to set this value. You risk, the contents being cut off, etc. Let the layout determine the window size instead | | (int, int or (int, int),(int,int)) or int | element_padding | Default amount of padding to put around elements in window (left/right, top/bottom) or ((left, right), (top, bottom)), or an int. If an int, then it's converted into a tuple (int, int) | diff --git a/docs/index.md b/docs/index.md index 9aa44d1b..38fb2761 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9259,6 +9259,14 @@ Column Element allow None for 1 size direction * `FILE_TYPES_ALL_FILES` is a new constant with this value * `popup_scrolled` added 1 line per argument to fit the contents better in some cases +## 4.51.0 PySimpleGUI 18-Oct-2021 +`relative_location` parameter for `Window` + +* New parameter for `Window` - `relative_location` + * Locates the window at an **offset** from the normal location + * Very useful for multi-window applications + * Also works when you've set a default window location using the `set_options` call. + ## Code Condition Make it run diff --git a/readme_creator/markdown input files/4_Release_notes.md b/readme_creator/markdown input files/4_Release_notes.md index 9585e935..3cd31c05 100644 --- a/readme_creator/markdown input files/4_Release_notes.md +++ b/readme_creator/markdown input files/4_Release_notes.md @@ -2226,6 +2226,14 @@ Column Element allow None for 1 size direction * `popup_scrolled` added 1 line per argument to fit the contents better in some cases +## 4.51.0 PySimpleGUI 18-Oct-2021 +`relative_location` parameter for `Window` + +* New parameter for `Window` - `relative_location` + * Locates the window at an **offset** from the normal location + * Very useful for multi-window applications + * Also works when you've set a default window location using the `set_options` call. + ## Code Condition Make it run diff --git a/readme_creator/output/call reference.md b/readme_creator/output/call reference.md index 9858312c..ed9c0487 100644 --- a/readme_creator/output/call reference.md +++ b/readme_creator/output/call reference.md @@ -11363,6 +11363,7 @@ Window(title, auto_size_text = None, auto_size_buttons = None, location = (None, None), + relative_location = (None, None), size = (None, None), element_padding = None, margins = (None, None), @@ -11418,6 +11419,7 @@ Parameter Descriptions: | (int, int) | default_button_element_size | (width, height) size in characters (wide) and rows (high) for all Button elements in this window | | bool | auto_size_text | True if Elements in Window should be sized to exactly fir the length of text | | bool | auto_size_buttons | True if Buttons in this Window should be sized to exactly fit the text on this. | +| (int, int) | relative_location | (x,y) location relative to the CENTER of the window, in pixels. Normally the window centers. This location is relative to THAT centered location. Note they can be negative. | | (int, int) | location | (x,y) location, in pixels, to locate the upper left corner of the window on the screen. Default is to center on screen. | | (int, int) | size | (width, height) size in pixels for this window. Normally the window is autosized to fit contents, not set to an absolute size by the user. Try not to set this value. You risk, the contents being cut off, etc. Let the layout determine the window size instead | | (int, int or (int, int),(int,int)) or int | element_padding | Default amount of padding to put around elements in window (left/right, top/bottom) or ((left, right), (top, bottom)), or an int. If an int, then it's converted into a tuple (int, int) | diff --git a/readme_creator/output/index.md b/readme_creator/output/index.md index 9aa44d1b..38fb2761 100644 --- a/readme_creator/output/index.md +++ b/readme_creator/output/index.md @@ -9259,6 +9259,14 @@ Column Element allow None for 1 size direction * `FILE_TYPES_ALL_FILES` is a new constant with this value * `popup_scrolled` added 1 line per argument to fit the contents better in some cases +## 4.51.0 PySimpleGUI 18-Oct-2021 +`relative_location` parameter for `Window` + +* New parameter for `Window` - `relative_location` + * Locates the window at an **offset** from the normal location + * Very useful for multi-window applications + * Also works when you've set a default window location using the `set_options` call. + ## Code Condition Make it run