PySimpleGUI/readme_creator/markdown input files/5_call_reference.md

114 KiB

Python GUIs for Humans

Python GUIs for Humans

idea emoji
Want to master
PySimpleGUI?
Sign up to the official
course on
Udemy logo
apply coupon for discount: 2F6C6BE01B8940D3E457.
click here to visit course page

ELEMENT AND FUNCTION CALL REFERENCE

Here you will find the details for all Elements, Objects, and Functions that are available to you. If you want to use a complex element and don't understand the parameters, then this is the right place to come. For every element you're shown the parameters used to create it as well as all methods available to call.

This call reference document covers the tkinter port

This documentation is created using the PySimpleGUI.py file which means it's based on the tkinter code. Some of the calls are different, might not exist at all, or there may be more methods/functions for the other PySimpleGUI ports (Qt, Wx, Web).

The PySimpleGUIQt call reference is located in another location.

Caution - Some functions / methods may be internal only yet exposed in this documentation

This section of the documentation is generated directly from the source code. As a result, sometimes internal only functions or methods that you are not supposed to be calling are accidentally shown in this documentation. Hopefully these accidents don't happen often.

The Elements


Button Element

bind

block_focus

click

expand

get_next_focus

get_previous_focus

get_size

get_text

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

set_vscroll_position

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Click

GetText

SetFocus

SetTooltip

Update


ButtonMenu Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

set_vscroll_position

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Click

SetFocus

SetTooltip

Update


Canvas Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

metadata

set_cursor

set_focus

set_size

set_tooltip

tk_canvas

unbind

unhide_row

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

TKCanvas


Checkbox Element

bind

block_focus

expand

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


Column Element

add_row

bind

block_focus

contents_changed

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

layout

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

set_vscroll_position

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

AddRow

Layout

SetFocus

SetTooltip

Update


Combo Element

bind

block_focus

expand

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


Frame Element

add_row

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

layout

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

AddRow

Layout

SetFocus

SetTooltip

Update


Graph Element

Update

bind

block_focus

bring_figure_to_front

change_coordinates

delete_figure

draw_arc

draw_circle

draw_image

draw_line

draw_oval

draw_point

draw_polygon

draw_rectangle

draw_text

erase

expand

get_bounding_box

get_figures_at_location

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

move

move_figure

relocate_figure

send_figure_to_back

key

metadata

set_cursor

set_focus

set_size

set_tooltip

tk_canvas

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

BringFigureToFront

DeleteFigure

DrawArc

DrawCircle

DrawImage

DrawLine

DrawOval

DrawPoint

DrawPolygon

DrawRectangle

DrawText

Erase

GetBoundingBox

GetFiguresAtLocation

Move

MoveFigure

RelocateFigure

SendFigureToBack

SetFocus

SetTooltip

TKCanvas


HorizontalSeparator Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip


Image Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

update_animation

update_animation_no_buffering

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update

UpdateAnimation


Input Element

bind

block_focus

expand

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_ibeam_color

set_size

set_tooltip

set_vscroll_position

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


Listbox Element

bind

block_focus

expand

get

get_indexes

get_list_values

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

select_index

set_cursor

set_focus

set_index_color

set_size

set_tooltip

set_value

set_vscroll_position

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

GetIndexes

GetListValues

SetFocus

SetTooltip

SetValue

Update


Menu Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update


MenubarCustom Element

Note that while the MenubarCustom is an element, it is implemented using a function. It is actually a "compound element" that consists of several elements combined into a single Column element. See the Column element to get a list of method calls available. The function returns a Column element.


Multiline Element

bind

block_focus

expand

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

print

reroute_stderr_to_here

reroute_stdout_to_here

restore_stderr

restore_stdout

key

metadata

set_cursor

set_focus

set_ibeam_color

set_size

set_tooltip

set_vscroll_position

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


OptionMenu Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

set_vscroll_position

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update


Output Element

Output Element - a multi-lined text area to where stdout, stderr, cprint are rerouted.

Now based on the Multiline element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

tk_out

set_vscroll_position

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


Pane Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update


ProgressBar Element

bind

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

update_bar

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update

UpdateBar


Push Element (alias include P and Stretch)

Not a true element, but a function acting like an element.

