More.... you guessed it... docstrings! Version 4.1.0.10
This commit is contained in:
parent
8618879a71
commit
42c4d97920
323
PySimpleGUI.py
323
PySimpleGUI.py
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
version = __version__ = "4.1.0.9 Unreleased - Anniversary Edition"
|
version = __version__ = "4.1.0.10 Unreleased - Anniversary Edition"
|
||||||
|
|
||||||
|
|
||||||
# 888888ba .d88888b oo dP .88888. dP dP dP
|
# 888888ba .d88888b oo dP .88888. dP dP dP
|
||||||
|
@ -3030,7 +3030,7 @@ class Graph(Element):
|
||||||
|
|
||||||
def Move(self, x_direction, y_direction):
|
def Move(self, x_direction, y_direction):
|
||||||
"""
|
"""
|
||||||
Moves the entire drawing area (the canvas) by indicated number of ticks in your coordinate system
|
Moves the entire drawing area (the canvas) by some delta from the current position. Units are indicated in your coordinate system indicated number of ticks in your coordinate system
|
||||||
|
|
||||||
:param x_direction: Union[int, float] how far to move in the "X" direction in your coordinates
|
:param x_direction: Union[int, float] how far to move in the "X" direction in your coordinates
|
||||||
:param y_direction: Union[int, float] how far to move in the "Y" direction in your coordinates
|
:param y_direction: Union[int, float] how far to move in the "Y" direction in your coordinates
|
||||||
|
@ -3044,13 +3044,14 @@ class Graph(Element):
|
||||||
return None
|
return None
|
||||||
self._TKCanvas2.move('all', shift_amount[0], shift_amount[1])
|
self._TKCanvas2.move('all', shift_amount[0], shift_amount[1])
|
||||||
|
|
||||||
|
|
||||||
def MoveFigure(self, figure, x_direction, y_direction):
|
def MoveFigure(self, figure, x_direction, y_direction):
|
||||||
"""
|
"""
|
||||||
|
Moves a previously drawn figure using a "delta" from current position
|
||||||
|
|
||||||
:param figure:
|
:param figure: (id) Previously obtained figure-id. These are returned from all Draw methods
|
||||||
:param x_direction:
|
:param x_direction: Union[int, float] delta to apply to position in the X direction
|
||||||
:param y_direction:
|
:param y_direction: Union[int, float] delta to apply to position in the Y direction
|
||||||
|
|
||||||
"""
|
"""
|
||||||
zero_converted = self._convert_xy_to_canvas_xy(0, 0)
|
zero_converted = self._convert_xy_to_canvas_xy(0, 0)
|
||||||
shift_converted = self._convert_xy_to_canvas_xy(x_direction, y_direction)
|
shift_converted = self._convert_xy_to_canvas_xy(x_direction, y_direction)
|
||||||
|
@ -3063,12 +3064,14 @@ class Graph(Element):
|
||||||
|
|
||||||
def RelocateFigure(self, figure, x, y):
|
def RelocateFigure(self, figure, x, y):
|
||||||
"""
|
"""
|
||||||
|
Move a previously made figure to an arbitrary (x,y) location. This differs from the Move methods because it
|
||||||
|
uses absolute coordinates versus relative for Move
|
||||||
|
|
||||||
:param figure:
|
:param figure: (id) Previously obtained figure-id. These are returned from all Draw methods
|
||||||
:param x:
|
:param x: Union[int, float] location on X axis (in user coords) to move the upper left corner of the figure
|
||||||
:param y:
|
:param y: Union[int, float] location on Y axis (in user coords) to move the upper left corner of the figure
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
zero_converted = self._convert_xy_to_canvas_xy(0, 0)
|
zero_converted = self._convert_xy_to_canvas_xy(0, 0)
|
||||||
shift_converted = self._convert_xy_to_canvas_xy(x, y)
|
shift_converted = self._convert_xy_to_canvas_xy(x, y)
|
||||||
shift_amount = (shift_converted[0] - zero_converted[0], shift_converted[1] - zero_converted[1])
|
shift_amount = (shift_converted[0] - zero_converted[0], shift_converted[1] - zero_converted[1])
|
||||||
|
@ -3087,13 +3090,14 @@ class Graph(Element):
|
||||||
print('*** form = sg.Window("My Form").Layout(layout).Finalize() ***')
|
print('*** form = sg.Window("My Form").Layout(layout).Finalize() ***')
|
||||||
return self._TKCanvas2
|
return self._TKCanvas2
|
||||||
|
|
||||||
# Realtime button release callback
|
# button release callback
|
||||||
def ButtonReleaseCallBack(self, event):
|
def ButtonReleaseCallBack(self, event):
|
||||||
"""
|
"""
|
||||||
|
Not a user callable method. Used to get Graph click events. Called by tkinter when button is released
|
||||||
|
|
||||||
:param event:
|
:param event: (event) event info from tkinter. Note not used in this method
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.ClickPosition = (None, None)
|
self.ClickPosition = (None, None)
|
||||||
self.LastButtonClickedWasRealtime = not self.DragSubmits
|
self.LastButtonClickedWasRealtime = not self.DragSubmits
|
||||||
if self.Key is not None:
|
if self.Key is not None:
|
||||||
|
@ -3106,13 +3110,14 @@ class Graph(Element):
|
||||||
self.ParentForm.LastButtonClicked = None
|
self.ParentForm.LastButtonClicked = None
|
||||||
self.MouseButtonDown = False
|
self.MouseButtonDown = False
|
||||||
|
|
||||||
# Realtime button callback
|
# button callback
|
||||||
def ButtonPressCallBack(self, event):
|
def ButtonPressCallBack(self, event):
|
||||||
"""
|
"""
|
||||||
|
Not a user callable method. Used to get Graph click events. Called by tkinter when button is released
|
||||||
|
|
||||||
:param event:
|
:param event: (event) event info from tkinter. Contains the x and y coordinates of a click
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.ClickPosition = self._convert_canvas_xy_to_xy(event.x, event.y)
|
self.ClickPosition = self._convert_canvas_xy_to_xy(event.x, event.y)
|
||||||
self.ParentForm.LastButtonClickedWasRealtime = self.DragSubmits
|
self.ParentForm.LastButtonClickedWasRealtime = self.DragSubmits
|
||||||
if self.Key is not None:
|
if self.Key is not None:
|
||||||
|
@ -3123,13 +3128,14 @@ class Graph(Element):
|
||||||
self.ParentForm.TKroot.quit() # kick out of loop if read was called
|
self.ParentForm.TKroot.quit() # kick out of loop if read was called
|
||||||
self.MouseButtonDown = True
|
self.MouseButtonDown = True
|
||||||
|
|
||||||
# Realtime button callback
|
# button callback
|
||||||
def MotionCallBack(self, event):
|
def MotionCallBack(self, event):
|
||||||
"""
|
"""
|
||||||
|
Not a user callable method. Used to get Graph mouse motion events. Called by tkinter when mouse moved
|
||||||
|
|
||||||
:param event:
|
:param event: (event) event info from tkinter. Contains the x and y coordinates of a mouse
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.MouseButtonDown:
|
if not self.MouseButtonDown:
|
||||||
return
|
return
|
||||||
self.ClickPosition = self._convert_canvas_xy_to_xy(event.x, event.y)
|
self.ClickPosition = self._convert_canvas_xy_to_xy(event.x, event.y)
|
||||||
|
@ -3142,7 +3148,12 @@ class Graph(Element):
|
||||||
self.ParentForm.TKroot.quit() # kick out of loop if read was called
|
self.ParentForm.TKroot.quit() # kick out of loop if read was called
|
||||||
|
|
||||||
def SetFocus(self, force=False):
|
def SetFocus(self, force=False):
|
||||||
""" """
|
"""
|
||||||
|
Sets the current focus to be on this Graph Element
|
||||||
|
|
||||||
|
:param force: (bool) if True will call focus_force otherwise calls focus_set
|
||||||
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if force:
|
if force:
|
||||||
self._TKCanvas2.focus_force()
|
self._TKCanvas2.focus_force()
|
||||||
|
@ -3161,28 +3172,29 @@ class Graph(Element):
|
||||||
# Frame #
|
# Frame #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Frame(Element):
|
class Frame(Element):
|
||||||
""" """
|
"""
|
||||||
|
A Frame Element that contains other Elements. Encloses with a line around elements and a text label.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, title, layout, title_color=None, background_color=None, title_location=None,
|
def __init__(self, title, layout, title_color=None, background_color=None, title_location=None,
|
||||||
relief=DEFAULT_FRAME_RELIEF, size=(None, None), font=None, pad=None, border_width=None, key=None,
|
relief=DEFAULT_FRAME_RELIEF, size=(None, None), font=None, pad=None, border_width=None, key=None,
|
||||||
tooltip=None, right_click_menu=None, visible=True):
|
tooltip=None, right_click_menu=None, visible=True):
|
||||||
"""
|
"""
|
||||||
|
:param title: (str) text that is displayed as the Frame's "label" or title
|
||||||
:param title: title for frame above
|
:param layout: List[List[Elements]] The layout to put inside the Frame
|
||||||
:param layout: layout of elements
|
:param title_color: (str) color of the title text
|
||||||
:param title_color: ????????????????????????
|
:param background_color: (str) background color of the Frame
|
||||||
:param background_color: color of background
|
:param title_location: (enum) location to place the text title. Choices include: TITLE_LOCATION_TOP TITLE_LOCATION_BOTTOM TITLE_LOCATION_LEFT TITLE_LOCATION_RIGHT TITLE_LOCATION_TOP_LEFT TITLE_LOCATION_TOP_RIGHT TITLE_LOCATION_BOTTOM_LEFT TITLE_LOCATION_BOTTOM_RIGHT
|
||||||
:param title_location: ????????????????????????
|
:param relief: (enum) relief style. Values are same as other elements with reliefs.
|
||||||
:param relief: relief style. Values are same as progress meter relief values. Can be a constant or a string: `RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID` (Default value = DEFAULT_FRAME_RELIEF)
|
Choices include RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID
|
||||||
:param size: (w,h) w=characters-wide, h=rows-high
|
:param size: Tuple(int, int) (width in characters, height in rows) (note this parameter may not always work)
|
||||||
:param font: specifies the font family, size, etc
|
:param font: Union[str, tuple] specifies the font family, size, etc
|
||||||
:param pad: Amount of padding to put around 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 border_width: width of border around element
|
:param border_width: (int) width of border around element in pixels
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element
|
: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 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 right_click_menu: List[List[str]] see "Right Click Menus" for format
|
:param right_click_menu: List[List[str]] see "Right Click Menus" for format
|
||||||
:param visible: set visibility state of the element (Default = True)
|
:param visible: (bool) set visibility state of the element
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.UseDictionary = False
|
self.UseDictionary = False
|
||||||
|
@ -3209,10 +3221,10 @@ class Frame(Element):
|
||||||
return
|
return
|
||||||
|
|
||||||
def AddRow(self, *args):
|
def AddRow(self, *args):
|
||||||
"""Parms are a variable number of Elements
|
"""
|
||||||
|
Not recommended user call. Used to add rows of Elements to the Frame Element.
|
||||||
:param *args:
|
|
||||||
|
|
||||||
|
:param *args: List[Element] The list of elements for this row
|
||||||
"""
|
"""
|
||||||
NumRows = len(self.Rows) # number of existing rows is our row number
|
NumRows = len(self.Rows) # number of existing rows is our row number
|
||||||
CurrentRowNumber = NumRows # this row's number
|
CurrentRowNumber = NumRows # this row's number
|
||||||
|
@ -3229,19 +3241,24 @@ class Frame(Element):
|
||||||
|
|
||||||
def Layout(self, rows):
|
def Layout(self, rows):
|
||||||
"""
|
"""
|
||||||
|
Can use like the Window.Layout method, but it's better to use the layout parameter when creating
|
||||||
|
|
||||||
:param rows:
|
:param rows: List[List[Element]] The rows of Elements
|
||||||
|
:return: (Frame) Used for chaining
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self.AddRow(*row)
|
self.AddRow(*row)
|
||||||
|
return self
|
||||||
|
|
||||||
def _GetElementAtLocation(self, location):
|
def _GetElementAtLocation(self, location):
|
||||||
"""
|
"""
|
||||||
|
Not user callable. Used to find the Element at a row, col position within the layout
|
||||||
|
|
||||||
:param location:
|
:param location: Tuple[int, int] (row, column) position of the element to find in layout
|
||||||
|
:return: (Element) The element found at the location
|
||||||
"""
|
"""
|
||||||
|
|
||||||
(row_num, col_num) = location
|
(row_num, col_num) = location
|
||||||
row = self.Rows[row_num]
|
row = self.Rows[row_num]
|
||||||
element = row[col_num]
|
element = row[col_num]
|
||||||
|
@ -3268,17 +3285,17 @@ class Frame(Element):
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
# Separator #
|
# Vertical Separator #
|
||||||
# Routes stdout, stderr to a scrolled window #
|
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class VerticalSeparator(Element):
|
class VerticalSeparator(Element):
|
||||||
""" """
|
"""
|
||||||
|
Vertical Separator Element draws a vertical line at the given location. It will span 1 "row". Usually paired with
|
||||||
|
Column Element if extra height is needed
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, pad=None):
|
def __init__(self, pad=None):
|
||||||
"""
|
"""
|
||||||
|
: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: Amount of padding to put around element
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.Orientation = 'vertical' # for now only vertical works
|
self.Orientation = 'vertical' # for now only vertical works
|
||||||
|
@ -3298,25 +3315,25 @@ VSep = VerticalSeparator
|
||||||
# Tab #
|
# Tab #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
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
|
||||||
|
"""
|
||||||
|
|
||||||
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,
|
||||||
border_width=None, key=None, tooltip=None, right_click_menu=None, visible=True):
|
border_width=None, key=None, tooltip=None, right_click_menu=None, visible=True):
|
||||||
"""
|
"""
|
||||||
|
:param title: (str) text to show on the tab
|
||||||
:param title:
|
:param layout: List[List[Element]] The element layout that will be shown in the tab
|
||||||
:param layout: ?????????????????????
|
:param title_color: (str) color of the tab text (note not currently working on tkinter)
|
||||||
:param title_color:
|
:param background_color: (str) color of background of the entire layout
|
||||||
:param background_color: color of background
|
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
||||||
:param font: specifies the font family, size, etc
|
: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: Amount of padding to put around element
|
:param disabled: (bool) If True button will be created disabled
|
||||||
:param disabled: set disable state for element (Default = False)
|
:param border_width: (int) width of border around element in pixels
|
||||||
:param border_width: width of border around element
|
: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: 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
|
||||||
:param right_click_menu: List[List[str]] see "Right Click Menus" for format
|
:param right_click_menu: List[List[str]] see "Right Click Menus" for format
|
||||||
:param visible: set visibility state of the element (Default = True)
|
:param visible: (bool) set visibility state of the element
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.UseDictionary = False
|
self.UseDictionary = False
|
||||||
|
@ -3343,10 +3360,10 @@ class Tab(Element):
|
||||||
return
|
return
|
||||||
|
|
||||||
def AddRow(self, *args):
|
def AddRow(self, *args):
|
||||||
"""Parms are a variable number of Elements
|
"""
|
||||||
|
Not recommended use call. Used to add rows of Elements to the Frame Element.
|
||||||
:param *args:
|
|
||||||
|
|
||||||
|
:param *args: List[Element] The list of elements for this row
|
||||||
"""
|
"""
|
||||||
NumRows = len(self.Rows) # number of existing rows is our row number
|
NumRows = len(self.Rows) # number of existing rows is our row number
|
||||||
CurrentRowNumber = NumRows # this row's number
|
CurrentRowNumber = NumRows # this row's number
|
||||||
|
@ -3363,10 +3380,12 @@ class Tab(Element):
|
||||||
|
|
||||||
def Layout(self, rows):
|
def Layout(self, rows):
|
||||||
"""
|
"""
|
||||||
|
Not user callable. Use layout parameter instead. Creates the layout using the supplied rows of Elements
|
||||||
|
|
||||||
:param rows:
|
:param rows: List[List[Element]] The list of rows
|
||||||
|
:return: (Tab) used for chaining
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self.AddRow(*row)
|
self.AddRow(*row)
|
||||||
return self
|
return self
|
||||||
|
@ -3392,10 +3411,12 @@ class Tab(Element):
|
||||||
|
|
||||||
def _GetElementAtLocation(self, location):
|
def _GetElementAtLocation(self, location):
|
||||||
"""
|
"""
|
||||||
|
Not user callable. Used to find the Element at a row, col position within the layout
|
||||||
|
|
||||||
:param location:
|
:param location: Tuple[int, int] (row, column) position of the element to find in layout
|
||||||
|
:return: (Element) The element found at the location
|
||||||
"""
|
"""
|
||||||
|
|
||||||
(row_num, col_num) = location
|
(row_num, col_num) = location
|
||||||
row = self.Rows[row_num]
|
row = self.Rows[row_num]
|
||||||
element = row[col_num]
|
element = row[col_num]
|
||||||
|
@ -3413,28 +3434,28 @@ class Tab(Element):
|
||||||
# TabGroup #
|
# TabGroup #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class TabGroup(Element):
|
class TabGroup(Element):
|
||||||
""" """
|
"""
|
||||||
|
TabGroup Element groups together your tabs into the group of tabs you see displayed in your window
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, layout, tab_location=None, title_color=None, selected_title_color=None, background_color=None,
|
def __init__(self, layout, tab_location=None, title_color=None, selected_title_color=None, background_color=None,
|
||||||
font=None, change_submits=False, enable_events=False, pad=None, border_width=None, theme=None,
|
font=None, change_submits=False, enable_events=False, pad=None, border_width=None, theme=None,
|
||||||
key=None, tooltip=None, visible=True):
|
key=None, tooltip=None, visible=True):
|
||||||
"""
|
"""
|
||||||
|
:param layout: List[List[Tab]] Layout of Tabs. Different than normal layouts. ALL Tabs should be on first row
|
||||||
:param layout:
|
:param tab_location: (str) location that tabs will be displayed. Choices are left, right, top, bottom, lefttop, leftbottom, righttop, rightbottom, bottomleft, bottomright, topleft, topright
|
||||||
:param tab_location:
|
:param title_color: (str) color of text on tabs
|
||||||
:param title_color:
|
:param selected_title_color: (str) color of tab when it is selected
|
||||||
:param selected_title_color:
|
:param background_color: (str) color of background of tabs
|
||||||
:param background_color: color of background
|
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
||||||
:param font: specifies the font family, size, etc
|
:param change_submits: (bool) * DEPRICATED DO NOT USE! Same as enable_events
|
||||||
:param change_submits: If True, pressing Enter key submits window (Default = False)
|
:param enable_events: (bool) If True then switching tabs will generate an Event
|
||||||
:param enable_events: Turns on the element specific events.(Default = False)
|
: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: Amount of padding to put around element
|
:param border_width: (int) width of border around element in pixels
|
||||||
:param border_width: width of border around element
|
:param theme: (enum) tabs can be 'themed'. These are the choices (some may not work on your OS): THEME_DEFAULT THEME_WINNATIVE THEME_CLAM THEME_ALT THEME_CLASSIC THEME_VISTA THEME_XPNATIVE
|
||||||
:param theme:
|
: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: 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
|
||||||
:param visible: set visibility state of the element (Default = True)
|
:param visible: (bool) set visibility state of the element
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.UseDictionary = False
|
self.UseDictionary = False
|
||||||
|
@ -3461,11 +3482,12 @@ class TabGroup(Element):
|
||||||
return
|
return
|
||||||
|
|
||||||
def AddRow(self, *args):
|
def AddRow(self, *args):
|
||||||
"""Parms are a variable number of Elements
|
|
||||||
|
|
||||||
:param *args:
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
Not recommended user call. Used to add rows of Elements to the Frame Element.
|
||||||
|
|
||||||
|
:param *args: List[Element] The list of elements for this row
|
||||||
|
"""
|
||||||
|
|
||||||
NumRows = len(self.Rows) # number of existing rows is our row number
|
NumRows = len(self.Rows) # number of existing rows is our row number
|
||||||
CurrentRowNumber = NumRows # this row's number
|
CurrentRowNumber = NumRows # this row's number
|
||||||
CurrentRow = [] # start with a blank row and build up
|
CurrentRow = [] # start with a blank row and build up
|
||||||
|
@ -3481,19 +3503,23 @@ class TabGroup(Element):
|
||||||
|
|
||||||
def Layout(self, rows):
|
def Layout(self, rows):
|
||||||
"""
|
"""
|
||||||
|
Can use like the Window.Layout method, but it's better to use the layout parameter when creating
|
||||||
|
|
||||||
:param rows:
|
:param rows: List[List[Element]] The rows of Elements
|
||||||
|
:return: (Frame) Used for chaining
|
||||||
"""
|
"""
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self.AddRow(*row)
|
self.AddRow(*row)
|
||||||
|
return self
|
||||||
|
|
||||||
def _GetElementAtLocation(self, location):
|
def _GetElementAtLocation(self, location):
|
||||||
"""
|
"""
|
||||||
|
Not user callable. Used to find the Element at a row, col position within the layout
|
||||||
|
|
||||||
:param location:
|
:param location: Tuple[int, int] (row, column) position of the element to find in layout
|
||||||
|
:return: (Element) The element found at the location
|
||||||
"""
|
"""
|
||||||
|
|
||||||
(row_num, col_num) = location
|
(row_num, col_num) = location
|
||||||
row = self.Rows[row_num]
|
row = self.Rows[row_num]
|
||||||
element = row[col_num]
|
element = row[col_num]
|
||||||
|
@ -3501,9 +3527,10 @@ class TabGroup(Element):
|
||||||
|
|
||||||
def FindKeyFromTabName(self, tab_name):
|
def FindKeyFromTabName(self, tab_name):
|
||||||
"""
|
"""
|
||||||
|
Searches through the layout to find the key that matches the text on the tab. Implies names should be unique
|
||||||
|
|
||||||
:param tab_name:
|
:param tab_name:
|
||||||
|
:return: Union[key, None] Returns the key or None if no key found
|
||||||
"""
|
"""
|
||||||
for row in self.Rows:
|
for row in self.Rows:
|
||||||
for element in row:
|
for element in row:
|
||||||
|
@ -3513,10 +3540,10 @@ class TabGroup(Element):
|
||||||
|
|
||||||
def SelectTab(self, index):
|
def SelectTab(self, index):
|
||||||
"""
|
"""
|
||||||
|
Create a tkinter event that mimics user clicking on a tab
|
||||||
:param index:
|
:param index: (int) indicates which Tab should be selected. Count starts at 0
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.TKNotebook.select(index)
|
self.TKNotebook.select(index)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -3534,7 +3561,9 @@ class TabGroup(Element):
|
||||||
# Slider #
|
# Slider #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Slider(Element):
|
class Slider(Element):
|
||||||
""" """
|
"""
|
||||||
|
A slider, horizontal or vertical
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, range=(None, None), default_value=None, resolution=None, tick_interval=None, orientation=None,
|
def __init__(self, range=(None, None), default_value=None, resolution=None, tick_interval=None, orientation=None,
|
||||||
disable_number_display=False, border_width=None, relief=None, change_submits=False,
|
disable_number_display=False, border_width=None, relief=None, change_submits=False,
|
||||||
|
@ -3542,26 +3571,25 @@ class Slider(Element):
|
||||||
text_color=None, key=None, pad=None, tooltip=None, visible=True):
|
text_color=None, key=None, pad=None, tooltip=None, visible=True):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param range: (min, max) slider's range
|
:param range: Union[Tuple[int, int], Tuple[float, float]] slider's range (min value, max value)
|
||||||
:param default_value: default setting (within range)
|
:param default_value: Union[int, float] starting value for the slider
|
||||||
:param resolution: how much each 'tick' should represent. Default = 1
|
:param resolution: Union[int, float] the smallest amount the slider can be moved
|
||||||
:param tick_interval:
|
:param tick_interval: Union[int, float] how often a visible tick should be shown next to slider
|
||||||
:param orientation: 'horizontal' or 'vertical' ('h' or 'v' work)
|
:param orientation: (str) 'horizontal' or 'vertical' ('h' or 'v' also work)
|
||||||
:param disable_number_display: (Default = False)
|
:param disable_number_display: (bool) if True no number will be displayed by the Slider Element
|
||||||
:param border_width: width of border around element
|
:param border_width: (int) width of border around element in pixels
|
||||||
:param relief: relief style. Values are same as progress meter relief values. Can be a constant or a string: `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: If True, pressing Enter key submits window (Default = False)
|
:param change_submits: (bool) * DEPRICATED DO NOT USE! Same as enable_events
|
||||||
:param enable_events: Turns on the element specific events.(Default = False)
|
:param enable_events: (bool) If True then moving the slider will generate an Event
|
||||||
:param disabled: set disable state for element (Default = False)
|
:param disabled: (bool) set disable state for element
|
||||||
:param size: (w,h) w=characters-wide, h=rows-high (Default = (None))
|
:param size: Tuple[int, int] (width in characters, height in rows)
|
||||||
:param font: specifies the font family, size, etc
|
:param font: Union[str, Tuple[str, int]] specifies the font family, size, etc
|
||||||
:param background_color: color of background
|
:param background_color: (str) color of slider's background
|
||||||
:param text_color: color of the text
|
:param text_color: (str) color of the slider's text
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element
|
: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 pad: Amount of padding to put around 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 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 visible: set visibility state of the element (Default = True)
|
:param visible: (bool) set visibility state of the element
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.TKScale = None # type: tk.Scale
|
self.TKScale = None # type: tk.Scale
|
||||||
|
@ -3587,8 +3615,8 @@ class Slider(Element):
|
||||||
"""
|
"""
|
||||||
Changes some of the settings for the Slider Element. Must call `Window.Read` or `Window.Finalize` prior
|
Changes some of the settings for the Slider Element. Must call `Window.Read` or `Window.Finalize` prior
|
||||||
|
|
||||||
:param value: set current selection to value new value in slider
|
:param value: Union[int, float] sets current slider value
|
||||||
:param range: new range in slider
|
:param range: Union[Tuple[int, int], Tuple[float, float] Sets a new range for slider
|
||||||
:param disabled: (bool) disable or enable state of the element
|
:param disabled: (bool) disable or enable state of the element
|
||||||
:param visible: (bool) control visibility of element
|
:param visible: (bool) control visibility of element
|
||||||
|
|
||||||
|
@ -3613,12 +3641,11 @@ class Slider(Element):
|
||||||
|
|
||||||
def _SliderChangedHandler(self, event):
|
def _SliderChangedHandler(self, event):
|
||||||
"""
|
"""
|
||||||
|
Not user callable. Callback function for when slider is moved.
|
||||||
|
|
||||||
:param event:
|
:param event: (event) the event data provided by tkinter. Unknown format. Not used.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# first, get the results table built
|
|
||||||
# modify the Results table in the parent FlexForm object
|
|
||||||
if self.Key is not None:
|
if self.Key is not None:
|
||||||
self.ParentForm.LastButtonClicked = self.Key
|
self.ParentForm.LastButtonClicked = self.Key
|
||||||
else:
|
else:
|
||||||
|
@ -3774,22 +3801,23 @@ class TkScrollableFrame(tk.Frame):
|
||||||
# Column #
|
# Column #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Column(Element):
|
class Column(Element):
|
||||||
""" """
|
"""
|
||||||
|
A container element that is used to create a layout within your window's layout
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, layout, background_color=None, size=(None, None), pad=None, scrollable=False,
|
def __init__(self, layout, background_color=None, size=(None, None), pad=None, scrollable=False,
|
||||||
vertical_scroll_only=False, right_click_menu=None, key=None, visible=True):
|
vertical_scroll_only=False, right_click_menu=None, key=None, visible=True):
|
||||||
"""
|
"""
|
||||||
|
:param layout: List[List[Element]] Layout that will be shown in the Column container
|
||||||
:param layout: ????????????????????????
|
:param background_color: (str) color of background of entire Column
|
||||||
:param background_color: color of background
|
:param size: Tuple[int, int] (width, height) size in pixels (doesn't work quite right, sometimes
|
||||||
:param size: (w,h) w=characters-wide, h=rows-high
|
only 1 dimension is set by tkinter
|
||||||
:param pad: Amount of padding to put around 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 scrollable: ???????????????????????? (Default = False)
|
:param scrollable: (bool) if True then scrollbars will be added to the column
|
||||||
:param vertical_scroll_only: ???????????????????????? (Default = False)
|
:param vertical_scroll_only: (bool) if Truen then no horizontal scrollbar will be shown
|
||||||
:param right_click_menu: List[List[str]] see "Right Click Menus" for format
|
:param right_click_menu: List[List[str]] see "Right Click Menus" for format
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
: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 visible: set visibility state of the element (Default = True)
|
:param visible: (bool) set visibility state of the element
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.UseDictionary = False
|
self.UseDictionary = False
|
||||||
|
@ -3814,11 +3842,12 @@ class Column(Element):
|
||||||
return
|
return
|
||||||
|
|
||||||
def AddRow(self, *args):
|
def AddRow(self, *args):
|
||||||
"""Parms are a variable number of Elements
|
|
||||||
|
|
||||||
:param *args:
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
Not recommended user call. Used to add rows of Elements to the Column Element.
|
||||||
|
|
||||||
|
:param *args: List[Element] The list of elements for this row
|
||||||
|
"""
|
||||||
|
|
||||||
NumRows = len(self.Rows) # number of existing rows is our row number
|
NumRows = len(self.Rows) # number of existing rows is our row number
|
||||||
CurrentRowNumber = NumRows # this row's number
|
CurrentRowNumber = NumRows # this row's number
|
||||||
CurrentRow = [] # start with a blank row and build up
|
CurrentRow = [] # start with a blank row and build up
|
||||||
|
@ -3834,24 +3863,30 @@ class Column(Element):
|
||||||
|
|
||||||
def Layout(self, rows):
|
def Layout(self, rows):
|
||||||
"""
|
"""
|
||||||
|
Can use like the Window.Layout method, but it's better to use the layout parameter when creating
|
||||||
|
|
||||||
:param rows:
|
:param rows: List[List[Element]] The rows of Elements
|
||||||
|
:return: (Frame) Used for chaining
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self.AddRow(*row)
|
self.AddRow(*row)
|
||||||
|
return self
|
||||||
|
|
||||||
def _GetElementAtLocation(self, location):
|
def _GetElementAtLocation(self, location):
|
||||||
"""
|
"""
|
||||||
|
Not user callable. Used to find the Element at a row, col position within the layout
|
||||||
|
|
||||||
:param location:
|
:param location: Tuple[int, int] (row, column) position of the element to find in layout
|
||||||
|
:return: (Element) The element found at the location
|
||||||
"""
|
"""
|
||||||
|
|
||||||
(row_num, col_num) = location
|
(row_num, col_num) = location
|
||||||
row = self.Rows[row_num]
|
row = self.Rows[row_num]
|
||||||
element = row[col_num]
|
element = row[col_num]
|
||||||
return element
|
return element
|
||||||
|
|
||||||
|
|
||||||
def Update(self, visible=None):
|
def Update(self, visible=None):
|
||||||
"""
|
"""
|
||||||
Changes some of the settings for the Column Element. Must call `Window.Read` or `Window.Finalize` prior
|
Changes some of the settings for the Column Element. Must call `Window.Read` or `Window.Finalize` prior
|
||||||
|
@ -3882,11 +3917,15 @@ class Column(Element):
|
||||||
super().__del__()
|
super().__del__()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
# Pane #
|
# Pane #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Pane(Element):
|
class Pane(Element):
|
||||||
""" """
|
"""
|
||||||
|
A sliding Pane that is unique to tkinter
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, pane_list, background_color=None, size=(None, None), pad=None, orientation='vertical',
|
def __init__(self, pane_list, background_color=None, size=(None, None), pad=None, orientation='vertical',
|
||||||
show_handle=True, relief=RELIEF_RAISED, handle_size=None, border_width=None, key=None, visible=True):
|
show_handle=True, relief=RELIEF_RAISED, handle_size=None, border_width=None, key=None, visible=True):
|
||||||
|
|
Loading…
Reference in New Issue