commit
560a7e4dfb
274
PySimpleGUI.py
274
PySimpleGUI.py
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
version = __version__ = "4.1.0.15 Unreleased - Anniversary Edition"
|
version = __version__ = "4.1.0.16 Unreleased - Anniversary Edition"
|
||||||
|
|
||||||
|
|
||||||
# 888888ba .d88888b oo dP .88888. dP dP dP
|
# 888888ba .d88888b oo dP .88888. dP dP dP
|
||||||
|
@ -403,7 +403,7 @@ class ToolTip:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param widget: (widget type varies) The tkinter widget
|
:param widget: (widget type varies) The tkinter widget
|
||||||
:param text: text for the tooltip. It can inslude \n
|
:param text: (str) text for the tooltip. It can inslude \n
|
||||||
:param timeout: (int) Time in milliseconds that mouse must remain still before tip is shown
|
:param timeout: (int) Time in milliseconds that mouse must remain still before tip is shown
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -867,7 +867,6 @@ class Combo(Element):
|
||||||
text_color=None, change_submits=False, enable_events=False, disabled=False, key=None, pad=None,
|
text_color=None, change_submits=False, enable_events=False, disabled=False, key=None, pad=None,
|
||||||
tooltip=None, readonly=False, font=None, visible=True):
|
tooltip=None, readonly=False, font=None, visible=True):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param values: List[Any] values to choose. While displayed as text, the items returned are what the caller supplied, not text
|
:param values: List[Any] values to choose. While displayed as text, the items returned are what the caller supplied, not text
|
||||||
:param default_value: (Any) Choice to be displayed as initial value. Must match one of values variable contents
|
:param default_value: (Any) Choice to be displayed as initial value. Must match one of values variable contents
|
||||||
:param size: (int, int) (width, height) width = characters-wide, height = rows-high
|
:param size: (int, int) (width, height) width = characters-wide, height = rows-high
|
||||||
|
@ -985,7 +984,6 @@ class OptionMenu(Element):
|
||||||
def __init__(self, values, default_value=None, size=(None, None), disabled=False, auto_size_text=None,
|
def __init__(self, values, default_value=None, size=(None, None), disabled=False, auto_size_text=None,
|
||||||
background_color=None, text_color=None, key=None, pad=None, tooltip=None, visible=True):
|
background_color=None, text_color=None, key=None, pad=None, tooltip=None, visible=True):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param values: List[Any] Values to be displayed
|
:param values: List[Any] Values to be displayed
|
||||||
:param default_value: (Any) the value to choose by default
|
:param default_value: (Any) the value to choose by default
|
||||||
:param size: Tuple[int, int] (width, height) size in characters (wide) and rows (high)
|
:param size: Tuple[int, int] (width, height) size in characters (wide) and rows (high)
|
||||||
|
@ -2024,7 +2022,7 @@ class Button(Element):
|
||||||
:param button_type: (int) You should NOT be setting this directly. ONLY the shortcut functions set this
|
:param button_type: (int) You should NOT be setting this directly. ONLY the shortcut functions set this
|
||||||
:param target: Union[str, Tuple[int, int]] key or (row,col) target for the button. Note that -1 for column means 1 element to the left of this one. The constant ThisRow is used to indicate the current row. The Button itself is a valid target for some types of button
|
:param target: Union[str, Tuple[int, int]] key or (row,col) target for the button. Note that -1 for column means 1 element to the left of this one. The constant ThisRow is used to indicate the current row. The Button itself is a valid target for some types of button
|
||||||
:param tooltip: (str) text, that will appear when mouse hovers over the element
|
:param tooltip: (str) text, that will appear when mouse hovers over the element
|
||||||
:param file_types: Tuple[Tuple[str, str], ...] the filetypes that will be used to match files. To indicate all files: (("ALL Files", "*.*"),)
|
:param file_types: Tuple[Tuple[str, str], ...] the filetypes that will be used to match files. To indicate all files: (("ALL Files", "*.*"),). Note - NOT SUPPORTED ON MAC
|
||||||
:param initial_folder: (str) starting path for folders and files
|
:param initial_folder: (str) starting path for folders and files
|
||||||
:param disabled: (bool) If True button will be created disabled
|
:param disabled: (bool) If True button will be created disabled
|
||||||
:param click_submits: (bool) DO NOT USE. Only listed for backwards compat - Use enable_events instead
|
:param click_submits: (bool) DO NOT USE. Only listed for backwards compat - Use enable_events instead
|
||||||
|
@ -2036,7 +2034,7 @@ class Button(Element):
|
||||||
:param border_width: (int) width of border around button in pixels
|
:param border_width: (int) width of border around button in pixels
|
||||||
:param size: Tuple[int, int] (width, height) of the button in characters wide, rows high
|
:param size: Tuple[int, int] (width, height) of the button in characters wide, rows high
|
||||||
:param auto_size_button: (bool) if True the button size is sized to fit the text
|
:param auto_size_button: (bool) if True the button size is sized to fit the text
|
||||||
:param button_color: Tuple[str, str] (text color, background color) of button. Easy to remember which is which if you say "ON" between colors. "red" on "green"
|
:param button_color: Tuple[str, str] (text color, background color) of button. Easy to remember which is which if you say "ON" between colors. "red" on "green". Note - Does not always work on Macs
|
||||||
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
||||||
:param bind_return_key: (bool) If True the return key will cause this button to be pressed
|
:param bind_return_key: (bool) If True the return key will cause this button to be pressed
|
||||||
:param focus: (bool) if True, initial focus will be put on this button
|
:param focus: (bool) if True, initial focus will be put on this button
|
||||||
|
@ -2357,8 +2355,8 @@ class ButtonMenu(Element):
|
||||||
size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None, key=None,
|
size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None, key=None,
|
||||||
tearoff=False, visible=True):
|
tearoff=False, visible=True):
|
||||||
"""
|
"""
|
||||||
:param button_text: Text to be displayed on the button (Default value = '')
|
:param button_text: (str) Text to be displayed on the button
|
||||||
:param menu_def: (list(list)) [ [ ] ] A list of lists of Menu items to show when this element is clicked. See docs for format
|
:param menu_def: List[List[str]] A list of lists of Menu items to show when this element is clicked. See docs for format as they are the same for all menu types
|
||||||
:param tooltip: (str) text, that will appear when mouse hovers over the element
|
:param tooltip: (str) text, that will appear when mouse hovers over the element
|
||||||
:param disabled: (bool) If True button will be created disabled
|
:param disabled: (bool) If True button will be created disabled
|
||||||
:param image_filename: (str) image filename if there is a button image. GIFs and PNGs only.
|
:param image_filename: (str) image filename if there is a button image. GIFs and PNGs only.
|
||||||
|
@ -3321,6 +3319,7 @@ VSep = VerticalSeparator
|
||||||
class Tab(Element):
|
class Tab(Element):
|
||||||
"""
|
"""
|
||||||
Tab Element is another "Container" element that holds a layout and displays a tab with text. Used with TabGroup only
|
Tab Element is another "Container" element that holds a layout and displays a tab with text. Used with TabGroup only
|
||||||
|
Tabs are never placed directly into a layout. They are always "Contained" in a TabGroup layout
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, title, layout, title_color=None, background_color=None, font=None, pad=None, disabled=False,
|
def __init__(self, title, layout, title_color=None, background_color=None, font=None, pad=None, disabled=False,
|
||||||
|
@ -3544,7 +3543,8 @@ class TabGroup(Element):
|
||||||
|
|
||||||
def SelectTab(self, index):
|
def SelectTab(self, index):
|
||||||
"""
|
"""
|
||||||
Create a tkinter event that mimics user clicking on a tab
|
Create a tkinter event that mimics user clicking on a tab. Must have called window.Finalize / Read first!
|
||||||
|
|
||||||
:param index: (int) indicates which Tab should be selected. Count starts at 0
|
:param index: (int) indicates which Tab should be selected. Count starts at 0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -3582,7 +3582,13 @@ class Slider(Element):
|
||||||
:param orientation: (str) 'horizontal' or 'vertical' ('h' or 'v' also work)
|
:param orientation: (str) 'horizontal' or 'vertical' ('h' or 'v' also work)
|
||||||
:param disable_number_display: (bool) if True no number will be displayed by the Slider Element
|
:param disable_number_display: (bool) if True no number will be displayed by the Slider Element
|
||||||
:param border_width: (int) width of border around element in pixels
|
:param border_width: (int) width of border around element in pixels
|
||||||
:param relief: (enum) relief style. `RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID`
|
:param relief: (enum) relief style.
|
||||||
|
RELIEF_RAISED
|
||||||
|
RELIEF_SUNKEN
|
||||||
|
RELIEF_FLAT
|
||||||
|
RELIEF_RIDGE
|
||||||
|
RELIEF_GROOVE
|
||||||
|
RELIEF_SOLID
|
||||||
:param change_submits: (bool) * DEPRICATED DO NOT USE! Same as enable_events
|
:param change_submits: (bool) * DEPRICATED DO NOT USE! Same as enable_events
|
||||||
:param enable_events: (bool) If True then moving the slider will generate an Event
|
:param enable_events: (bool) If True then moving the slider will generate an Event
|
||||||
:param disabled: (bool) set disable state for element
|
:param disabled: (bool) set disable state for element
|
||||||
|
@ -3596,7 +3602,7 @@ class Slider(Element):
|
||||||
:param visible: (bool) set visibility state of the element
|
:param visible: (bool) set visibility state of the element
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.TKScale = None # type: tk.Scale
|
self.TKScale = self.Widget = None # type: tk.Scale
|
||||||
self.Range = (1, 10) if range == (None, None) else range
|
self.Range = (1, 10) if range == (None, None) else range
|
||||||
self.DefaultValue = self.Range[0] if default_value is None else default_value
|
self.DefaultValue = self.Range[0] if default_value is None else default_value
|
||||||
self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION
|
self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION
|
||||||
|
@ -3941,7 +3947,13 @@ class Pane(Element):
|
||||||
:param pad: (int, int) or ((int, int),(int,int)) Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom))
|
:param pad: (int, int) or ((int, int),(int,int)) Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom))
|
||||||
:param orientation: (str) 'horizontal' or 'vertical' or ('h' or 'v'). Direction the Pane should slide
|
:param orientation: (str) 'horizontal' or 'vertical' or ('h' or 'v'). Direction the Pane should slide
|
||||||
:param show_handle: (bool) if True, the handle is drawn that makes it easier to grab and slide
|
:param show_handle: (bool) if True, the handle is drawn that makes it easier to grab and slide
|
||||||
:param relief: (enum) relief style. Values are same as other elements that use relief values. `RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID`
|
:param relief: (enum) relief style. Values are same as other elements that use relief values.
|
||||||
|
RELIEF_RAISED
|
||||||
|
RELIEF_SUNKEN
|
||||||
|
RELIEF_FLAT
|
||||||
|
RELIEF_RIDGE
|
||||||
|
RELIEF_GROOVE
|
||||||
|
RELIEF_SOLID
|
||||||
:param handle_size: (int) Size of the handle in pixels
|
:param handle_size: (int) Size of the handle in pixels
|
||||||
:param border_width: (int) width of border around element in pixels
|
:param border_width: (int) width of border around element in pixels
|
||||||
:param key: (any) Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
|
:param key: (any) Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
|
||||||
|
@ -4390,7 +4402,7 @@ class Table(Element):
|
||||||
:param size: Tuple[int, int] DO NOT USE! Use num_rows instead
|
:param size: Tuple[int, int] DO NOT USE! Use num_rows instead
|
||||||
:param change_submits: (bool) DO NOT USE. Only listed for backwards compat - Use enable_events instead
|
:param change_submits: (bool) DO NOT USE. Only listed for backwards compat - Use enable_events instead
|
||||||
:param enable_events: (bool) Turns on the element specific events. Table events happen when row is clicked
|
:param enable_events: (bool) Turns on the element specific events. Table events happen when row is clicked
|
||||||
:param bind_return_key: (bool) if True, pressing return key will cause event coming from Table
|
:param bind_return_key: (bool) if True, pressing return key will cause event coming from Table, ALSO a left button double click will generate an event if this parameter is True
|
||||||
:param pad: (int, int) or ((int, int),(int,int)) Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom))
|
:param pad: (int, int) or ((int, int),(int,int)) Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom))
|
||||||
:param key: (Any) Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element
|
:param key: (Any) Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element
|
||||||
:param tooltip: (str) text, that will appear when mouse hovers over the element
|
:param tooltip: (str) text, that will appear when mouse hovers over the element
|
||||||
|
@ -4517,13 +4529,12 @@ class Table(Element):
|
||||||
"""
|
"""
|
||||||
Not user callable. Callback function that is called when something is selected from Table.
|
Not user callable. Callback function that is called when something is selected from Table.
|
||||||
Stores the selected rows in Element as they are being selected. If events enabled, then returns from Read
|
Stores the selected rows in Element as they are being selected. If events enabled, then returns from Read
|
||||||
TODO: Why is BindReturnKey being checked??
|
|
||||||
|
|
||||||
:param event: (unknown) event information from tkinter
|
:param event: (unknown) event information from tkinter
|
||||||
"""
|
"""
|
||||||
selections = self.TKTreeview.selection()
|
selections = self.TKTreeview.selection()
|
||||||
self.SelectedRows = [int(x) - 1 for x in selections]
|
self.SelectedRows = [int(x) - 1 for x in selections]
|
||||||
if self.BindReturnKey: # shouldn't this be ChangeSubmits?
|
if self.BindReturnKey: # Signifies BOTH a return key AND a double click
|
||||||
if self.Key is not None:
|
if self.Key is not None:
|
||||||
self.ParentForm.LastButtonClicked = self.Key
|
self.ParentForm.LastButtonClicked = self.Key
|
||||||
else:
|
else:
|
||||||
|
@ -4703,25 +4714,30 @@ class Tree(Element):
|
||||||
|
|
||||||
|
|
||||||
class TreeData(object):
|
class TreeData(object):
|
||||||
""" """
|
"""
|
||||||
|
Class that user fills in to represent their tree data. It's a very simple tree representation with a root "Node"
|
||||||
|
with possibly one or more children "Nodes". Each Node contains a key, text to display, list of values to display
|
||||||
|
and an icon
|
||||||
|
"""
|
||||||
class Node(object):
|
class Node(object):
|
||||||
""" """
|
"""
|
||||||
|
Contains information about the individual node in the tree
|
||||||
|
"""
|
||||||
def __init__(self, parent, key, text, values, icon=None):
|
def __init__(self, parent, key, text, values, icon=None):
|
||||||
"""
|
"""
|
||||||
|
:param parent: (Node) The parent Node
|
||||||
:param parent:
|
:param key: (Any) Used to uniquely identify this node
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
:param text: (str) The text that is displayed at this node's location
|
||||||
:param text:
|
:param values: List[Any] The list of values that are displayed at this node
|
||||||
:param values:
|
:param icon: Union[str, bytes]
|
||||||
:param icon:
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.parent = parent
|
|
||||||
self.children = []
|
self.parent = parent # type: TreeData.Node
|
||||||
self.key = key
|
self.children = [] # type: List[TreeData.Node]
|
||||||
self.text = text
|
self.key = key # type: str
|
||||||
self.values = values
|
self.text = text # type: str
|
||||||
self.icon = icon
|
self.values = values # type: List[Any]
|
||||||
|
self.icon = icon # type: Union[str, bytes]
|
||||||
|
|
||||||
def _Add(self, node):
|
def _Add(self, node):
|
||||||
"""
|
"""
|
||||||
|
@ -4739,38 +4755,43 @@ class TreeData(object):
|
||||||
|
|
||||||
def _AddNode(self, key, node):
|
def _AddNode(self, key, node):
|
||||||
"""
|
"""
|
||||||
|
Adds a node to tree dictionary (not user callable)
|
||||||
|
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
:param key: (str) Uniquely identifies this Node
|
||||||
:param node:
|
:param node: (Node) Node being added
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.tree_dict[key] = node
|
self.tree_dict[key] = node
|
||||||
|
|
||||||
def Insert(self, parent, key, text, values, icon=None):
|
def Insert(self, parent, key, text, values, icon=None):
|
||||||
"""
|
"""
|
||||||
|
Inserts a node into the tree. This is how user builds their tree, by Inserting Nodes
|
||||||
|
|
||||||
:param parent:
|
:param parent: (Node) the parent Node
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
:param key: (Any) Used to uniquely identify this node
|
||||||
:param text:
|
:param text: (str) The text that is displayed at this node's location
|
||||||
:param values:
|
:param values: List[Any] The list of values that are displayed at this node
|
||||||
:param icon:
|
:param icon: Union[str, bytes]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
node = self.Node(parent, key, text, values, icon)
|
node = self.Node(parent, key, text, values, icon)
|
||||||
self.tree_dict[key] = node
|
self.tree_dict[key] = node
|
||||||
parent_node = self.tree_dict[parent]
|
parent_node = self.tree_dict[parent]
|
||||||
parent_node._Add(node)
|
parent_node._Add(node)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
""" """
|
"""
|
||||||
|
Converts the TreeData into a printable version, nicely formatted
|
||||||
|
|
||||||
|
:return: (str) A formatted, text version of the TreeData
|
||||||
|
"""
|
||||||
return self._NodeStr(self.root_node, 1)
|
return self._NodeStr(self.root_node, 1)
|
||||||
|
|
||||||
def _NodeStr(self, node, level):
|
def _NodeStr(self, node, level):
|
||||||
"""
|
"""
|
||||||
|
Does the magic of converting the TreeData into a nicely formatted string version
|
||||||
|
|
||||||
:param node:
|
:param node: (Node) The node to begin printing the tree
|
||||||
:param level:
|
:param level: (int) The indentation level for string formatting
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return '\n'.join(
|
return '\n'.join(
|
||||||
[str(node.key) + ' : ' + str(node.text)] +
|
[str(node.key) + ' : ' + str(node.text)] +
|
||||||
|
@ -4781,26 +4802,26 @@ class TreeData(object):
|
||||||
# Error Element #
|
# Error Element #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class ErrorElement(Element):
|
class ErrorElement(Element):
|
||||||
""" """
|
"""
|
||||||
|
A "dummy Element" that is returned when there are error conditions, like trying to find an element that's invalid
|
||||||
|
"""
|
||||||
def __init__(self, key=None):
|
def __init__(self, key=None):
|
||||||
"""Error Element
|
"""
|
||||||
|
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.Key = key
|
self.Key = key
|
||||||
|
|
||||||
super().__init__(ELEM_TYPE_ERROR, key=key)
|
super().__init__(ELEM_TYPE_ERROR, key=key)
|
||||||
return
|
|
||||||
|
|
||||||
def Update(self, silent_on_error=True, *args, **kwargs):
|
def Update(self, silent_on_error=True, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Update method for the Error Element, an element that should not be directly used by developer
|
Update method for the Error Element, an element that should not be directly used by developer
|
||||||
|
|
||||||
:param silent_on_error: (bool) if False, then a Popup window will be shown
|
:param silent_on_error: (bool) if False, then a Popup window will be shown
|
||||||
:param *args: (Any) meant to "soak up" any normal paramters passed in
|
:param *args: (Any) meant to "soak up" any normal parameters passed in
|
||||||
:param **kwargs: (Any) meant to "soak up" any keyword parameters that were passed in
|
:param **kwargs: (Any) meant to "soak up" any keyword parameters that were passed in
|
||||||
|
:return: (ErrorElement) returns 'self' so call can be chained
|
||||||
"""
|
"""
|
||||||
if not silent_on_error:
|
if not silent_on_error:
|
||||||
PopupError('Keyword error in Update',
|
PopupError('Keyword error in Update',
|
||||||
|
@ -4811,7 +4832,11 @@ class ErrorElement(Element):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def Get(self):
|
def Get(self):
|
||||||
""" """
|
"""
|
||||||
|
One of the method names found in other Elements. Used here to return an error string in case it's called
|
||||||
|
|
||||||
|
:return: (str) A warning text string.
|
||||||
|
"""
|
||||||
return 'This is NOT a valid Element!\nSTOP trying to do things with it or I will have to crash at some point!'
|
return 'This is NOT a valid Element!\nSTOP trying to do things with it or I will have to crash at some point!'
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
@ -4851,7 +4876,6 @@ class Window:
|
||||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=False, disable_close=False,
|
no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=False, disable_close=False,
|
||||||
disable_minimize=False, right_click_menu=None, transparent_color=None, debugger_enabled=True):
|
disable_minimize=False, right_click_menu=None, transparent_color=None, debugger_enabled=True):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param title: (str) The title that will be displayed in the Titlebar and on the Taskbar
|
:param title: (str) The title that will be displayed in the Titlebar and on the Taskbar
|
||||||
:param layout: List[List[Elements]] The layout for the window. Can also be specified in the Layout method
|
:param layout: List[List[Elements]] The layout for the window. Can also be specified in the Layout method
|
||||||
:param default_element_size: Tuple[int, int] (width, height) size in characters (wide) and rows (high) for all elements in this window
|
:param default_element_size: Tuple[int, int] (width, height) size in characters (wide) and rows (high) for all elements in this window
|
||||||
|
@ -9479,27 +9503,27 @@ def Popup(*args, title=None, button_color=None, background_color=None, text_colo
|
||||||
font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||||
"""
|
"""
|
||||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages
|
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||||
|
|
||||||
:param *args: Variable number of your arguments. Load up the call with stuff to see!
|
:param *args: (Any) Variable number of your arguments. Load up the call with stuff to see!
|
||||||
:param title: Optional title for the window
|
:param title: (str) Optional title for the window. If none provided, the first arg will be used instead.
|
||||||
:param button_color: Tuple(str, str) Color of the buttons shown (text color, button color)
|
:param button_color: Tuple[str, str] Color of the buttons shown (text color, button color)
|
||||||
:param background_color: (str) Window background color
|
:param background_color: (str) Window's background color
|
||||||
:param text_color: (str) text color
|
:param text_color: (str) text color
|
||||||
:param button_type: (enum) determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). The user normally will NOT change this value. There are many Popup functions and they call Popup, changing this parameter to get the desired effect.
|
:param button_type: (enum) NOT USER SET! Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). There are many Popup functions and they call Popup, changing this parameter to get the desired effect.
|
||||||
:param auto_close: (bool) If True the window will automatically close
|
:param auto_close: (bool) If True the window will automatically close
|
||||||
:param auto_close_duration: (int) time in seconds to keep window open before closing it automatically
|
:param auto_close_duration: (int) time in seconds to keep window open before closing it automatically
|
||||||
:param custom_text: Union[tuple(str, str), str] A string or pair of strings that contain the text to display on the buttons
|
:param custom_text: Union[Tuple[str, str], str] A string or pair of strings that contain the text to display on the buttons
|
||||||
:param non_blocking: (bool) If True then will immediately return from the function without waiting for the uder's input.
|
:param non_blocking: (bool) If True then will immediately return from the function without waiting for the user's input.
|
||||||
:param icon: Union[str, bytes] icon to display on the window. Same format was Window call
|
:param icon: Union[str, bytes] icon to display on the window. Same format as a Window call
|
||||||
:param line_width: (int) Width of lines in characters to use. Defaults to MESSAGE_BOX_LINE_WIDTH
|
:param line_width: (int) Width of lines in characters. Defaults to MESSAGE_BOX_LINE_WIDTH
|
||||||
:param font: Union[str, tuple(font, size, modifiors) specifies the font family, size, etc
|
:param font: Union[str, tuple(font name, size, modifiers) specifies the font family, size, etc
|
||||||
:param no_titlebar: (bool) If True will not show the frame around the window and the titlebar across the top
|
:param no_titlebar: (bool) If True will not show the frame around the window and the titlebar across the top
|
||||||
:param grab_anywhere: (bool) If True can grab anywhere to move the window. If no_titlebar is True, grab_anywhere should likely be enabled too
|
:param grab_anywhere: (bool) If True can grab anywhere to move the window. If no_titlebar is True, grab_anywhere should likely be enabled too
|
||||||
:param location: (int, int) Location on screen to display the top left corner of window. Defaults to centered on screen
|
:param location: Tuple[int, int] Location on screen to display the top left corner of window. Defaults to window centered on screen
|
||||||
:return: Union[str, None] Returns text of the button that was pressed. None will be returned if user closed window with X
|
:return: Union[str, None] Returns text of the button that was pressed. None will be returned if user closed window with X
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
args_to_print = ['']
|
args_to_print = ['']
|
||||||
else:
|
else:
|
||||||
|
@ -10034,24 +10058,24 @@ def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(
|
||||||
background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
|
background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
|
||||||
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_folder=None):
|
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_folder=None):
|
||||||
"""
|
"""
|
||||||
Display popup with text entry field and browse button. Browse for folder
|
Display popup with text entry field and browse button so that a folder can be chosen.
|
||||||
|
|
||||||
:param message:
|
:param message: (str) message displayed to user
|
||||||
:param title:
|
:param title: (str) Window title
|
||||||
:param default_path: (Default value = '')
|
:param default_path: (str) path to display to user as starting point (filled into the input field)
|
||||||
:param no_window: (Default = False)
|
:param no_window: (bool) if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown
|
||||||
:param size: (w,h) w=characters-wide, h=rows-high
|
:param size: Tuple[int, int] (width, height) of the InputText Element
|
||||||
:param button_color: button color (foreground, background)
|
:param button_color: Tuple[str, str] Color of the button (text, background)
|
||||||
:param background_color: color of background
|
:param background_color: (str) background color of the entire window
|
||||||
:param text_color: color of the text
|
:param text_color: (str) color of the message text
|
||||||
:param icon: Icon to display
|
:param icon: Union[bytes, str] filename or base64 string to be used for the window's icon
|
||||||
:param font: specifies the font family, size, etc
|
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
||||||
:param no_titlebar: (Default = False)
|
:param no_titlebar: (bool) If True no titlebar will be shown
|
||||||
:param grab_anywhere: If True can grab anywhere to move the window (Default = False)
|
:param grab_anywhere: (bool) If True can click and drag anywhere in the window to move the window
|
||||||
:param location: Location on screen to display
|
:param keep_on_top: (bool) If True the window will remain above all current windows
|
||||||
:param location: (Default = (None))
|
:param location: Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window
|
||||||
:param initial_folder:
|
:param initial_folder: (str) location in filesystem to begin browsing
|
||||||
:return: Union[str, None] Contents of text field. None if closed using X or cancelled
|
:return: Union[str, None] string representing the path chosen, None if cancelled or window closed with X
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# global _my_windows
|
# global _my_windows
|
||||||
|
@ -10109,28 +10133,28 @@ def PopupGetFile(message, title=None, default_path='', default_extension='', sav
|
||||||
icon=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
|
icon=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
|
||||||
location=(None, None), initial_folder=None):
|
location=(None, None), initial_folder=None):
|
||||||
"""
|
"""
|
||||||
Display popup with text entry field and browse button. Browse for file
|
Display popup window with text entry field and browse button so that a file can be chosen by user.
|
||||||
|
|
||||||
:param message:
|
:param message: (str) message displayed to user
|
||||||
:param title:
|
:param title: (str) Window title
|
||||||
:param default_path: (Default value = '')
|
:param default_path: (str) path to display to user as starting point (filled into the input field)
|
||||||
:param default_extension: (Default value = '')
|
:param default_extension: (str) If no extension entered by user, add this to filename (only used in saveas dialogs)
|
||||||
:param save_as: (Default = False)
|
:param save_as: (bool) if True, the "save as" dialog is shown which will verify before overwriting
|
||||||
:param multiple_files: (Default = False)
|
:param multiple_files: (bool) if True, then allows multiple files to be selected that are returned with ';' between each filename
|
||||||
:param file_types: (Default value = (("ALL Files", "*.*")))
|
:param file_types: Tuple[Tuple[str,str]] List of extensions to show using wildcards. All files (the default) = (("ALL Files", "*.*"),)
|
||||||
:param no_window: (Default = False)
|
:param no_window: (bool) if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown
|
||||||
:param size: (w,h) w=characters-wide, h=rows-high
|
:param size: Tuple[int, int] (width, height) of the InputText Element
|
||||||
:param button_color: button color (foreground, background)
|
:param button_color: Tuple[str, str] Color of the button (text, background)
|
||||||
:param background_color: color of background
|
:param background_color: (str) background color of the entire window
|
||||||
:param text_color: color of the text
|
:param text_color: (str) color of the message text
|
||||||
:param icon: Icon to display
|
:param icon: Union[bytes, str] filename or base64 string to be used for the window's icon
|
||||||
:param font: specifies the font family, size, etc
|
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
||||||
:param no_titlebar: (Default = False)
|
:param no_titlebar: (bool) If True no titlebar will be shown
|
||||||
:param grab_anywhere: If True can grab anywhere to move the window (Default = False)
|
:param grab_anywhere: (bool) If True can click and drag anywhere in the window to move the window
|
||||||
:param location: Location on screen to display
|
:param keep_on_top: (bool) If True the window will remain above all current windows
|
||||||
:param location: (Default = (None))
|
:param location: Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window
|
||||||
:param initial_folder:
|
:param initial_folder: (str) location in filesystem to begin browsing
|
||||||
:return: Union[str, None] string representing the path chosen, None if cancelled or window closed with X
|
:return: Union[str, None] string representing the file(s) chosen, None if cancelled or window closed with X
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if no_window:
|
if no_window:
|
||||||
|
@ -10201,23 +10225,23 @@ def PopupGetText(message, title=None, default_text='', password_char='', size=(N
|
||||||
background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
|
background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
|
||||||
grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||||
"""
|
"""
|
||||||
Display Popup with text entry field
|
Display Popup with text entry field. Returns the text entered or None if closed / cancelled
|
||||||
|
|
||||||
:param message:
|
:param message: (str) message displayed to user
|
||||||
:param title:
|
:param title: (str) Window title
|
||||||
:param default_text: (Default value = '')
|
:param default_text: (str) default value to put into input area
|
||||||
:param password_char: Passwork character if this is a password field (Default value = '')
|
:param password_char: (str) character to be shown instead of actually typed characters
|
||||||
:param size: (w,h) w=characters-wide, h=rows-high
|
:param size: Tuple[int, int] (width, height) of the InputText Element
|
||||||
:param button_color: button color (foreground, background)
|
:param button_color: Tuple[str, str] Color of the button (text, background)
|
||||||
:param background_color: color of background
|
:param background_color: (str) background color of the entire window
|
||||||
:param text_color: color of the text
|
:param text_color: (str) color of the message text
|
||||||
:param icon: Icon to display
|
:param icon: Union[bytes, str] filename or base64 string to be used for the window's icon
|
||||||
:param font: specifies the font family, size, etc
|
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
||||||
:param no_titlebar: (Default = False)
|
:param no_titlebar: (bool) If True no titlebar will be shown
|
||||||
:param grab_anywhere: If True can grab anywhere to move the window (Default = False)
|
:param grab_anywhere: (bool) If True can click and drag anywhere in the window to move the window
|
||||||
:param location: Location on screen to display
|
:param keep_on_top: (bool) If True the window will remain above all current windows
|
||||||
:param location: (Default = (None))
|
:param location: Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window
|
||||||
:return: Union[str, None] Text entered or None if window was closed
|
:return: Union[str, None] Text entered or None if window was closed or cancel button clicked
|
||||||
"""
|
"""
|
||||||
|
|
||||||
layout = [[Text(message, auto_size_text=True, text_color=text_color, background_color=background_color, font=font)],
|
layout = [[Text(message, auto_size_text=True, text_color=text_color, background_color=background_color, font=font)],
|
||||||
|
@ -10246,9 +10270,11 @@ def PopupAnimated(image_source, message=None, background_color=None, text_color=
|
||||||
"""
|
"""
|
||||||
"Plays" an animated GIF file. This function has its own internal clocking meaning you can call it at any frequency
|
"Plays" an animated GIF file. This function has its own internal clocking meaning you can call it at any frequency
|
||||||
and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
|
and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
|
||||||
event loop is running every 10 ms.
|
event loop is running every 10 ms. You don't have to worry about delaying, just call it every time through the
|
||||||
|
loop.
|
||||||
|
|
||||||
:param image_source: Union[str, bytes] Either a filename or a base64 string.
|
:param image_source: Union[str, bytes] Either a filename or a base64 string.
|
||||||
:param message: An optional message to be shown with the animation
|
:param message: (str) An optional message to be shown with the animation
|
||||||
:param background_color: (str) color of background
|
:param background_color: (str) color of background
|
||||||
:param text_color: (str) color of the text
|
:param text_color: (str) color of the text
|
||||||
:param font: Union[str, tuple) specifies the font family, size, etc
|
:param font: Union[str, tuple) specifies the font family, size, etc
|
||||||
|
@ -10256,9 +10282,9 @@ def PopupAnimated(image_source, message=None, background_color=None, text_color=
|
||||||
:param grab_anywhere: (bool) If True then you can move the window just clicking anywhere on window, hold and drag
|
:param grab_anywhere: (bool) If True then you can move the window just clicking anywhere on window, hold and drag
|
||||||
:param keep_on_top: (bool) If True then Window will remain on top of all other windows currently shownn
|
:param keep_on_top: (bool) If True then Window will remain on top of all other windows currently shownn
|
||||||
:param location: (int, int) (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
|
:param location: (int, int) (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
|
||||||
:param alpha_channel:
|
:param alpha_channel: (float) Window transparency 0 = invisible 1 = completely visible. Values between are see through
|
||||||
:param time_between_frames: (Default value = 0)
|
:param time_between_frames: (int) Amount of time in milliseconds between each frame
|
||||||
:param transparent_color:
|
:param transparent_color: (str) This color will be completely see-through in your window. Can even click through
|
||||||
"""
|
"""
|
||||||
if image_source is None:
|
if image_source is None:
|
||||||
for image in Window.animated_popup_dict:
|
for image in Window.animated_popup_dict:
|
||||||
|
|
140
docs/index.md
140
docs/index.md
|
@ -852,7 +852,7 @@ Preview of popups:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages
|
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||||
|
|
||||||
```
|
```
|
||||||
Popup(args,
|
Popup(args,
|
||||||
|
@ -878,22 +878,22 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|*args|Variable number of your arguments. Load up the call with stuff to see!|
|
|*args|(Any) Variable number of your arguments. Load up the call with stuff to see!|
|
||||||
|title|Optional title for the window|
|
|title|(str) Optional title for the window. If none provided, the first arg will be used instead.|
|
||||||
|button_color|Tuple(str, str) Color of the buttons shown (text color, button color)|
|
|button_color|Tuple[str, str] Color of the buttons shown (text color, button color)|
|
||||||
|background_color|(str) Window background color|
|
|background_color|(str) Window's background color|
|
||||||
|text_color|(str) text color|
|
|text_color|(str) text color|
|
||||||
|button_type|(enum) determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). The user normally will NOT change this value. There are many Popup functions and they call Popup, changing this parameter to get the desired effect.|
|
|button_type|(enum) NOT USER SET! Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). There are many Popup functions and they call Popup, changing this parameter to get the desired effect.|
|
||||||
|auto_close|(bool) If True the window will automatically close|
|
|auto_close|(bool) If True the window will automatically close|
|
||||||
|auto_close_duration|(int) time in seconds to keep window open before closing it automatically|
|
|auto_close_duration|(int) time in seconds to keep window open before closing it automatically|
|
||||||
|custom_text|Union[tuple(str, str), str] A string or pair of strings that contain the text to display on the buttons|
|
|custom_text|Union[Tuple[str, str], str] A string or pair of strings that contain the text to display on the buttons|
|
||||||
|non_blocking|(bool) If True then will immediately return from the function without waiting for the uder's input.|
|
|non_blocking|(bool) If True then will immediately return from the function without waiting for the user's input.|
|
||||||
|icon|Union[str, bytes] icon to display on the window. Same format was Window call|
|
|icon|Union[str, bytes] icon to display on the window. Same format as a Window call|
|
||||||
|line_width|(int) Width of lines in characters to use. Defaults to MESSAGE_BOX_LINE_WIDTH|
|
|line_width|(int) Width of lines in characters. Defaults to MESSAGE_BOX_LINE_WIDTH|
|
||||||
|font|Union[str, tuple(font, size, modifiors) specifies the font family, size, etc|
|
|font|Union[str, tuple(font name, size, modifiers) specifies the font family, size, etc|
|
||||||
|no_titlebar|(bool) If True will not show the frame around the window and the titlebar across the top|
|
|no_titlebar|(bool) If True will not show the frame around the window and the titlebar across the top|
|
||||||
|grab_anywhere|(bool) If True can grab anywhere to move the window. If no_titlebar is True, grab_anywhere should likely be enabled too|
|
|grab_anywhere|(bool) If True can grab anywhere to move the window. If no_titlebar is True, grab_anywhere should likely be enabled too|
|
||||||
|location|(int, int) Location on screen to display the top left corner of window. Defaults to centered on screen|
|
|location|Tuple[int, int] Location on screen to display the top left corner of window. Defaults to window centered on screen|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] Returns text of the button that was pressed. None will be returned if user closed window with X |
|
| **return** | Union[str, None] Returns text of the button that was pressed. None will be returned if user closed window with X |
|
||||||
|
|
||||||
|
@ -1025,7 +1025,7 @@ Use these Popups instead of making a custom window to get one data value, call
|
||||||
### PopupGetText
|
### PopupGetText
|
||||||
Use this Popup to get a line of text from the user.
|
Use this Popup to get a line of text from the user.
|
||||||
|
|
||||||
Display Popup with text entry field
|
Display Popup with text entry field. Returns the text entered or None if closed / cancelled
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupGetText(message,
|
PopupGetText(message,
|
||||||
|
@ -1048,21 +1048,22 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|message||
|
|message|(str) message displayed to user|
|
||||||
|title||
|
|title|(str) Window title|
|
||||||
|default_text|(Default value = '')|
|
|default_text|(str) default value to put into input area|
|
||||||
|password_char|Passwork character if this is a password field (Default value = '')|
|
|password_char|(str) character to be shown instead of actually typed characters|
|
||||||
|size|(w,h) w=characters-wide, h=rows-high|
|
|size|Tuple[int, int] (width, height) of the InputText Element|
|
||||||
|button_color|button color (foreground, background)|
|
|button_color|Tuple[str, str] Color of the button (text, background)|
|
||||||
|background_color|color of background|
|
|background_color|(str) background color of the entire window|
|
||||||
|text_color|color of the text|
|
|text_color|(str) color of the message text|
|
||||||
|icon|Icon to display|
|
|icon|Union[bytes, str] filename or base64 string to be used for the window's icon|
|
||||||
|font|specifies the font family, size, etc|
|
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||||
|no_titlebar|(Default = False)|
|
|no_titlebar|(bool) If True no titlebar will be shown|
|
||||||
|grab_anywhere|If True can grab anywhere to move the window (Default = False)|
|
|grab_anywhere|(bool) If True can click and drag anywhere in the window to move the window|
|
||||||
|location|(Default = (None))|
|
|keep_on_top|(bool) If True the window will remain above all current windows|
|
||||||
|
|location|Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] Text entered or None if window was closed |
|
| **return** | Union[str, None] Text entered or None if window was closed or cancel button clicked |
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
@ -1077,7 +1078,7 @@ sg.Popup('Results', 'The value returned from PopupGetText', text)
|
||||||
### PopupGetFile
|
### PopupGetFile
|
||||||
Gets a filename from the user. There are options to configure the type of dialog box to show. Normally an "Open File" dialog box is shown.
|
Gets a filename from the user. There are options to configure the type of dialog box to show. Normally an "Open File" dialog box is shown.
|
||||||
|
|
||||||
Display popup with text entry field and browse button. Browse for file
|
Display popup window with text entry field and browse button so that a file can be chosen by user.
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupGetFile(message,
|
PopupGetFile(message,
|
||||||
|
@ -1105,26 +1106,27 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|message||
|
|message|(str) message displayed to user|
|
||||||
|title||
|
|title|(str) Window title|
|
||||||
|default_path|(Default value = '')|
|
|default_path|(str) path to display to user as starting point (filled into the input field)|
|
||||||
|default_extension|(Default value = '')|
|
|default_extension|(str) If no extension entered by user, add this to filename (only used in saveas dialogs)|
|
||||||
|save_as|(Default = False)|
|
|save_as|(bool) if True, the "save as" dialog is shown which will verify before overwriting|
|
||||||
|multiple_files|(Default = False)|
|
|multiple_files|(bool) if True, then allows multiple files to be selected that are returned with ';' between each filename|
|
||||||
|file_types|(Default value = (("ALL Files", "*.*")))|
|
|file_types|Tuple[Tuple[str,str]] List of extensions to show using wildcards. All files (the default) = (("ALL Files", "*.*"),)|
|
||||||
|no_window|(Default = False)|
|
|no_window|(bool) if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown|
|
||||||
|size|(w,h) w=characters-wide, h=rows-high|
|
|size|Tuple[int, int] (width, height) of the InputText Element|
|
||||||
|button_color|button color (foreground, background)|
|
|button_color|Tuple[str, str] Color of the button (text, background)|
|
||||||
|background_color|color of background|
|
|background_color|(str) background color of the entire window|
|
||||||
|text_color|color of the text|
|
|text_color|(str) color of the message text|
|
||||||
|icon|Icon to display|
|
|icon|Union[bytes, str] filename or base64 string to be used for the window's icon|
|
||||||
|font|specifies the font family, size, etc|
|
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||||
|no_titlebar|(Default = False)|
|
|no_titlebar|(bool) If True no titlebar will be shown|
|
||||||
|grab_anywhere|If True can grab anywhere to move the window (Default = False)|
|
|grab_anywhere|(bool) If True can click and drag anywhere in the window to move the window|
|
||||||
|location|(Default = (None))|
|
|keep_on_top|(bool) If True the window will remain above all current windows|
|
||||||
|initial_folder||
|
|location|Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window|
|
||||||
|
|initial_folder|(str) location in filesystem to begin browsing|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] string representing the path chosen, None if cancelled or window closed with X |
|
| **return** | Union[str, None] string representing the file(s) chosen, None if cancelled or window closed with X |
|
||||||
|
|
||||||
If configured as an Open File Popup then (save_as is not True) the dialog box will look like this.
|
If configured as an Open File Popup then (save_as is not True) the dialog box will look like this.
|
||||||
|
|
||||||
|
@ -1149,7 +1151,7 @@ sg.Popup('Results', 'The value returned from PopupGetFile', text)
|
||||||
|
|
||||||
The window created to get a folder name looks the same as the get a file name. The difference is in what the browse button does. `PopupGetFile` shows an Open File dialog box while `PopupGetFolder` shows an Open Folder dialog box.
|
The window created to get a folder name looks the same as the get a file name. The difference is in what the browse button does. `PopupGetFile` shows an Open File dialog box while `PopupGetFolder` shows an Open Folder dialog box.
|
||||||
|
|
||||||
Display popup with text entry field and browse button. Browse for folder
|
Display popup with text entry field and browse button so that a folder can be chosen.
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupGetFolder(message,
|
PopupGetFolder(message,
|
||||||
|
@ -1173,22 +1175,23 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|message||
|
|message|(str) message displayed to user|
|
||||||
|title||
|
|title|(str) Window title|
|
||||||
|default_path|(Default value = '')|
|
|default_path|(str) path to display to user as starting point (filled into the input field)|
|
||||||
|no_window|(Default = False)|
|
|no_window|(bool) if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown|
|
||||||
|size|(w,h) w=characters-wide, h=rows-high|
|
|size|Tuple[int, int] (width, height) of the InputText Element|
|
||||||
|button_color|button color (foreground, background)|
|
|button_color|Tuple[str, str] Color of the button (text, background)|
|
||||||
|background_color|color of background|
|
|background_color|(str) background color of the entire window|
|
||||||
|text_color|color of the text|
|
|text_color|(str) color of the message text|
|
||||||
|icon|Icon to display|
|
|icon|Union[bytes, str] filename or base64 string to be used for the window's icon|
|
||||||
|font|specifies the font family, size, etc|
|
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||||
|no_titlebar|(Default = False)|
|
|no_titlebar|(bool) If True no titlebar will be shown|
|
||||||
|grab_anywhere|If True can grab anywhere to move the window (Default = False)|
|
|grab_anywhere|(bool) If True can click and drag anywhere in the window to move the window|
|
||||||
|location|(Default = (None))|
|
|keep_on_top|(bool) If True the window will remain above all current windows|
|
||||||
|initial_folder||
|
|location|Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window|
|
||||||
|
|initial_folder|(str) location in filesystem to begin browsing|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] Contents of text field. None if closed using X or cancelled |
|
| **return** | Union[str, None] string representing the path chosen, None if cancelled or window closed with X |
|
||||||
|
|
||||||
This is a typpical call
|
This is a typpical call
|
||||||
|
|
||||||
|
@ -1207,7 +1210,8 @@ The animated Popup enables you to easily display a "loading" style animation spe
|
||||||
|
|
||||||
"Plays" an animated GIF file. This function has its own internal clocking meaning you can call it at any frequency
|
"Plays" an animated GIF file. This function has its own internal clocking meaning you can call it at any frequency
|
||||||
and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
|
and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
|
||||||
event loop is running every 10 ms.
|
event loop is running every 10 ms. You don't have to worry about delaying, just call it every time through the
|
||||||
|
loop.
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupAnimated(image_source,
|
PopupAnimated(image_source,
|
||||||
|
@ -1229,7 +1233,7 @@ Parameter Descriptions:
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|image_source|Union[str, bytes] Either a filename or a base64 string.|
|
|image_source|Union[str, bytes] Either a filename or a base64 string.|
|
||||||
|message|An optional message to be shown with the animation|
|
|message|(str) An optional message to be shown with the animation|
|
||||||
|background_color|(str) color of background|
|
|background_color|(str) color of background|
|
||||||
|text_color|(str) color of the text|
|
|text_color|(str) color of the text|
|
||||||
|font|Union[str, tuple) specifies the font family, size, etc|
|
|font|Union[str, tuple) specifies the font family, size, etc|
|
||||||
|
@ -1237,9 +1241,9 @@ Parameter Descriptions:
|
||||||
|grab_anywhere|(bool) If True then you can move the window just clicking anywhere on window, hold and drag|
|
|grab_anywhere|(bool) If True then you can move the window just clicking anywhere on window, hold and drag|
|
||||||
|keep_on_top|(bool) If True then Window will remain on top of all other windows currently shownn|
|
|keep_on_top|(bool) If True then Window will remain on top of all other windows currently shownn|
|
||||||
|location|(int, int) (x,y) location on the screen to place the top left corner of your window. Default is to center on screen|
|
|location|(int, int) (x,y) location on the screen to place the top left corner of your window. Default is to center on screen|
|
||||||
|alpha_channel||
|
|alpha_channel|(float) Window transparency 0 = invisible 1 = completely visible. Values between are see through|
|
||||||
|time_between_frames|(Default value = 0)|
|
|time_between_frames|(int) Amount of time in milliseconds between each frame|
|
||||||
|transparent_color||
|
|transparent_color|(str) This color will be completely see-through in your window. Can even click through|
|
||||||
|
|
||||||
***To close animated popups***, call PopupAnimated with `image_source=None`. This will close all of the currently open PopupAnimated windows.
|
***To close animated popups***, call PopupAnimated with `image_source=None`. This will close all of the currently open PopupAnimated windows.
|
||||||
|
|
||||||
|
|
140
readme.md
140
readme.md
|
@ -852,7 +852,7 @@ Preview of popups:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages
|
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||||
|
|
||||||
```
|
```
|
||||||
Popup(args,
|
Popup(args,
|
||||||
|
@ -878,22 +878,22 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|*args|Variable number of your arguments. Load up the call with stuff to see!|
|
|*args|(Any) Variable number of your arguments. Load up the call with stuff to see!|
|
||||||
|title|Optional title for the window|
|
|title|(str) Optional title for the window. If none provided, the first arg will be used instead.|
|
||||||
|button_color|Tuple(str, str) Color of the buttons shown (text color, button color)|
|
|button_color|Tuple[str, str] Color of the buttons shown (text color, button color)|
|
||||||
|background_color|(str) Window background color|
|
|background_color|(str) Window's background color|
|
||||||
|text_color|(str) text color|
|
|text_color|(str) text color|
|
||||||
|button_type|(enum) determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). The user normally will NOT change this value. There are many Popup functions and they call Popup, changing this parameter to get the desired effect.|
|
|button_type|(enum) NOT USER SET! Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). There are many Popup functions and they call Popup, changing this parameter to get the desired effect.|
|
||||||
|auto_close|(bool) If True the window will automatically close|
|
|auto_close|(bool) If True the window will automatically close|
|
||||||
|auto_close_duration|(int) time in seconds to keep window open before closing it automatically|
|
|auto_close_duration|(int) time in seconds to keep window open before closing it automatically|
|
||||||
|custom_text|Union[tuple(str, str), str] A string or pair of strings that contain the text to display on the buttons|
|
|custom_text|Union[Tuple[str, str], str] A string or pair of strings that contain the text to display on the buttons|
|
||||||
|non_blocking|(bool) If True then will immediately return from the function without waiting for the uder's input.|
|
|non_blocking|(bool) If True then will immediately return from the function without waiting for the user's input.|
|
||||||
|icon|Union[str, bytes] icon to display on the window. Same format was Window call|
|
|icon|Union[str, bytes] icon to display on the window. Same format as a Window call|
|
||||||
|line_width|(int) Width of lines in characters to use. Defaults to MESSAGE_BOX_LINE_WIDTH|
|
|line_width|(int) Width of lines in characters. Defaults to MESSAGE_BOX_LINE_WIDTH|
|
||||||
|font|Union[str, tuple(font, size, modifiors) specifies the font family, size, etc|
|
|font|Union[str, tuple(font name, size, modifiers) specifies the font family, size, etc|
|
||||||
|no_titlebar|(bool) If True will not show the frame around the window and the titlebar across the top|
|
|no_titlebar|(bool) If True will not show the frame around the window and the titlebar across the top|
|
||||||
|grab_anywhere|(bool) If True can grab anywhere to move the window. If no_titlebar is True, grab_anywhere should likely be enabled too|
|
|grab_anywhere|(bool) If True can grab anywhere to move the window. If no_titlebar is True, grab_anywhere should likely be enabled too|
|
||||||
|location|(int, int) Location on screen to display the top left corner of window. Defaults to centered on screen|
|
|location|Tuple[int, int] Location on screen to display the top left corner of window. Defaults to window centered on screen|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] Returns text of the button that was pressed. None will be returned if user closed window with X |
|
| **return** | Union[str, None] Returns text of the button that was pressed. None will be returned if user closed window with X |
|
||||||
|
|
||||||
|
@ -1025,7 +1025,7 @@ Use these Popups instead of making a custom window to get one data value, call
|
||||||
### PopupGetText
|
### PopupGetText
|
||||||
Use this Popup to get a line of text from the user.
|
Use this Popup to get a line of text from the user.
|
||||||
|
|
||||||
Display Popup with text entry field
|
Display Popup with text entry field. Returns the text entered or None if closed / cancelled
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupGetText(message,
|
PopupGetText(message,
|
||||||
|
@ -1048,21 +1048,22 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|message||
|
|message|(str) message displayed to user|
|
||||||
|title||
|
|title|(str) Window title|
|
||||||
|default_text|(Default value = '')|
|
|default_text|(str) default value to put into input area|
|
||||||
|password_char|Passwork character if this is a password field (Default value = '')|
|
|password_char|(str) character to be shown instead of actually typed characters|
|
||||||
|size|(w,h) w=characters-wide, h=rows-high|
|
|size|Tuple[int, int] (width, height) of the InputText Element|
|
||||||
|button_color|button color (foreground, background)|
|
|button_color|Tuple[str, str] Color of the button (text, background)|
|
||||||
|background_color|color of background|
|
|background_color|(str) background color of the entire window|
|
||||||
|text_color|color of the text|
|
|text_color|(str) color of the message text|
|
||||||
|icon|Icon to display|
|
|icon|Union[bytes, str] filename or base64 string to be used for the window's icon|
|
||||||
|font|specifies the font family, size, etc|
|
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||||
|no_titlebar|(Default = False)|
|
|no_titlebar|(bool) If True no titlebar will be shown|
|
||||||
|grab_anywhere|If True can grab anywhere to move the window (Default = False)|
|
|grab_anywhere|(bool) If True can click and drag anywhere in the window to move the window|
|
||||||
|location|(Default = (None))|
|
|keep_on_top|(bool) If True the window will remain above all current windows|
|
||||||
|
|location|Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] Text entered or None if window was closed |
|
| **return** | Union[str, None] Text entered or None if window was closed or cancel button clicked |
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
@ -1077,7 +1078,7 @@ sg.Popup('Results', 'The value returned from PopupGetText', text)
|
||||||
### PopupGetFile
|
### PopupGetFile
|
||||||
Gets a filename from the user. There are options to configure the type of dialog box to show. Normally an "Open File" dialog box is shown.
|
Gets a filename from the user. There are options to configure the type of dialog box to show. Normally an "Open File" dialog box is shown.
|
||||||
|
|
||||||
Display popup with text entry field and browse button. Browse for file
|
Display popup window with text entry field and browse button so that a file can be chosen by user.
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupGetFile(message,
|
PopupGetFile(message,
|
||||||
|
@ -1105,26 +1106,27 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|message||
|
|message|(str) message displayed to user|
|
||||||
|title||
|
|title|(str) Window title|
|
||||||
|default_path|(Default value = '')|
|
|default_path|(str) path to display to user as starting point (filled into the input field)|
|
||||||
|default_extension|(Default value = '')|
|
|default_extension|(str) If no extension entered by user, add this to filename (only used in saveas dialogs)|
|
||||||
|save_as|(Default = False)|
|
|save_as|(bool) if True, the "save as" dialog is shown which will verify before overwriting|
|
||||||
|multiple_files|(Default = False)|
|
|multiple_files|(bool) if True, then allows multiple files to be selected that are returned with ';' between each filename|
|
||||||
|file_types|(Default value = (("ALL Files", "*.*")))|
|
|file_types|Tuple[Tuple[str,str]] List of extensions to show using wildcards. All files (the default) = (("ALL Files", "*.*"),)|
|
||||||
|no_window|(Default = False)|
|
|no_window|(bool) if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown|
|
||||||
|size|(w,h) w=characters-wide, h=rows-high|
|
|size|Tuple[int, int] (width, height) of the InputText Element|
|
||||||
|button_color|button color (foreground, background)|
|
|button_color|Tuple[str, str] Color of the button (text, background)|
|
||||||
|background_color|color of background|
|
|background_color|(str) background color of the entire window|
|
||||||
|text_color|color of the text|
|
|text_color|(str) color of the message text|
|
||||||
|icon|Icon to display|
|
|icon|Union[bytes, str] filename or base64 string to be used for the window's icon|
|
||||||
|font|specifies the font family, size, etc|
|
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||||
|no_titlebar|(Default = False)|
|
|no_titlebar|(bool) If True no titlebar will be shown|
|
||||||
|grab_anywhere|If True can grab anywhere to move the window (Default = False)|
|
|grab_anywhere|(bool) If True can click and drag anywhere in the window to move the window|
|
||||||
|location|(Default = (None))|
|
|keep_on_top|(bool) If True the window will remain above all current windows|
|
||||||
|initial_folder||
|
|location|Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window|
|
||||||
|
|initial_folder|(str) location in filesystem to begin browsing|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] string representing the path chosen, None if cancelled or window closed with X |
|
| **return** | Union[str, None] string representing the file(s) chosen, None if cancelled or window closed with X |
|
||||||
|
|
||||||
If configured as an Open File Popup then (save_as is not True) the dialog box will look like this.
|
If configured as an Open File Popup then (save_as is not True) the dialog box will look like this.
|
||||||
|
|
||||||
|
@ -1149,7 +1151,7 @@ sg.Popup('Results', 'The value returned from PopupGetFile', text)
|
||||||
|
|
||||||
The window created to get a folder name looks the same as the get a file name. The difference is in what the browse button does. `PopupGetFile` shows an Open File dialog box while `PopupGetFolder` shows an Open Folder dialog box.
|
The window created to get a folder name looks the same as the get a file name. The difference is in what the browse button does. `PopupGetFile` shows an Open File dialog box while `PopupGetFolder` shows an Open Folder dialog box.
|
||||||
|
|
||||||
Display popup with text entry field and browse button. Browse for folder
|
Display popup with text entry field and browse button so that a folder can be chosen.
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupGetFolder(message,
|
PopupGetFolder(message,
|
||||||
|
@ -1173,22 +1175,23 @@ Parameter Descriptions:
|
||||||
|
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|message||
|
|message|(str) message displayed to user|
|
||||||
|title||
|
|title|(str) Window title|
|
||||||
|default_path|(Default value = '')|
|
|default_path|(str) path to display to user as starting point (filled into the input field)|
|
||||||
|no_window|(Default = False)|
|
|no_window|(bool) if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown|
|
||||||
|size|(w,h) w=characters-wide, h=rows-high|
|
|size|Tuple[int, int] (width, height) of the InputText Element|
|
||||||
|button_color|button color (foreground, background)|
|
|button_color|Tuple[str, str] Color of the button (text, background)|
|
||||||
|background_color|color of background|
|
|background_color|(str) background color of the entire window|
|
||||||
|text_color|color of the text|
|
|text_color|(str) color of the message text|
|
||||||
|icon|Icon to display|
|
|icon|Union[bytes, str] filename or base64 string to be used for the window's icon|
|
||||||
|font|specifies the font family, size, etc|
|
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||||
|no_titlebar|(Default = False)|
|
|no_titlebar|(bool) If True no titlebar will be shown|
|
||||||
|grab_anywhere|If True can grab anywhere to move the window (Default = False)|
|
|grab_anywhere|(bool) If True can click and drag anywhere in the window to move the window|
|
||||||
|location|(Default = (None))|
|
|keep_on_top|(bool) If True the window will remain above all current windows|
|
||||||
|initial_folder||
|
|location|Tuyple[int, int] (x,y) Location on screen to display the upper left corner of window|
|
||||||
|
|initial_folder|(str) location in filesystem to begin browsing|
|
||||||
|||
|
|||
|
||||||
| **return** | Union[str, None] Contents of text field. None if closed using X or cancelled |
|
| **return** | Union[str, None] string representing the path chosen, None if cancelled or window closed with X |
|
||||||
|
|
||||||
This is a typpical call
|
This is a typpical call
|
||||||
|
|
||||||
|
@ -1207,7 +1210,8 @@ The animated Popup enables you to easily display a "loading" style animation spe
|
||||||
|
|
||||||
"Plays" an animated GIF file. This function has its own internal clocking meaning you can call it at any frequency
|
"Plays" an animated GIF file. This function has its own internal clocking meaning you can call it at any frequency
|
||||||
and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
|
and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
|
||||||
event loop is running every 10 ms.
|
event loop is running every 10 ms. You don't have to worry about delaying, just call it every time through the
|
||||||
|
loop.
|
||||||
|
|
||||||
```
|
```
|
||||||
PopupAnimated(image_source,
|
PopupAnimated(image_source,
|
||||||
|
@ -1229,7 +1233,7 @@ Parameter Descriptions:
|
||||||
|Name|Meaning|
|
|Name|Meaning|
|
||||||
|---|---|
|
|---|---|
|
||||||
|image_source|Union[str, bytes] Either a filename or a base64 string.|
|
|image_source|Union[str, bytes] Either a filename or a base64 string.|
|
||||||
|message|An optional message to be shown with the animation|
|
|message|(str) An optional message to be shown with the animation|
|
||||||
|background_color|(str) color of background|
|
|background_color|(str) color of background|
|
||||||
|text_color|(str) color of the text|
|
|text_color|(str) color of the text|
|
||||||
|font|Union[str, tuple) specifies the font family, size, etc|
|
|font|Union[str, tuple) specifies the font family, size, etc|
|
||||||
|
@ -1237,9 +1241,9 @@ Parameter Descriptions:
|
||||||
|grab_anywhere|(bool) If True then you can move the window just clicking anywhere on window, hold and drag|
|
|grab_anywhere|(bool) If True then you can move the window just clicking anywhere on window, hold and drag|
|
||||||
|keep_on_top|(bool) If True then Window will remain on top of all other windows currently shownn|
|
|keep_on_top|(bool) If True then Window will remain on top of all other windows currently shownn|
|
||||||
|location|(int, int) (x,y) location on the screen to place the top left corner of your window. Default is to center on screen|
|
|location|(int, int) (x,y) location on the screen to place the top left corner of your window. Default is to center on screen|
|
||||||
|alpha_channel||
|
|alpha_channel|(float) Window transparency 0 = invisible 1 = completely visible. Values between are see through|
|
||||||
|time_between_frames|(Default value = 0)|
|
|time_between_frames|(int) Amount of time in milliseconds between each frame|
|
||||||
|transparent_color||
|
|transparent_color|(str) This color will be completely see-through in your window. Can even click through|
|
||||||
|
|
||||||
***To close animated popups***, call PopupAnimated with `image_source=None`. This will close all of the currently open PopupAnimated windows.
|
***To close animated popups***, call PopupAnimated with `image_source=None`. This will close all of the currently open PopupAnimated windows.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue