Merge pull request #3799 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
PySimpleGUI 2021-01-17 12:45:28 -05:00 committed by GitHub
commit 0fee135a86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 68 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.33.0.4 Unreleased\nAliases shown SDK reference, popup_scrolled fix, summary mode for SDK help, BIG PEP8 definition swap" version = __version__ = "4.33.0.5 Unreleased\nAliases shown SDK reference, popup_scrolled fix, summary mode for SDK help, BIG PEP8 definition swap, changed metadata into a class property, docstring change for element lookups"
__version__ = version.split()[0] # For PEP 396 and PEP 345 __version__ = version.split()[0] # For PEP 396 and PEP 345
@ -766,6 +766,8 @@ class Element():
self.TKEntry = None self.TKEntry = None
self.TKImage = None self.TKImage = None
self._metadata = None # type: Any
self.ParentForm = None # type: Window self.ParentForm = None # type: Window
self.ParentContainer = None # will be a Form, Column, or Frame element # UNBIND self.ParentContainer = None # will be a Form, Column, or Frame element # UNBIND
self.TextInputDefault = None self.TextInputDefault = None
@ -780,7 +782,7 @@ class Element():
self.Widget = None # Set when creating window. Has the main tkinter widget for element self.Widget = None # Set when creating window. Has the main tkinter widget for element
self.Tearoff = False # needed because of right click menu code self.Tearoff = False # needed because of right click menu code
self.ParentRowFrame = None # type tk.Frame self.ParentRowFrame = None # type tk.Frame
self.metadata = metadata # type: Any self.metadata = metadata
self.user_bind_dict = {} # Used when user defines a tkinter binding using bind method - convert bind string to key modifier self.user_bind_dict = {} # Used when user defines a tkinter binding using bind method - convert bind string to key modifier
self.user_bind_event = None # Used when user defines a tkinter binding using bind method - event data from tkinter self.user_bind_event = None # Used when user defines a tkinter binding using bind method - event data from tkinter
self.pad_used = (0,0) # the amount of pad used when was inserted into the layout self.pad_used = (0,0) # the amount of pad used when was inserted into the layout
@ -794,13 +796,32 @@ class Element():
def visible(self): def visible(self):
""" """
Returns visibility state for the element. This is a READONLY property Returns visibility state for the element. This is a READONLY property
To control visibility, use the element's update method
:return: Visibility state for element :return: Visibility state for element
:rtype: (bool) :rtype: (bool)
""" """
return self._visible return self._visible
@property
def metadata(self):
"""
Metadata is an Element property that you can use at any time to hold any value
:return: the current metadata value
:rtype: (Any)
"""
return self._metadata
@metadata.setter
def metadata(self, value):
"""
Metadata is an Element property that you can use at any time to hold any value
:param value: Anything you want it to be
:type value: (Any)
"""
self._metadata = value
def _RightClickMenuCallback(self, event): def _RightClickMenuCallback(self, event):
""" """
Callback function that's called when a right click happens. Shows right click menu as result Callback function that's called when a right click happens. Shows right click menu as result
@ -7441,6 +7462,7 @@ class Window:
:type metadata: (Any) :type metadata: (Any)
""" """
self._metadata = None # type: Any
self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT
self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS
self.Title = str(title) self.Title = str(title)
@ -7599,6 +7621,26 @@ class Window:
root.destroy() root.destroy()
return screen_width, screen_height return screen_width, screen_height
@property
def metadata(self):
"""
Metadata is available for all windows. You can set to any value.
:return: the current metadata value
:rtype: (Any)
"""
return self._metadata
@metadata.setter
def metadata(self, value):
"""
Metadata is available for all windows. You can set to any value.
:param value: Anything you want it to be
:type value: (Any)
"""
self._metadata = value
# ------------------------- Add ONE Row to Form ------------------------- # # ------------------------- Add ONE Row to Form ------------------------- #
def add_row(self, *args): def add_row(self, *args):
""" """
@ -9262,8 +9304,8 @@ class Window:
window['element key'].Update window['element key'].Update
:param key: The key to find :param key: The key to find
:type key: str | int | tuple | object"" :type key: str | int | tuple | object
:rtype: Element | None :rtype: Element | Input | Combo | OptionMenu | Listbox | Radio | Checkbox | Spin | Multiline | Text | StatusBar | Output | Button | ButtonMenu | ProgressBar | Image | Canvas | Graph | Frame | VerticalSeparator | HorizontalSeparator | Tab | TabGroup | Slider | Column | Pane | Menu | Table | Tree | ErrorElement | None
""" """
return self.FindElement(key) return self.FindElement(key)
@ -9552,6 +9594,7 @@ class SystemTray:
:param metadata: User metadata that can be set to ANYTHING :param metadata: User metadata that can be set to ANYTHING
:type metadata: (Any) :type metadata: (Any)
""" """
self._metadata = None
self.Menu = menu self.Menu = menu
self.TrayIcon = None self.TrayIcon = None
self.Shown = False self.Shown = False
@ -9576,6 +9619,26 @@ class SystemTray:
self.window['-IMAGE-'].bind('<Double-Button-1>', '+DOUBLE_CLICK') self.window['-IMAGE-'].bind('<Double-Button-1>', '+DOUBLE_CLICK')
@property
def metadata(self):
"""
Metadata is an SystemTray property that you can use at any time to hold any value
:return: the current metadata value
:rtype: (Any)
"""
return self._metadata
@metadata.setter
def metadata(self, value):
"""
Metadata is an SystemTray property that you can use at any time to hold any value
:param value: Anything you want it to be
:type value: (Any)
"""
self._metadata = value
def read(self, timeout=None): def read(self, timeout=None):
""" """