### Test FreeSimpleGUIQt installation in Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Run these commands in a Python interpreter to verify the installation. If the package is not installed correctly, an error will occur during one of these commands. ```python python3 >>> import FreeSimpleGUIQt >>> FreeSimpleGUIQt.main() ``` -------------------------------- ### main Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/5_call_reference.md The main PySimpleGUI program entry point. Used to get SDK help, test the installation, get information about versions, and upgrade from GitHub. ```APIDOC ## main ### Description The main PySimpleGUI program entry point. Used to get SDK help, test the installation, get information about versions, and upgrade from GitHub. ### Method Function call ### Endpoint main ### Parameters No parameters documented. ### Response No response documented. ``` -------------------------------- ### Complete program for 'Get a filename' example Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Full FreeSimpleGUI program that uses a file browse button and a theme, then shows a popup with the selected filename. ```python import FreeSimpleGUI as sg sg.theme('Dark Blue 3') # please make your windows colorful layout = [[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ] window = sg.Window('Get filename example', layout) event, values = window.read() window.close() sg.Popup(event, values[0]) ``` -------------------------------- ### Install FreeSimpleGUI and PyInstaller Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md Install the required packages for building executables. Run these commands once in your environment. ```bash pip install FreeSimpleGUI pip install PyInstaller ``` -------------------------------- ### Install FreeSimpleGUI on Windows Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Initial installation command for Windows using Python's module invocation of pip. ```bash python -m pip install FreeSimpleGUI ``` -------------------------------- ### Dictionary-based window example with keys Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Complete FreeSimpleGUI example that creates a window with three input fields using keys, reads the window, and displays the values in a popup. Demonstrates the dictionary return behavior when any element has a key. ```python import FreeSimpleGUI as sg sg.theme('Dark Blue 3') # please make your windows colorful layout = [ [sg.Text('Please enter your Name, Address, Phone')], [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='-NAME-')], [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='-ADDRESS-')], [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='-PHONE-')], [sg.Submit(), sg.Cancel()] ] window = sg.Window('Simple data entry window', layout) event, values = window.read() window.close() sg.Popup(event, values, values['-NAME-'], values['-ADDRESS-'], values['-PHONE-']) ``` -------------------------------- ### Install FreeSimpleGUIQt with pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Install the FreeSimpleGUIQt package using pip. On Linux systems, use pip3 instead of pip. ```bash pip install --upgrade FreeSimpleGUIQt ``` -------------------------------- ### Install FreeSimpleGUI on Linux and macOS Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Initial installation command for Linux and macOS using Python 3's module invocation of pip. ```bash python3 -m pip install FreeSimpleGUI ``` -------------------------------- ### Install FreeSimpleGUIQt on Linux with pip3 Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Install FreeSimpleGUIQt on Linux systems using pip3 with the --no-cache-dir flag. ```bash pip3 install --upgrade --no-cache-dir FreeSimpleGUIQt ``` -------------------------------- ### Window.timer_start Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/5_call_reference.md Starts a timer. ```APIDOC ## Window.timer_start ### Description Starts a timer. ### Method timer_start ### Parameters - **key** (str) - Required - The timer key. - **duration** (int) - Required - Duration in milliseconds. ### Returns None ``` -------------------------------- ### Install pip on Linux Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/1_HEADER_top_part.md On some versions of Linux you will need to first install pip. ```bash sudo apt install python3-pip ``` -------------------------------- ### Install FreeSimpleGUI with pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Install the FreeSimpleGUI package using pip. Run this command in your terminal or command prompt. ```bash pip install FreeSimpleGUI ``` -------------------------------- ### UserSettings class with [ ] syntax example Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Use sg.UserSettings() with the [ ] lookup syntax to persist a filename between runs. The settings file is shared with the earlier example if both are placed in the same file, so a value saved by the first example is read by the second. The Input element accepts None as equivalent to an empty string. ```python import FreeSimpleGUI as sg settings = sg.UserSettings() layout = [[sg.Text('Enter a filename:')], [sg.Input(settings.get('-filename-', ''), key='-IN-'), sg.FileBrowse()], [sg.B('Save'), sg.B('Exit Without Saving', key='Exit')]] window = sg.Window('Filename Example', layout) while True: event, values = window.read() if event in (sg.WINDOW_CLOSED, 'Exit'): break elif event == 'Save': settings['-filename-'] = values['-IN-'] window.close() ``` -------------------------------- ### Save button example Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Example of creating a Save button with various parameters. The bind_return_key parameter is set to True, making the button respond to the return key. ```python Save(button_text = "Save", size = (None, None), s = (None, None), auto_size_button = None, button_color = None, bind_return_key = True, disabled = False, tooltip = None, font = None, focus = False, pad = None, p = None, key = None, k = None, visible = True, metadata = None, expand_x = False, expand_y = False) ``` -------------------------------- ### Install PySimpleGUI27 with pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/1_HEADER_top_part.md Install PySimpleGUI27 for Python 2.7 using pip. ```bash pip install --upgrade PySimpleGUI27 ``` -------------------------------- ### Install pip and tkinter for Python 2.7 Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/output/index.md Install pip and tkinter on Python 2.7 using apt. ```bash sudo apt install python-pip ``` ```bash sudo apt install python-tkinter ``` -------------------------------- ### Install psgdemos with pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/1_HEADER_top_part.md Use this command to install the psgdemos package, which includes both the Demo Programs and the Demo Browser. This is the standard pip install command for Python environments. ```bash python -m pip install psgdemos ``` -------------------------------- ### Install psgdemos via pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md Install the psgdemos package from PyPI, which includes the Demo Browser and all demo program source files. Use pip3 on Linux or Mac. ```bash pip install psgdemos ``` -------------------------------- ### Install psgdemos via pip3 on Linux/Mac Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md Alternative installation command for Linux or Mac systems that use pip3 instead of pip. ```bash pip3 install psgdemos ``` -------------------------------- ### Media Player Button with Image Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Example from the Demo Media Player showing a button with an image, using the same image parameters as the previous example. ```python sg.Button('Pause', button_color=(sg.theme_background_color(), sg.theme_background_color()), image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) ``` -------------------------------- ### Example User Settings Usage Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Primary use case for User Settings is storing filenames and folder names. The example uses a User Setting key of '-filename-' following the PySimpleGUI convention of lowercase keys for settings. ```python import PySimpleGUI as sg layout = [[sg.Text('Filename'), sg.Input(key='-filename-')], [sg.Button('Save'), sg.Button('Exit')]] window = sg.Window('User Settings Example', layout) while True: event, values = window.read() if event == sg.WIN_CLOSED or event == 'Exit': break if event == 'Save': settings = sg.UserSettings() settings['-filename-'] = values['-filename-'] sg.popup('You saved', settings['-filename-']) window.close() ``` -------------------------------- ### Launch Demo Browser with psgdemos Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md Run the Demo Browser from the command line after installing psgdemos. ```bash psgdemos ``` -------------------------------- ### main_get_debug_data Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/5_call_reference.md Gets debug data for the PySimpleGUI installation. ```APIDOC ## main_get_debug_data ### Description Gets debug data for the PySimpleGUI installation. ### Method Function call ### Endpoint main_get_debug_data ### Parameters No parameters documented. ### Response No response documented. ``` -------------------------------- ### Install tkinter for Python 3 Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/1_HEADER_top_part.md For python 3, install tkinter with apt-get. ```bash sudo apt-get install python3-tk ``` -------------------------------- ### Install tkinter for Python 2.7 and 3 Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/output/index.md Install tkinter if you get 'ImportError: No module named tkinter'. Use the appropriate command for your Python version. ```bash sudo apt-get install python-tk ``` ```bash sudo apt-get install python3-tk ``` -------------------------------- ### Key error example program Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/index.md Program used in the key error handling example. It imports FreeSimpleGUI as sg, defines a main function, and configures key error options with sg.set_options before building a window layout. ```python import FreeSimpleGUI as sg def main(): sg.set_options(suppress_raise_key_errors=False, suppress_error_popups=False, suppress_key_guessing=False) layout = [ [sg.Text('My Window')], [sg.Input(k='-IN-')], [sg.Text(size=(40,1), key='-OUT-')], [sg.Button('Go'), sg.Button('Exit')] ] window = sg.Window('Window Title', layout) while True: # the event loop event, values = window.read() if event == sg.WIN_CLOSED or event == 'Exit': break window['-OUTPUT-'].update(values['-IN-']) # This is the line that will cause the error window.close() if __name__ == '__main__': main() ``` -------------------------------- ### Install PySimpleGUI with pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/1_HEADER_top_part.md Install or upgrade PySimpleGUI using pip on Python 3. ```bash pip install --upgrade PySimpleGUI ``` -------------------------------- ### main_sdk_help() Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Display a window that will display the docstrings for each PySimpleGUI Element and the Window object. ```APIDOC ## main_sdk_help() ### Description Display a window that will display the docstrings for each PySimpleGUI Element and the Window object. ### Method Function ### Signature main_sdk_help() ### Parameters None ### Return Value None ``` -------------------------------- ### ImportError: No module named tkinter Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/index.md If you get an error similar to this, tkinter is not installed on your system. Some OS variants, such as Ubuntu, do not come with tkinter already installed. ```text ImportError: No module named tkinter ``` -------------------------------- ### main_sdk_help - Display docstrings for Elements and Window Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Displays a window showing the docstrings for each PySimpleGUI Element and the Window object. ```python main_sdk_help() ``` -------------------------------- ### popup_get_file: Get a filename Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Use this popup to get one or more filenames from the user. The example shows a typical call to popup_get_file and then displays the returned value. ```python text = sg.popup_get_file('Please enter a file name') sg.popup('Results', 'The value returned from popup_get_file', text) ``` -------------------------------- ### Install FreeSimpleGUIWeb via pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWeb/readme.md Install the FreeSimpleGUIWeb package using pip. If this fails, the readme suggests copying the FreeSimpleGUIWeb.py file into your application folder. ```bash pip install FreeSimpleGUIWeb ``` -------------------------------- ### popup_get_folder: Get a folder name Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Use this popup to get a folder name from the user. The example shows a typical call to popup_get_folder and then displays the returned value. ```python text = sg.popup_get_folder('Please enter a folder name') sg.popup('Results', 'The value returned from popup_get_folder', text) ``` -------------------------------- ### popup_get_text: Get a single line of text Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Use this popup to get a line of text from the user. The example shows how to call popup_get_text and then display the returned value using popup. ```python import FreeSimpleGUI as sg text = sg.popup_get_text('Title', 'Please input something') sg.popup('Results', 'The value returned from PopupGetText', text) ``` -------------------------------- ### Preview all themes with sg.preview_all_look_and_feel_themes() Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/cookbook.md Call this function to open a window showing all available themes. Useful for exploring theme options. ```python import FreeSimpleGUI as sg sg.preview_all_look_and_feel_themes() ``` -------------------------------- ### Single-line window read with close=True in PySimpleGUI Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/index.md Displays a window, gets the user's input, closes the window, and returns the event and values dictionary in one call. Available starting in version 4.16.0. The returned values dictionary can be accessed immediately, as shown by reading the '-ID-' key. ```python event, values = sg.Window('Login Window', [[sg.T('Enter your Login ID'), sg.In(key='-ID-')], [sg.B('OK'), sg.B('Cancel') ]]).read(close=True) login_id = values['-ID-'] ``` -------------------------------- ### Complete FreeSimpleGUI window example Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md A complete program that creates a window with text, input fields, and browse buttons. It sets a theme, builds a layout, reads the window, and prints the input values. The window is read once and then closed. ```python import FreeSimpleGUI as sg sg.theme('Dark Blue 3') # please make your windows colorful layout = [[sg.Text('Rename files or folders')], [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FileBrowse()], [sg.Submit(), sg.Cancel()]] window = sg.Window('Rename Files or Folders', layout) event, values = window.read() window.close() folder_path, file_path = values[0], values[1] # get the data from the values dictionary print(folder_path, file_path) ``` -------------------------------- ### Get INI entry with bracket notation and get method Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Access an entry in a section using either bracket notation or the get method. The get method returns a default value if the entry is missing. ```python settings['Section 2']['var'] settings['Section 2'].get('var', 'Default Value') ``` -------------------------------- ### Start a 3-second timer with a custom key Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Starts a timer that returns the custom key '-MY TIMER KEY-' when it expires, instead of the default sg.EVENT_TIMER. ```python window.timer_start(3000, key='-MY TIMER KEY-', repeating=False) ``` -------------------------------- ### get() Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the current value of the displayed text. ```APIDOC ## get() ### Description Gets the current value of the displayed text. ### Method get ### Parameters None ### Returns - **(str)** - The current value. ``` -------------------------------- ### preview_all_look_and_feel_themes(columns = 12, scrollable = False, scroll_area_size = (None, None), search_string = None, location = (None, None)) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Displays a 'Quick Reference Window' showing all available Look and Feel settings, sorted alphabetically. Legacy color names are mixed in, but otherwise sorted into Dark and Light halves. This function is deprecated and should not be used. ```APIDOC ## preview_all_look_and_feel_themes(columns = 12, scrollable = False, scroll_area_size = (None, None), search_string = None, location = (None, None)) ### Description Displays a 'Quick Reference Window' showing all available Look and Feel settings, sorted alphabetically. Legacy color names are mixed in, but otherwise sorted into Dark and Light halves. This function is deprecated and should not be used. ### Method Function ### Signature preview_all_look_and_feel_themes(columns = 12, scrollable = False, scroll_area_size = (None, None), search_string = None, location = (None, None)) ### Parameters - **columns** (int) - Optional - The number of themes to display per row. - **scrollable** (bool) - Optional - If True then scrollbars will be added. - **scroll_area_size** ((int, int)) - Optional - Size of the scrollable area (The Column Element used to make scrollable). - **search_string** (str) - Optional - If specified then only themes containing this string will be shown. - **location** ((int, int)) - Optional - Location on the screen to place the window. Defaults to the center like all windows. ### Return Value None ``` -------------------------------- ### Sizegrip.get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## Sizegrip.get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Endpoint get_previous_focus() ### Returns - (Element) Element that should get the focus before this one ``` -------------------------------- ### Sizegrip.get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## Sizegrip.get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus ### Endpoint get_next_focus() ### Returns - (Element) Element that will get focus after this one ``` -------------------------------- ### main() Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md The PySimpleGUI 'Test Harness'. This is meant to be a super-quick test of the Elements. It also provides access to SDK help, test installation, version information, and upgrade from GitHub. ```APIDOC ## main() ### Description The PySimpleGUI "Test Harness". This is meant to be a super-quick test of the Elements. It also provides access to SDK help, test installation, version information, and upgrade from GitHub. ### Method Function ### Signature main() ### Parameters None ### Return Value None ``` -------------------------------- ### Sample output from persistent window Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/cookbook.md Example output showing events and values when buttons are clicked. The event is the button name and values is a dictionary with the input key. ```text Read {'-IN-': 'typed into input field'} Read {'-IN-': 'More typing'} Exit {'-IN-': 'clicking the exit button this time'} ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Signature ```python get_previous_focus() ``` ### Returns - **(Element)** - Element that should get the focus before this one ``` -------------------------------- ### Complete program for 'Enter a number' example Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md Full FreeSimpleGUI program that displays the window, reads events and values, and shows a popup with the entered number. ```python import FreeSimpleGUI as sg layout = [[sg.Text('Enter a Number')], [sg.Input()], [sg.OK()] ] window = sg.Window('Enter a number example', layout) event, values = window.read() window.close() sg.Popup(event, values[0]) ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus ### Signature ```python get_next_focus() ``` ### Returns - **(Element)** - Element that will get focus after this one ``` -------------------------------- ### main_sdk_help Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/5_call_reference.md Provides SDK help for PySimpleGUI. ```APIDOC ## main_sdk_help ### Description Provides SDK help for PySimpleGUI. ### Method Function call ### Endpoint main_sdk_help ### Parameters No parameters documented. ### Response No response documented. ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Parameters None ### Response #### Success Response - **return** (Element) - Element that should get the focus before this one ### Request Example ```python get_previous_focus() ``` ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus ### Parameters None ### Response #### Success Response - **return** (Element) - Element that will get focus after this one ### Request Example ```python get_next_focus() ``` ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus() ### Returns - **(Element)** - Element that should get the focus before this one ``` -------------------------------- ### All Elements Demo - Full Python Script Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/2_readme.md This is the complete example script that creates a window with all 34 PySimpleGUI elements. It includes a function to build the window, a tree data structure, and an event loop that handles theme changes and toggling the custom titlebar. The script uses the FreeSimpleGUI import alias 'sg'. ```python import FreeSimpleGUI as sg """ Demo - Element List All 34 elements shown in 1 window as simply as possible. Copyright 2022 PySimpleGUI """ use_custom_titlebar = False def make_window(theme=None): NAME_SIZE = 23 def name(name): dots = NAME_SIZE-len(name)-2 return sg.Text(name + ' ' + '•'*dots, size=(NAME_SIZE,1), justification='r',pad=(0,0), font='Courier 10') sg.theme(theme) treedata = sg.TreeData() treedata.Insert("", '_A_', 'Tree Item 1', [1234], ) treedata.Insert("", '_B_', 'B', []) treedata.Insert("_A_", '_A1_', 'Sub Item 1', ['can', 'be', 'anything'], ) layout_l = [[name('Text'), sg.Text('Text')], [name('Input'), sg.Input(s=15)], [name('Multiline'), sg.Multiline(s=(15,2))], [name('Output'), sg.Output(s=(15,2))], [name('Combo'), sg.Combo(sg.theme_list(), default_value=sg.theme(), s=(15,22), enable_events=True, readonly=True, k='-COMBO-')], [name('OptionMenu'), sg.OptionMenu(['OptionMenu',],s=(15,2))], [name('Checkbox'), sg.Checkbox('Checkbox')], [name('Radio'), sg.Radio('Radio', 1)], [name('Spin'), sg.Spin(['Spin',], s=(15,2))], [name('Button'), sg.Button('Button')], [name('ButtonMenu'), sg.ButtonMenu('ButtonMenu', sg.MENU_RIGHT_CLICK_EDITME_EXIT)], [name('Slider'), sg.Slider((0,10), orientation='h', s=(10,15))], [name('Listbox'), sg.Listbox(['Listbox', 'Listbox 2'], no_scrollbar=True, s=(15,2))], [name('Image'), sg.Image(sg.EMOJI_BASE64_HAPPY_THUMBS_UP)], [name('Graph'), sg.Graph((125, 50), (0,0), (125,50), k='-GRAPH-')] ] layout_r = [[name('Canvas'), sg.Canvas(background_color=sg.theme_button_color()[1], size=(125,50))], [name('ProgressBar'), sg.ProgressBar(100, orientation='h', s=(10,20), k='-PBAR-')], [name('Table'), sg.Table([[1,2,3], [4,5,6]], ['Col 1','Col 2','Col 3'], num_rows=2)], [name('Tree'), sg.Tree(treedata, ['Heading',], num_rows=3)], [name('Horizontal Separator'), sg.HSep()], [name('Vertical Separator'), sg.VSep()], [name('Frame'), sg.Frame('Frame', [[sg.T(s=15)]])], [name('Column'), sg.Column([[sg.T(s=15)]])], [name('Tab, TabGroup'), sg.TabGroup([[sg.Tab('Tab1',[[sg.T(s=(15,2))]]), sg.Tab('Tab2', [[]])]])], [name('Pane'), sg.Pane([sg.Col([[sg.T('Pane 1')]]), sg.Col([[sg.T('Pane 2')]])])], [name('Push'), sg.Push(), sg.T('Pushed over')], [name('VPush'), sg.VPush()], [name('Sizer'), sg.Sizer(1,1)], [name('StatusBar'), sg.StatusBar('StatusBar')], [name('Sizegrip'), sg.Sizegrip()] ] layout = [[sg.MenubarCustom([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)] if use_custom_titlebar else [sg.Menu([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)], [sg.Checkbox('Use Custom Titlebar & Menubar', use_custom_titlebar, enable_events=True, k='-USE CUSTOM TITLEBAR-')], [sg.T('PySimpleGUI Elements - Use Combo to Change Themes', font='_ 18', justification='c', expand_x=True)], [sg.Col(layout_l), sg.Col(layout_r)]] window = sg.Window('The PySimpleGUI Element List', layout, finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT, keep_on_top=True, use_custom_titlebar=use_custom_titlebar) window['-PBAR-'].update(30) # Show 30% complete on ProgressBar window['-GRAPH-'].draw_image(data=sg.EMOJI_BASE64_HAPPY_JOY, location=(0,50)) # Draw something in the Graph Element return window # Start of the program... window = make_window() while True: event, values = window.read() sg.popup(event, values) # show the results of the read in a popup Window if event == sg.WIN_CLOSED or event == 'Exit': break if values['-COMBO-'] != sg.theme(): sg.theme(values['-COMBO-']) window.close() window = make_window() if event == '-USE CUSTOM TITLEBAR-': use_custom_titlebar = values['-USE CUSTOM TITLEBAR-'] window.close() window = make_window() window.close() ``` -------------------------------- ### Ok button default parameters Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/output/call reference.md Shows the default parameters for the pre-defined Ok button. Use this as a reference for customizing button behavior. The example includes all parameters with their default values, such as disabled=False, bind_return_key=True, and visible=True. ```python Ok(button_text = "Ok", size = (None, None), s = (None, None), auto_size_button = None, button_color = None, disabled = False, bind_return_key = True, tooltip = None, font = None, focus = False, pad = None, p = None, key = None, k = None, visible = True, metadata = None, expand_x = False, expand_y = False) ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus() ### Returns - **(Element)** - Element that will get focus after this one ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Response #### Success Response - **return** (Element) - Element that should get the focus before this one ### Request Example ```python get_previous_focus() ``` ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus ### Response #### Success Response - **return** (Element) - Element that will get focus after this one ### Request Example ```python get_next_focus() ``` ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method `get_previous_focus()` ### Returns - **(Element)** - Element that should get the focus before this one ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method `get_next_focus()` ### Returns - **(Element)** - Element that will get focus after this one ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Returns - **return** (Element) - Element that should get the focus before this one ### Signature ``` get_previous_focus() ``` ``` -------------------------------- ### Help(button_text, size, s, auto_size_button, button_color, disabled, font, tooltip, bind_return_key, focus, pad, p, key, k, visible, metadata, expand_x, expand_y) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Creates a Help button with customizable text, size, colors, events, and layout options. Returns a Button element. ```APIDOC ## Help(button_text, size, s, auto_size_button, button_color, disabled, font, tooltip, bind_return_key, focus, pad, p, key, k, visible, metadata, expand_x, expand_y) ### Description Creates a Help button with customizable text, size, colors, events, and layout options. Returns a Button element. ### Method Function call ### Endpoint Help(button_text = "Help", size = (None, None), s = (None, None), auto_size_button = None, button_color = None, disabled = False, font = None, tooltip = None, bind_return_key = False, focus = False, pad = None, p = None, key = None, k = None, visible = True, metadata = None, expand_x = False, expand_y = False) ### Parameters #### Parameters - **button_text** (str) - Required - Text in the button (Default value = 'Browse') - **target** (str or (int, int)) - Optional - Target for the button (Default value = (ThisRow, -1)) - **initial_folder** (str) - Optional - Starting path for folders and files - **tooltip** (str) - Optional - Text that will appear when mouse hovers over the element - **size** ((int, int)) - Optional - (w,h) w=characters-wide, h=rows-high - **s** ((int, int) or (None, None) or int) - Optional - 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 - **auto_size_button** (bool) - Optional - True if button size is determined by button text - **button_color** ((str, str) or str) - Optional - Button color (foreground, background) - **disabled** (bool) - Optional - Set disable state for element (Default = False) - **change_submits** (bool) - Optional - If True, pressing Enter key submits window (Default = False) - **enable_events** (bool) - Optional - Turns on the element specific events. (Default = False) - **font** ((str or (str, int[, str]) or None)) - Optional - Specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike - **pad** ((int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int) - Optional - 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) - **p** ((int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int) - Optional - 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 - **key** (str or int or tuple or object) - Optional - Used with window.find_element and with return values to uniquely identify this element - **k** (str or int or tuple or object) - Optional - Same as the Key. You can use either k or key. Which ever is set will be used. - **visible** (bool) - Optional - Set initial visibility state of the Button - **metadata** (Any) - Optional - Anything you want to store along with this button - **expand_x** (bool) - Optional - If True Element will expand in the Horizontal directions - **expand_y** (bool) - Optional - If True Element will expand in the Vertical directions ### Request Example ```python Help(button_text = "Help", size = (None, None), s = (None, None), auto_size_button = None, button_color = None, disabled = False, font = None, tooltip = None, bind_return_key = False, focus = False, pad = None, p = None, key = None, k = None, visible = True, metadata = None, expand_x = False, expand_y = False) ``` ### Response #### Success Response - **RETURN** (Button) - The Button created #### Response Example ```python Button ``` ``` -------------------------------- ### EasyPrint(args=*<1 or N object>, size=(None, None), end=None, sep=None, location=(None, None), relative_location=(None, None), font=None, no_titlebar=False, no_button=False, grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, text_color=None, background_color=None, colors=None, c=None, erase_all=False, resizable=True, blocking=None, wait=None) Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/output/call reference.md Works like a print statement but with windowing options. Routes output to the Debug Window. Supports extensive customization including font, colors, window behavior, and output routing. ```APIDOC ## EasyPrint(args=*<1 or N object>, size=(None, None), end=None, sep=None, location=(None, None), relative_location=(None, None), font=None, no_titlebar=False, no_button=False, grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, text_color=None, background_color=None, colors=None, c=None, erase_all=False, resizable=True, blocking=None, wait=None) ### Description Works like a "print" statement but with windowing options. Routes output to the "Debug Window". Supports text and background colors via the 'colors' or 'c' parameter. ### Method Function call ### Signature EasyPrint(args=*<1 or N object>, size=(None, None), end=None, sep=None, location=(None, None), relative_location=(None, None), font=None, no_titlebar=False, no_button=False, grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, text_color=None, background_color=None, colors=None, c=None, erase_all=False, resizable=True, blocking=None, wait=None) ### Parameters - **args** (Any) - Required - Stuff to output. - **size** ((int, int)) - Optional - (w,h) w=characters-wide, h=rows-high. - **end** (str) - Optional - End character. - **sep** (str) - Optional - Separator character. - **location** ((int, int)) - Optional - Location of upper left corner of the window. - **relative_location** ((int, int)) - Optional - (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative. - **font** (str or (str, int[, str]) or None) - Optional - Specifies the font family, size, etc. Tuple or single string format 'name size styles'. Styles: italic, roman, bold, normal, underline, overstrike. - **no_titlebar** (bool) - Optional - If True no titlebar will be shown. - **no_button** (bool) - Optional - Don't show button. - **grab_anywhere** (bool) - Optional - If True, can grab anywhere to move the window (Default = False). - **background_color** (str) - Optional - Color of background. - **text_color** (str) - Optional - Color of the text. - **keep_on_top** (bool) - Optional - If True the window will remain above all current windows. - **location** ((int, int)) - Optional - Location of upper left corner of the window. - **relative_location** ((int, int)) - Optional - (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative. - **do_not_reroute_stdout** (bool) - Optional - do not reroute stdout and stderr. If False, both stdout and stderr will reroute to here. - **echo_stdout** (bool) - Optional - If True stdout is sent to both the console and the debug window. - **colors** (str or (str, str)) - Optional - Either a tuple or a string that has both the text and background colors. - **c** (str or (str, str)) - Optional - Either a tuple or a string that has both the text and background colors. Tuple format: (foreground, background). String format: "foreground on background" (e.g., "white on red"). - **resizable** (bool) - Optional - If True, the user can resize the debug window. Default is True. - **erase_all** (bool) - Optional - If True, erase the output before printing. - **blocking** (bool or None) - Optional - If True, makes the window block instead of returning immediately. The "Quit" button changes to "More". ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus ### Returns - **return** (Element) - Element that will get focus after this one ### Signature ``` get_next_focus() ``` ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Signature get_previous_focus() ### Returns - **(Element)** - Element that should get the focus before this one ``` -------------------------------- ### Complete program using user settings Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/output/index.md Full example program that retrieves a saved filename, saves it on button click, and exits cleanly. ```python import FreeSimpleGUI as sg layout = [[sg.Text('Enter a filename:')], [sg.Input(sg.user_settings_get_entry('-filename-', ''), key='-IN-'), sg.FileBrowse()], [sg.B('Save'), sg.B('Exit Without Saving', key='Exit')]] window = sg.Window('Filename Example', layout) while True: event, values = window.read() if event in (sg.WINDOW_CLOSED, 'Exit'): break elif event == 'Save': sg.user_settings_set_entry('-filename-', values['-IN-']) window.close() ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus ### Signature get_next_focus() ### Returns - **(Element)** - Element that will get focus after this one ``` -------------------------------- ### Create Mac App with PyInstaller (basic) Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md Untested command to create a Mac App file. Includes binary paths for Tk and Tcl frameworks. ```bash pyinstaller --onefile --add-binary='/System/Library/Frameworks/Tk.framework/Tk':'tk' --add-binary='/System/Library/Frameworks/Tcl.framework/Tcl':'tcl' your_program.py ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Signature ``` get_previous_focus() ``` ### Returns - (Element) - Element that should get the focus before this one ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus ### Description Gets the next element that should get focus after this element. ### Method get_next_focus ### Signature ``` get_next_focus() ``` ### Returns - (Element) - Element that will get focus after this one ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method `get_previous_focus()` ### Parameters None ### Returns - **(Element)** - Element that should get the focus before this one ``` -------------------------------- ### Install PySimpleGUI on Raspberry Pi Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/1_HEADER_top_part.md On a Raspberry Pi, use sudo with pip3. ```bash sudo pip3 install --upgrade pysimplegui ``` -------------------------------- ### Add a custom theme with sg.theme_add_new Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/cookbook.md Defines a new theme dictionary with custom colors and registers it using sg.theme_add_new. Then switches to the new theme and displays a popup to preview it. ```python import FreeSimpleGUI as sg # Add your new theme colors and settings my_new_theme = {'BACKGROUND': '#709053', 'TEXT': '#fff4c9', 'INPUT': '#c7e78b', 'TEXT_INPUT': '#000000', 'SCROLL': '#c7e78b', 'BUTTON': ('white', '#709053'), 'PROGRESS': ('#01826B', '#D0D0D0'), 'BORDER': 1, 'SLIDER_DEPTH': 0, 'PROGRESS_DEPTH': 0} # Add your dictionary to the PySimpleGUI themes sg.theme_add_new('MyNewTheme', my_new_theme) # Switch your theme to use the newly added one. You can add spaces to make it more readable sg.theme('My New Theme') # Call a popup to show what the theme looks like sg.popup_get_text('This how the MyNewTheme custom theme looks') ``` -------------------------------- ### get_next_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the next element that should get focus after this element. ```APIDOC ## get_next_focus() ### Description Gets the next element that should get focus after this element. ### Returns - **(Element)** - Element that will get focus after this one. ``` -------------------------------- ### get_previous_focus Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/call reference.md Gets the element that should get focus previous to this element. ```APIDOC ## get_previous_focus ### Description Gets the element that should get focus previous to this element. ### Method get_previous_focus ### Signature ``` get_previous_focus() ``` ### Returns - **(Element)** - Element that should get the focus before this one ``` -------------------------------- ### Window.load_from_disk Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/5_call_reference.md Loads window settings from disk. ```APIDOC ## Window.load_from_disk ### Description Loads window settings from disk. ### Method load_from_disk ### Parameters - **filename** (str) - Required - The file to load from. ### Returns None ```