TabGroup
TabGroup Element groups together your tabs into the group of tabs you see displayed in your window
TabGroup(
layout,
tab_location = None,
title_color = None,
tab_background_color = None,
selected_title_color = None,
selected_background_color = None,
background_color = None,
focus_color = None,
font = None,
change_submits = False,
enable_events = False,
pad = None,
p = None,
border_width = None,
tab_border_width = None,
theme = None,
key = None,
k = None,
size = (None, None),
s = (None, None),
tooltip = None,
right_click_menu = None,
expand_x = False,
expand_y = False,
visible = True,
metadata = None
)
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
background_color | str | None | color of background area that tabs are located on |
border_width | int | None | width of border around element in pixels |
change_submits | bool | False | * DEPRICATED DO NOT USE. Use enable_events instead |
enable_events | bool | False | If True then switching tabs will generate an Event |
expand_x | bool | False | If True the element will automatically expand in the X direction to fill available space |
expand_y | bool | False | If True the element will automatically expand in the Y direction to fill available space |
focus_color | str | None | color of focus indicator on the tabs |
font | (str or (str, int[, str]) or None) | None | specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike |
k | str or int or tuple or object | None | Same as the Key. You can use either k or key. Which ever is set will be used. |
key | str or int or tuple or object | None | 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 |
layout | List[List[Tab]] | Layout of Tabs. Different than normal layouts. ALL Tabs should be on first row | |
metadata | Any | None | User metadata that can be set to ANYTHING |
p | (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | None | Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used |
pad | (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | None | Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int) |
right_click_menu | List[List[ List[str] or str ]] | None | A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. |
s | (intorNone, intorNone) | (None, None) | Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used |
selected_background_color | str | None | color of tab when it is selected |
selected_title_color | str | None | color of tab text when it is selected |
size | (intorNone, intorNone) | (None, None) | (width, height) w=pixels-wide, h=pixels-high. Either item in tuple can be None to indicate use the computed value and set only 1 direction |
tab_background_color | str | None | color of all tabs that are not selected |
tab_border_width | int | None | width of border around the tabs |
tab_location | str | None | location that tabs will be displayed. Choices are left, right, top, bottom, lefttop, leftbottom, righttop, rightbottom, bottomleft, bottomright, topleft, topright |
theme | str | None | 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 |
title_color | str | None | color of text on tabs |
tooltip | str | None | text, that will appear when mouse hovers over the element |
visible | bool | True | DEPRECATED - Should you need to control visiblity for the TabGroup as a whole, place it into a Column element |
Class Properties
key
Returns key for the element. This is a READONLY property. Keys can be any hashable object (basically anything except a list... tuples are ok, but not lists)
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | Any | The window's Key |
metadata
Metadata is an Element property that you can use at any time to hold any value
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | Any | the current metadata value |
visible
Returns visibility state for the element. This is a READONLY property
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | bool | Visibility state for element |
widget
Returns tkinter widget for the element. This is a READONLY property. The implementation is that the Widget member variable is returned. This is a backward compatible addition
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | (tkinter.Widget) | The element's underlying tkinter widget |
Class Methods
def add_row
def add_tab
def bind
def block_focus
def expand
def find_currently_active_tab_key
def find_key_from_tab_name
def get
def get_next_focus
def get_previous_focus
def get_size
def grab_anywhere_exclude
def grab_anywhere_include
def hide_row
def layout
def remove_tooltip
def save_element_screenshot_to_disk
def set_cursor
def set_focus
def set_hscroll_position
def set_right_click_menu
def set_size
def set_tooltip
def set_vscroll_position
def unbind
def unhide_row
def update
add_row
Not recommended user call. Used to add rows of Elements to the Frame Element.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
*args | List[Element] | The list of elements for this row |
add_tab
Add a new tab to an existing TabGroup This call was written so that tabs can be added at runtime as your user performs operations. Your Window should already be created and finalized.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
tab_element | Tab | A Tab Element that has a layout in it |
bind
Used to add tkinter events to an Element. The tkinter specific data is in the Element's member variable user_bind_event
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
bind_string | str | The string tkinter expected in its bind function | |
key_modifier | str | Additional data to be added to the element's key when event is returned | |
propagate | bool | True | If True then tkinter will be told to propagate the event to the element |
block_focus
Enable or disable the element from getting focus by using the keyboard. If the block parameter is True, then this element will not be given focus by using the keyboard to go from one element to another. You CAN click on the element and utilize it.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
block | bool | True | if True the element will not get focus via the keyboard |
expand
Causes the Element to expand to fill available space in the X and Y directions. Can specify which or both directions
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
expand_row | bool | True | If True the row containing the element will also expand. Without this your element is "trapped" within the row |
expand_x | bool | False | If True Element will expand in the Horizontal directions |
expand_y | bool | False | If True Element will expand in the Vertical directions |
find_currently_active_tab_key
Returns the key for the currently active tab in this TabGroup
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | key or None | Returns the key or None of no key found |
find_key_from_tab_name
Searches through the layout to find the key that matches the text on the tab. Implies names should be unique
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
tab_name | str | name of a tab | |
RETURN | key or None | Returns the key or None if no key found |
get
Returns the current value for the Tab Group, which will be the currently selected tab's KEY or the text on the tab if no key is defined. Returns None if an error occurs. Note that this is exactly the same data that would be returned from a call to Window.read. Are you sure you are using this method correctly?
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Any or None | The key of the currently selected tab or None if there is an error |
get_next_focus
Gets the next element that should get focus after this element.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Element | Element that will get focus after this one |
get_previous_focus
Gets the element that should get focus previous to this element.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Element | Element that should get the focus before this one |
get_size
Return the size of an element in Pixels. Care must be taken as some elements use characters to specify their size but will return pixels when calling this get_size method.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | (int, int) | width and height of the element |
grab_anywhere_exclude
Excludes this element from being used by the grab_anywhere feature Handy for elements like a Graph element when dragging is enabled. You want the Graph element to get the drag events instead of the window dragging.
grab_anywhere_include
Includes this element in the grab_anywhere feature This will allow you to make a Multline element drag a window for example
hide_row
Hide the entire row an Element is located on. Use this if you must have all space removed when you are hiding an element, including the row container
layout
Can use like the Window.Layout method, but it's better to use the layout parameter when creating
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
rows | List[List[Element]] | The rows of Elements | |
RETURN | Frame | Used for chaining |
remove_tooltip
Removes a previiously created tooltip for an element
save_element_screenshot_to_disk
Saves an image of the PySimpleGUI window provided into the filename provided
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | (PIL.ImageGrab or None) | A PIL ImageGrab object that can be saved or manipulated |
set_cursor
Sets the cursor for the current Element. "Cursor" is used in 2 different ways in this call. For the parameter "cursor" it's actually the mouse pointer. If you do not want any mouse pointer, then use the string "none" For the parameter "cursor_color" it's the color of the beam used when typing into an input element
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
cursor | str | None | The tkinter cursor name |
cursor_color | str | None | color to set the "cursor" to |
set_focus
Sets the current focus to be on this element
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
force | bool | False | if True will call focus_force otherwise calls focus_set |
set_hscroll_position
Attempts to set the horizontal scroll postition for an element's Widget
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
percent_from_left | float | From 0 to 1.0, the percentage from the left to move scrollbar to |
set_right_click_menu
Sets a right click menu for an element. If a menu is already set for the element, it will call the tkinter destroy method to remove it
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
menu | List[List[ List[str] or str ]] | None | A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. |
set_size
Changes the size of an element to a specific size. It's possible to specify None for one of sizes so that only 1 of the element's dimensions are changed.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
size | (int, int) | (None, None) | The size in characters, rows typically. In some cases they are pixels |
set_tooltip
Called by application to change the tooltip text for an Element. Normally invoked using the Element Object such as: window.Element('key').SetToolTip('New tip').
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
tooltip_text | str or None | the text to show in tooltip. If None then no tip will be shown |
set_vscroll_position
Attempts to set the vertical scroll postition for an element's Widget
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
percent_from_top | float | From 0 to 1.0, the percentage from the top to move scrollbar to |
unbind
Removes a previously bound tkinter event from an Element.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
bind_string | str | The string tkinter expected in its bind function |
unhide_row
Unhides (makes visible again) the row container that the Element is located on. Note that it will re-appear at the bottom of the window / container, most likely.
update
Enables changing the visibility
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
visible | bool | None | control visibility of element |