These elements Push and VPush as aliases for Stretch and VStretch and are implemented using a function rather than a class. They're not meant to be manipulated like other elements. They have a functional role in a layout that is much like the "Layout Helper Functions" (pin, vtop, etc).

The name Stretch originally appeared in the PySimpleGUI APIs when the PySimpleGUIQt port was added.

In the Sept 2021 time-frame, a functioning version of this element appeared in the tkinter port, along with some aliases and a vertical addition.

The PySimpleGUI documentation, demos, etc, will be using the names Push and VPush.

Push-style Elements Use

These elements modify the placement of other elements inside of containers. As the name implies, these elements Push and VPush will "push" other elements around. Push works in the horizontal direction, VPush in the vertical.

A Push element will "push" elements on the row away from it. If you have 1 Push as the start of a row, then the row will be right-justified. If you have two Push elements, one as the first element and one as the last element on a row, then the row will be centered.


Radio Element

bind

block_focus

expand

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

reset_group

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

ResetGroup

SetFocus

SetTooltip

Update


Sizer Element

Note that while the Sizer is an element, it is implemented using a function and doesn't have the normal set of element methods.

This element is used to add more space.... more size...to a Container Element or a Window. They are often better to use than hard-coded sizes on the containers typically.


Sizegrip Element

bind

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

set_vscroll_position

unbind

unhide_row

update

visible

widget


Slider Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update


Spin Element

bind

block_focus

expand

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_ibeam_color

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


StatusBar Element

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update


Tab Element

add_row

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

layout

select

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

AddRow

Layout

Select

SetFocus

SetTooltip

Update


TabGroup Element

add_tab

bind

block_focus

expand

find_key_from_tab_name

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

set_vscroll_position

unbind

unhide_row

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

FindKeyFromTabName

Get

SetFocus

SetTooltip


Table Element

bind

block_focus

expand

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


Text Element

bind

expand

fonts_installed_list

get

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Get

SetFocus

SetTooltip

Update


Titlebar Element

Note that while the Titlebar is an element, it is implemented using a function.

It is actually a "compound element" that consists of several elements combined into a single Column element. See the Column element to get a list of method calls available. The function returns a Column element. This type of construct is referred to as "User Defined Elements" in the documentation and tutorials.


Tree Element

add_treeview_data

bind

block_focus

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

set_vscroll_position

unbind

unhide_row

update

visible

widget


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

SetFocus

SetTooltip

Update


TreeData (for Tree Element)

Node

insert

Insert


VerticalSeparator Element

bind

expand

get_next_focus

get_previous_focus

get_size

grab_anywhere_exclude

grab_anywhere_include

hide_row

key

metadata

set_cursor

set_focus

set_size

set_tooltip

unbind

unhide_row

visible

widget


VPush Element (aliases include VP and VStretch)

Like the Push element, this is not a true element but rather a function acting like an element. It will "Push" all elements above and below away from it.

Example: If first row has a VPush, then your layout will be At the bottom of the container it is in. If one is on the last row, then the layout will be at the top of the container. If you use TWO VPush, one on the first row and one on the last row, then your layout will be centered vertically.


Window - The Window Object

add_row

add_rows

alpha_channel

bind

bring_to_front

close

current_location

ding

disable

disable_debugger

disappear

elem

element

element_list

enable

enable_debugger

extend_layout

fill

finalize

find

find_element

find_element_with_focus

force_focus

get_screen_dimensions

get_screen_size

grab_any_where_off

grab_any_where_on

hide

keep_on_top_clear

keep_on_top_set

key_dict

layout

load_from_disk

make_modal

maximize

key

metadata

minimize

mouse_location

move

move_to_center

normal

perform_long_operation

read

reappear

refresh

save_to_disk

save_window_screenshot_to_disk

send_to_back

set_alpha

set_cursor

set_icon

set_min_size

set_size

set_title

set_transparent_color

size

start_thread

timer_get_active_timers

timer_start

timer_stop

timer_stop_all

un_hide

visibility_changed

was_closed

widget_to_element

write_event_value


These are non-PEP8 Compliant Methods - do NOT use

Do not use these... they are here for your reference should you see them in old code.

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

AddRow

AddRows

AlphaChannel

BringToFront

Close

CurrentLocation

Disable

DisableDebugger

