From d48089972125ee3e3180a5080ab64059a87d0135 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Mon, 23 Mar 2020 23:17:04 -0400 Subject: [PATCH] More docstring fixes. no_titlebar parameter for one_line_progress_meter, renamed demo file --- ...ar_Chart2.py => Demo_Pyplot_Bar_Chart2.py} | 0 PySimpleGUI.py | 200 +++++++++++------- 2 files changed, 124 insertions(+), 76 deletions(-) rename DemoPrograms/{Demo_Pyploy_Bar_Chart2.py => Demo_Pyplot_Bar_Chart2.py} (100%) diff --git a/DemoPrograms/Demo_Pyploy_Bar_Chart2.py b/DemoPrograms/Demo_Pyplot_Bar_Chart2.py similarity index 100% rename from DemoPrograms/Demo_Pyploy_Bar_Chart2.py rename to DemoPrograms/Demo_Pyplot_Bar_Chart2.py diff --git a/PySimpleGUI.py b/PySimpleGUI.py index ab7f3fdb..2aa490d7 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -222,7 +222,8 @@ def _timeit_summary(func): Code I write now, outside PySimpleGUI, IS PEP8 compliant. The variable and function naming in particular are not compliant. There is - liberal use of CamelVariableAndFunctionNames. If you've got a serious enough problem with this + liberal use of CamelVariableAndFunctionNames, but for anything externally facing, there are aliases + available for all functions. If you've got a serious enough problem with 100% PEP8 compliance that you'll pass on this package, then that's your right and I invite you to do so. However, if perhaps you're a practical thinker where it's the results that matter, then you'll have no trouble with this code base. There is consisency however. @@ -596,7 +597,7 @@ class Element(): :param key: Identifies an Element. Should be UNIQUE to this window. :type key: (Any) :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: text, that will appear when mouse hovers over the element :type tooltip: (str) :param visible: set visibility state of the element (Default = True) @@ -1052,7 +1053,7 @@ class InputText(Element): :param focus: Determines if initial focus should go to this element. :type focus: (bool) :param pad: . Amount of padding to put around element. Normally (horizontal pixels, vertical pixels) but can be split apart further into ((horizontal left, horizontal right), (vertical above, vertical below)) - :type pad: (int, int) or ((int, int), (int, int)) Tuple(s) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param use_readonly_for_disable: If True (the default) tkinter state set to 'readonly'. Otherwise state set to 'disabled' :type use_readonly_for_disable: (bool) :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. @@ -1182,7 +1183,7 @@ class Combo(Element): :para key: Used with window.FindElement and with return values to uniquely identify this element :type key: (Any) :param: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :para tooltip: text that will appear when mouse hovers over this element :type tooltip: (str) :par readonly: make element readonly (user can't change). True means user cannot change @@ -1331,7 +1332,7 @@ class OptionMenu(Element): :param key: Used with window.FindElement and with return values to uniquely identify this element :type key: (Any) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: (str) text that will appear when mouse hovers over this element :type tooltip: (str) :param visible: (bool) set visibility state of the element @@ -1441,7 +1442,7 @@ class Listbox(Element): :param key: Used with window.FindElement and with return values to uniquely identify this element :type key: (Any) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: text, that will appear when mouse hovers over the element :type tooltip: (str) :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. @@ -1636,7 +1637,7 @@ class Radio(Element): :param key: Used with window.FindElement and with return values to uniquely identify this element :type key: (Any) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: text, that will appear when mouse hovers over the element :type tooltip: (str) :param change_submits: DO NOT USE. Only listed for backwards compat - Use enable_events instead @@ -1766,7 +1767,7 @@ class Checkbox(Element): :param key: Used with window.FindElement and with return values to uniquely identify this element :type key: (Any) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: text, that will appear when mouse hovers over the element :type tooltip: (str) :param visible: set visibility state of the element @@ -1917,7 +1918,7 @@ class Spin(Element): :param key: Used with window.FindElement and with return values to uniquely identify this element :type key: (Any) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: text, that will appear when mouse hovers over the element :type tooltip: (str) :param visible: set visibility state of the element @@ -2054,7 +2055,7 @@ class Multiline(Element): :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: text, that will appear when mouse hovers over the element :type tooltip: (str) :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. @@ -2224,7 +2225,7 @@ class Text(Element): :param justification: how string should be aligned within space provided by size. Valid choices = `left`, `right`, `center` :type justification: (str) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. @@ -2329,7 +2330,7 @@ class StatusBar(Element): :param justification: how string should be aligned within space provided by size. Valid choices = `left`, `right`, `center` :type justification: (str) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param tooltip: text, that will appear when mouse hovers over the element @@ -2511,7 +2512,7 @@ class TKOutput(tk.Frame): :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) """ self.frame = tk.Frame(parent) tk.Frame.__init__(self, self.frame) @@ -2587,7 +2588,7 @@ class Output(Element): :param text_color: color of the text :type text_color: (str) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param tooltip: text, that will appear when mouse hovers over the element @@ -2612,6 +2613,12 @@ class Output(Element): @property def TKOut(self): + """ + Returns the TKOutput object used to create the element + + :return: The TKOutput object + :rtype: (TKOutput) + """ if self._TKOut is None: print('*** Did you forget to call Finalize()? Your code should look something like: ***') print('*** form = sg.Window("My Form").Layout(layout).Finalize() ***') @@ -2645,7 +2652,7 @@ class Output(Element): """ return self._TKOut.output.get(1.0, tk.END) - def expand(self, expand_x=False, expand_y=False): + def expand(self, expand_x=False, expand_y=False, expand_row=True): """ Causes the Element to expand to fill available space in the X and Y directions. Can specify which or both directions @@ -2666,7 +2673,7 @@ class Output(Element): self._TKOut.output.pack(expand=True, fill=fill) self._TKOut.frame.pack(expand=True, fill=fill) - self.ParentRowFrame.pack(expand=True, fill=fill) + self.ParentRowFrame.pack(expand=expand_row, fill=fill) def __del__(self): """ @@ -2741,7 +2748,7 @@ class Button(Element): :param focus: if True, initial focus will be put on this button :type focus: (bool) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param visible: set visibility state of the element @@ -3111,7 +3118,7 @@ class ButtonMenu(Element): :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param tearoff: Determines if menus should allow them to be torn off @@ -3230,7 +3237,7 @@ class ProgressBar(Element): :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param visible: set visibility state of the element :type visible: (bool) :param metadata: User metadata that can be set to ANYTHING @@ -3317,7 +3324,7 @@ class Image(Element): :param size: (width, height) size of image in pixels :type size: Tuple[int, int] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param tooltip: text, that will appear when mouse hovers over the element @@ -3515,7 +3522,7 @@ class Canvas(Element): :param size: (width in char, height in rows) size in pixels to make canvas :type size: Tuple[int,int] :param pad: Amount of padding to put around element - :type pad: int + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element :type key: (Any) :param tooltip: text, that will appear when mouse hovers over the element @@ -3538,6 +3545,12 @@ class Canvas(Element): @property def TKCanvas(self): + """ + Returns the underlying tkiner Canvas widget + + :return: The tkinter canvas widget + :rtype: (tk.Canvas) + """ if self._TKCanvas is None: print('*** Did you forget to call Finalize()? Your code should look something like: ***') print('*** window = sg.Window("My Form", layout, finalize=True) ***') @@ -3577,7 +3590,7 @@ class Graph(Element): :param background_color: background color of the drawing area :type background_color: (str) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param change_submits: * DEPRICATED DO NOT USE! Same as enable_events :type change_submits: (bool) :param drag_submits: if True and Events are enabled for the Graph, will report Events any time the mouse moves while button down @@ -3627,8 +3640,12 @@ class Graph(Element): """ if None in (x_in, y_in): return None, None - scale_x = (self.CanvasSize[0] - 0) / (self.TopRight[0] - self.BottomLeft[0]) - scale_y = (0 - self.CanvasSize[1]) / (self.TopRight[1] - self.BottomLeft[1]) + try: + scale_x = (self.CanvasSize[0] - 0) / (self.TopRight[0] - self.BottomLeft[0]) + scale_y = (0 - self.CanvasSize[1]) / (self.TopRight[1] - self.BottomLeft[1]) + except: + scale_x = scale_y = 0 + new_x = 0 + scale_x * (x_in - self.BottomLeft[0]) new_y = self.CanvasSize[1] + scale_y * (y_in - self.BottomLeft[1]) return new_x, new_y @@ -4130,6 +4147,12 @@ class Graph(Element): @property def TKCanvas(self): + """ + Returns the underlying tkiner Canvas widget + + :return: The tkinter canvas widget + :rtype: (tk.Canvas) + """ if self._TKCanvas2 is None: print('*** Did you forget to call Finalize()? Your code should look something like: ***') print('*** form = sg.Window("My Form").Layout(layout).Finalize() ***') @@ -4249,7 +4272,7 @@ class Frame(Element): :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param border_width: width of border around element in pixels :type border_width: (int) :param key: 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 @@ -4417,7 +4440,7 @@ class VerticalSeparator(Element): def __init__(self, pad=None): """ :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) """ self.Orientation = 'vertical' # for now only vertical works @@ -4455,7 +4478,7 @@ class Tab(Element): :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param disabled: If True button will be created disabled :type disabled: (bool) :param border_width: width of border around element in pixels @@ -4663,7 +4686,7 @@ class TabGroup(Element): :param enable_events: If True then switching tabs will generate an Event :type enable_events: (bool) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param border_width: width of border around element in pixels :type border_width: (int) :param theme: DEPRICATED - You can only specify themes using set options or when window is created. It's not possible to do it on an element basis @@ -4882,7 +4905,7 @@ class Slider(Element): :param key: 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 :type key: (any) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param tooltip: text, that will appear when mouse hovers over the element :type tooltip: (str) :param visible: set visibility state of the element @@ -5106,7 +5129,7 @@ class Column(Element): :param size: (width, height) size in pixels (doesn't work quite right, sometimes only 1 dimension is set by tkinter :type size: Tuple[int, int] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param scrollable: if True then scrollbars will be added to the column :type scrollable: (bool) :param vertical_scroll_only: if Truen then no horizontal scrollbar will be shown @@ -5285,7 +5308,7 @@ class Pane(Element): :param size: (width, height) w=characters-wide, h=rows-high How much room to reserve for the Pane :type size: Tuple[int, int] :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param orientation: 'horizontal' or 'vertical' or ('h' or 'v'). Direction the Pane should slide :type orientation: (str) :param show_handle: if True, the handle is drawn that makes it easier to grab and slide @@ -5602,7 +5625,7 @@ class Menu(Element): :param tearoff: if True, then can tear the menu off from the window ans use as a floating window. Very cool effect :type tearoff: (bool) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: 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 :type key: (any) :param visible: set visibility state of the element @@ -5746,7 +5769,7 @@ class Table(Element): :param bind_return_key: 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 :type bind_return_key: (bool) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param tooltip: text, that will appear when mouse hovers over the element @@ -5978,7 +6001,7 @@ class Tree(Element): :param row_height: height of a single row in pixels :type row_height: (int) :param pad: Amount of padding to put around element (left/right, top/bottom) or ((left, right), (top, bottom)) - :type pad: (int, int) or ((int, int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element :type key: (Any) :param tooltip: text, that will appear when mouse hovers over the element @@ -8151,7 +8174,7 @@ def FileBrowse(button_text='Browse', target=(ThisRow, -1), file_types=(("ALL Fil :param disabled: set disable state for element (Default = False) :type disabled: (bool) :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8191,7 +8214,7 @@ def FilesBrowse(button_text='Browse', target=(ThisRow, -1), file_types=(("ALL Fi :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8229,7 +8252,7 @@ def FileSaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=(("ALL :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8267,7 +8290,7 @@ def SaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=(("ALL Fil :param font: specifies the font family, size, etc :type font: Union[str, Tuple[str, int]] :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8300,7 +8323,7 @@ def Save(button_text='Save', size=(None, None), auto_size_button=None, button_co :type font: Union[str, Tuple[str, int]] :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8332,7 +8355,7 @@ def Submit(button_text='Submit', size=(None, None), auto_size_button=None, butto :type font: Union[str, Tuple[str, int]] :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8365,7 +8388,7 @@ def Open(button_text='Open', size=(None, None), auto_size_button=None, button_co :type font: Union[str, Tuple[str, int]] :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] @@ -8396,7 +8419,7 @@ def OK(button_text='OK', size=(None, None), auto_size_button=None, button_color= :type font: Union[str, Tuple[str, int]] :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8428,7 +8451,7 @@ def Ok(button_text='Ok', size=(None, None), auto_size_button=None, button_color= :type font: Union[str, Tuple[str, int]] :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8460,7 +8483,7 @@ def Cancel(button_text='Cancel', size=(None, None), auto_size_button=None, butto :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] @@ -8491,7 +8514,7 @@ def Quit(button_text='Quit', size=(None, None), auto_size_button=None, button_co :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8523,7 +8546,7 @@ def Exit(button_text='Exit', size=(None, None), auto_size_button=None, button_co :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] @@ -8554,7 +8577,7 @@ def Yes(button_text='Yes', size=(None, None), auto_size_button=None, button_colo :param bind_return_key: (Default = True) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8586,7 +8609,7 @@ def No(button_text='No', size=(None, None), auto_size_button=None, button_color= :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] @@ -8617,7 +8640,7 @@ def Help(button_text='Help', size=(None, None), auto_size_button=None, button_co :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8649,7 +8672,7 @@ def Debug(button_text='', size=(None, None), auto_size_button=None, button_color :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8689,7 +8712,7 @@ def SimpleButton(button_text, image_filename=None, image_data=None, image_size=( :type disabled: (bool) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8730,7 +8753,7 @@ def CloseButton(button_text, image_filename=None, image_data=None, image_size=(N :type disabled: (bool) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8774,7 +8797,7 @@ def ReadButton(button_text, image_filename=None, image_data=None, image_size=(No :type disabled: (bool) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] @@ -8818,7 +8841,7 @@ def RealtimeButton(button_text, image_filename=None, image_data=None, image_size :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] @@ -8858,7 +8881,7 @@ def DummyButton(button_text, image_filename=None, image_data=None, image_size=(N :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -8904,7 +8927,7 @@ def CalendarButton(button_text, target=(None, None), close_when_date_chosen=True :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :param locale: @@ -8954,7 +8977,7 @@ def ColorChooserButton(button_text, target=(None, None), image_filename=None, im :param bind_return_key: (Default = False) :param focus: if focus should be set to this :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) - :type pad: (int, int) or ((int,int),(int,int)) + :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) :param key: key for uniquely identify this element (for window.FindElement) :type key: Union[str, int, tuple] :return: returns a button @@ -9817,7 +9840,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): if element.DisabledButtonColor[1] is not None: button_style.map(style_name, background=[('disabled', element.DisabledButtonColor[1])]) if height > 1: - button_style.configure(style_name, padding=height * _char_width_in_pixels(font)) + button_style.configure(style_name, padding=height * _char_width_in_pixels(font)) # should this be height instead? wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels if width != 0: button_style.configure(style_name, wraplength=wraplen) # set wrap to width of widget @@ -11145,8 +11168,7 @@ class QuickMeter(object): active_meters = {} exit_reasons = {} - def __init__(self, title, current_value, max_value, key, *args, orientation='v', bar_color=(None, None), - button_color=(None, None), size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None, grab_anywhere=False): + def __init__(self, title, current_value, max_value, key, *args, orientation='v', bar_color=(None, None), button_color=(None, None), size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None, grab_anywhere=False, no_titlebar=False): """ :param title: text to display in eleemnt @@ -11171,6 +11193,8 @@ class QuickMeter(object): :type border_width: (int) :param grab_anywhere: If True: can grab anywhere to move the window (Default = False) :type grab_anywhere: (bool) + :param no_titlebar: If True: window will be created without a titlebar + :type no_titlebar: (bool) """ self.start_time = datetime.datetime.utcnow() self.key = key @@ -11180,6 +11204,7 @@ class QuickMeter(object): self.grab_anywhere = grab_anywhere self.button_color = button_color self.border_width = border_width + self.no_titlebar = no_titlebar self.title = title self.current_value = current_value self.max_value = max_value @@ -11206,7 +11231,7 @@ class QuickMeter(object): col2 += [[T('', size=(30, 10), key='_STATS_')], [Cancel(button_color=self.button_color), Stretch()]] layout = [Column(col), Column(col2)] - self.window = Window(self.title, grab_anywhere=self.grab_anywhere, border_depth=self.border_width) + self.window = Window(self.title, grab_anywhere=self.grab_anywhere, border_depth=self.border_width, no_titlebar=self.no_titlebar) self.window.Layout([layout]).Finalize() return self.window @@ -11257,8 +11282,7 @@ class QuickMeter(object): return self.stat_messages -def OneLineProgressMeter(title, current_value, max_value, key, *args, orientation='v', bar_color=(None, None), - button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None, grab_anywhere=False): +def OneLineProgressMeter(title, current_value, max_value, key, *args, orientation='v', bar_color=(None, None), button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None, grab_anywhere=False, no_titlebar=False): """ :param title: text to display in eleemnt :type title: (str) @@ -11273,7 +11297,7 @@ def OneLineProgressMeter(title, current_value, max_value, key, *args, orientatio :param orientation: 'horizontal' or 'vertical' ('h' or 'v' work) (Default value = 'vertical' / 'v') :type orientation: (str) :param bar_color: color of a bar line - :type bar_color: str + :type bar_color: Tuple(str, str) :param button_color: button color (foreground, background) :type button_color: Tuple[str, str] :param size: (w,h) w=characters-wide, h=rows-high (Default value = DEFAULT_PROGRESS_BAR_SIZE) @@ -11282,12 +11306,13 @@ def OneLineProgressMeter(title, current_value, max_value, key, *args, orientatio :type border_width: (int) :param grab_anywhere: If True: can grab anywhere to move the window (Default = False) :type grab_anywhere: (bool) + :param no_titlebar: If True: no titlebar will be shown on the window + :type no_titlebar: (bool) :return: True if updated successfully. False if user closed the meter with the X or Cancel button :rtype: (bool) """ if key not in QuickMeter.active_meters: - meter = QuickMeter(title, current_value, max_value, key, *args, orientation=orientation, bar_color=bar_color, - button_color=button_color, size=size, border_width=border_width, grab_anywhere=grab_anywhere) + meter = QuickMeter(title, current_value, max_value, key, *args, orientation=orientation, bar_color=bar_color, button_color=button_color, size=size, border_width=border_width, grab_anywhere=grab_anywhere, no_titlebar=no_titlebar) QuickMeter.active_meters[key] = meter else: meter = QuickMeter.active_meters[key] @@ -11302,6 +11327,7 @@ def OneLineProgressMeterCancel(key): Cancels and closes a previously created One Line Progress Meter window :param key: Key used when meter was created + :type key: (Any) """ try: meter = QuickMeter.active_meters[key] @@ -11414,12 +11440,17 @@ class _DebugWin(): def PrintClose(): + """ + Close a previously opened EasyPrint window + """ EasyPrintClose() def EasyPrint(*args, size=(None, None), end=None, sep=None, location=(None, None), font=None, no_titlebar=False, no_button=False, grab_anywhere=False, keep_on_top=False, do_not_reroute_stdout=True, text_color=None, background_color=None): """ + Works like a "print" statement but with windowing options. Routes output to the "Debug Window" + :param *args: stuff to output :type *args: (Any) :param size: (w,h) w=characters-wide, h=rows-high @@ -11461,6 +11492,9 @@ eprint = EasyPrint def EasyPrintClose(): + """ + Close a previously opened EasyPrint window + """ if _DebugWin.debug_window is not None: _DebugWin.debug_window.Close() _DebugWin.debug_window = None @@ -12773,6 +12807,7 @@ def theme_background_color(color=None): Used for Windows and containers (Column, Frame, Tab) and tables :return: (str) - color string of the background color currently in use + :rtype: (str) """ if color is not None: set_options(background_color=color) @@ -12784,6 +12819,7 @@ def theme_element_background_color(color=None): Sets/Returns the background color currently in use for all elements except containers :return: (str) - color string of the element background color currently in use + :rtype: (str) """ if color is not None: set_options(element_background_color=color) @@ -12795,6 +12831,7 @@ def theme_text_color(color=None): Sets/Returns the text color currently in use :return: (str) - color string of the text color currently in use + :rtype: (str) """ if color is not None: set_options(text_color=color) @@ -12806,6 +12843,7 @@ def theme_text_element_background_color(color=None): Sets/Returns the background color for text elements :return: (str) - color string of the text background color currently in use + :rtype: (str) """ if color is not None: set_options(text_element_background_color=color) @@ -12816,6 +12854,7 @@ def theme_input_background_color(color=None): Sets/Returns the input element background color currently in use :return: (str) - color string of the input element background color currently in use + :rtype: (str) """ if color is not None: set_options(input_elements_background_color=color) @@ -12827,6 +12866,7 @@ def theme_input_text_color(color=None): Sets/Returns the input element entry color (not the text but the thing that's displaying the text) :return: (str) - color string of the input element color currently in use + :rtype: (str) """ if color is not None: set_options(input_text_color=color) @@ -12839,6 +12879,7 @@ def theme_button_color(color=None): Sets/Returns the button color currently in use :return: Tuple[str, str] - TUPLE with color strings of the button color currently in use (button text color, button background color) + :rtype: (str) """ if color is not None: set_options(button_color=color) @@ -12850,6 +12891,7 @@ def theme_progress_bar_color(color=None): Sets/Returns the progress bar colors by the current color theme :return: Tuple[str, str] - TUPLE with color strings of the ProgressBar color currently in use(button text color, button background color) + :rtype: (str) """ if color is not None: set_options(progress_meter_color=color) @@ -12861,6 +12903,7 @@ def theme_slider_color(color=None): Sets/Returns the slider color (used for sliders) :return: (str) - color string of the slider color currently in use + :rtype: (str) """ if color is not None: set_options(scrollbar_color=color) @@ -12873,6 +12916,7 @@ def theme_border_width(border_width=None): Used by non ttk elements at the moment :return: (int) - border width currently in use + :rtype: (str) """ if border_width is not None: set_options(border_width=border_width) @@ -12884,6 +12928,7 @@ def theme_slider_border_width(border_width=None): Sets/Returns the slider border width currently in use :return: (int) - border width currently in use + :rtype: (str) """ if border_width is not None: set_options(slider_border_width=border_width) @@ -12895,6 +12940,7 @@ def theme_progress_bar_border_width(border_width=None): Sets/Returns the progress meter border width currently in use :return: (int) - border width currently in use + :rtype: (str) """ if border_width is not None: set_options(progress_meter_border_depth=border_width) @@ -12907,6 +12953,7 @@ def theme_element_text_color(color=None): Sets/Returns the text color used by elements that have text as part of their display (Tables, Trees and Sliders) :return: (str) - color string currently in use + :rtype: (str) """ if color is not None: set_options(element_text_color=color) @@ -12918,6 +12965,7 @@ def theme_list(): Returns a sorted list of the currently available color themes :return: List[str] - A sorted list of the currently available color themes + :rtype: (str) """ return list_of_look_and_feel_values() @@ -13178,7 +13226,7 @@ def Popup(*args, title=None, button_color=None, background_color=None, text_colo :param text_color: text color :type text_color: (str) :param button_type: 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. - :type button_type: (enum) + :type button_type: (int) :param auto_close: If True the window will automatically close :type auto_close: (bool) :param auto_close_duration: time in seconds to keep window open before closing it automatically @@ -13428,7 +13476,7 @@ def PopupNonBlocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_col :param title: Title to display in the window. :type title: (str) :param button_type: Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). - :type button_type: (enum) + :type button_type: (int) :param button_color: button color (foreground, background) :type button_color: Tuple[str, str] :param background_color: color of background @@ -13477,7 +13525,7 @@ def PopupQuick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=Non :param title: Title to display in the window. :type title: (str) :param button_type: Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). - :type button_type: (enum) + :type button_type: (int) :param button_color: button color (foreground, background) :type button_color: Tuple[str, str] :param background_color: color of background @@ -13525,7 +13573,7 @@ def PopupQuickMessage(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS, b :param title: Title to display in the window. :type title: (str) :param button_type: Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). - :type button_type: (enum) + :type button_type: (int) :param button_color: button color (foreground, background) :type button_color: Tuple[str, str] :param background_color: color of background @@ -13571,7 +13619,7 @@ def PopupNoTitlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_colo :param title: Title to display in the window. :type title: (str) :param button_type: Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). - :type button_type: (enum) + :type button_type: (int) :param button_color: button color (foreground, background) :type button_color: Tuple[str, str] :param background_color: color of background @@ -13622,15 +13670,13 @@ def PopupAutoClose(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color :param title: Title to display in the window. :type title: (str) :param button_type: Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). - :type button_type: (enum) - + :type button_type: (int) :param button_color: button color (foreground, background) :type button_color: Tuple[str, str] :param background_color: color of background :type background_color: (str) :param text_color: color of the text :type text_color: (str) - :param auto_close: if True window will close itself :type auto_close: (bool) :param auto_close_duration: Older versions only accept int. Time in seconds until window will close @@ -15358,10 +15404,12 @@ theme(CURRENT_LOOK_AND_FEEL) # -------------------------------- ENTRY POINT IF RUN STANDALONE -------------------------------- # if __name__ == '__main__': + # To execute the upgrade from command line, type: + # python -m PySimpleGUI.PySimpleGUI upgrade if len(sys.argv) > 1 and sys.argv[1] == 'upgrade': _upgrade_gui() - exit(69) + exit(0) main() - exit(69) + exit(0)