Disappear

Elem

Element

Enable

EnableDebugger

Fill

Finalize

Find

FindElement

FindElementWithFocus

GetScreenDimensions

GrabAnyWhereOff

GrabAnyWhereOn

Hide

Layout

LoadFromDisk

Maximize

Minimize

Move

Normal

Read

Reappear

Refresh

SaveToDisk

SendToBack

SetAlpha

SetIcon

SetTransparentColor

Size

UnHide

VisibilityChanged


Layout Helper Funcs


SystemTray - Only for Qt and Wx ports. Use psgtray package for the tkinter port

close

hide

metadata

notify

read

show_message

un_hide

update


These are non-PEP8 Compliant Methods - do NOT use

The following methods are here for backwards compatibility reference. You will find there are PEP8 versions for each of these methods. The PEP8 versions will be all lower case and have underscores.

Close

Hide

Read

ShowMessage

UnHide

Update


Version Info

Multi-window Interface

Pre-Defined Buttons (use in your layout)

Button Functions No Longer Used (DO NOT USE)

Note - These are no longer recommended! They are shown here in case you run into them in some old code.


Debug Window Output

Color Printing to Multiline Element of a Window


One Line Progress Meter

Add a progress meter to your application by adding 1 line of code.

NON-PEP8 Versions

Don't use these. They are here in case you're searching for them. Instead use the PEP8 version one_line_progress_meter.

Popups PEP8 Versions

sprint Popup Alias - Same as popup_scrolled

Popup Not PEP8 Compliant names

*** You should not use these function names! ***

These versions of the popup functions are here only for backwards compatibility. Instead use the popup functions that have snake_case rather than CamelCase.

Display Objects as Strings

These functions will return an object as a string that shows each of the object's member variables. They're nice to use if you want to print any Python object, not just PySimpleGUI ones.

The Main PySimpleGUI Program - Test Harness, Global Settings, Debug Information, Upgrade from GitHub

A convention that PySimpleGUI uses is that standalone entry points start with "main_". These calls are essentially a mini-program within the PySimpleGUI.py file.

Used to get SDK help, test the installation, get information about the versions, upgrade from GitHub.

You can call main() from your code and then access these other features such as the global settings. You can also directly call these functions.

You can also type psgmain from the command line to access it if you have pip installed your copy of PySimpleGUI.

Debugger


Themes

The way to get Windows that have elements that have matching colors.


Platform Checks

These are simple functions you can use that return a boolean True if sys.platform matches the platform. Saves you the trouble of importing sys and then looking up the values for sys.platform.


UserSettings API - Class Interface

The User Settings API is used to store your settings information from one session to another or from one program to another. They are stored on disk in either JSON or INI file formats.

In addition to user settings files, there is also a global PySimpleGUI settings file that PySimpleGUI uses to store information about the default Python interpreter you want to use with the Exec APIs, the default theme. You can directly access the global settings through the UserSettings object: pysimplegui_user_settings

delete_entry

delete_file

delete_section

exists

get

get_dict

get_filename

load

read

save

set

set_default_value

set_location

write_new_dictionary

User Settings API - Function Interface

You have a couple of ways to access User Settings if your information is stored in JSON format. If you're using the INI format, then you must use the UserSettings object.

These are particularly useful directly in layouts, allowing you to you can easily set default values.


Exec APIs - Launching Subprocesses

These API calls are used to launch subprocesses. You can launch Python files or any type of executable file. In these calls is where you invoke the editor and file explorer that was specified in the PySimpleGUI Global Settings.


Clipboard APIs

Note that this clipboard uses tkinter's clipboard. There is a known limitation that your application needs to remain running until you've pasted the contents. Managed to get around this limitation so that the clipboard stays set after you exit your application, but only have it working for Windows systems.

Misc

Application-wide Configuration / Settings (set_options, etc)

Non PEP8 versions

Old Themes (Look and Feel) - Replaced by theme()

You should NOT use these calls. They are here for your reference should you run into them in existing code.


This documentation is copyright 2021 by PySimpleGUI(tm)

The PySimpleGUI name and logo are trademarked. Use without permission is prohibited.

Republishing the copyrighted PySimpleGUI documentation and selling it IS PROHIBITED.

When in doubt, ask.