### Launching the psgdemos Browser (Bash) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md After installing the `psgdemos` package, this simple command executed from the terminal launches the FreeSimpleGUI Demo Browser application, which allows users to search, view, and run the included demo programs. ```bash psgdemos ``` -------------------------------- ### Installing psgdemos with python3 pip (Python/Bash) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Similar to the previous command, this version uses `python3 -m pip` for environments where `python3` is the primary executable. It installs the `psgdemos` package containing FreeSimpleGUI demos and the Demo Browser. ```bash python3 -m pip install psgdemos ``` -------------------------------- ### Install FreeSimpleGUI via Pip - Windows Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This command installs the FreeSimpleGUI library using pip as a Python module. It is the recommended method for initial installation on Windows systems. ```Shell python -m pip install FreeSimpleGUI ``` -------------------------------- ### Installing psgdemos with pip (Python/Bash) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This command-line instruction uses the `python -m pip` syntax to execute the pip module and install the `psgdemos` package. This package contains numerous FreeSimpleGUI demo programs and the Demo Browser application. ```bash python -m pip install psgdemos ``` -------------------------------- ### Install FreeSimpleGUI via Pip - Linux/MacOS Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This command installs the FreeSimpleGUI library using pip as a Python module. It is the recommended method for initial installation on Linux and MacOS systems. ```Shell python3 -m pip install FreeSimpleGUI ``` -------------------------------- ### Testing FreeSimpleGUIQt Installation Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Steps to verify the installation by importing the library and running its main test function from the Python 3 command line interpreter. ```python python3 >>> import FreeSimpleGUIQt >>> FreeSimpleGUIQt.main() ``` -------------------------------- ### Install PySimpleGUI Demos via Pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md These commands demonstrate how to install the `psgdemos` package, which includes the demo browser and source files, using the standard Python package installer, pip. ```Shell pip install psgdemos ``` ```Shell pip3 install psgdemos ``` -------------------------------- ### Install FreeSimpleGUIWeb via pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWeb/readme.md Installs the FreeSimpleGUIWeb package using the pip package manager. This is the standard and recommended way to install the library. ```Shell pip install FreeSimpleGUIWeb ``` -------------------------------- ### Launch PySimpleGUI Demo Browser Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md This command is used to invoke the graphical demo browser from the command line after the `psgdemos` package has been installed. ```Shell psgdemos ``` -------------------------------- ### Installing FreeSimpleGUIQt using pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Command to install or upgrade the FreeSimpleGUIQt library using the standard pip package manager for Python 3. ```bash pip install --upgrade FreeSimpleGUIQt ``` -------------------------------- ### Upgrade FreeSimpleGUI via Pip - Windows Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This command upgrades the FreeSimpleGUI library using pip as a Python module. The --upgrade flag ensures the latest version is installed, and --no-cache-dir prevents caching issues on Windows systems. ```Shell python -m pip install --upgrade --no-cache-dir FreeSimpleGUI ``` -------------------------------- ### Install FreeSimpleGUI via pip (Windows) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Installs the FreeSimpleGUI package using pip as a Python module. This command is the suggested method for initial installation on Windows systems. ```Shell python -m pip install FreeSimpleGUI ``` -------------------------------- ### Installing FreeSimpleGUI Demos via Pip (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Command line instruction using the standard 'python' executable to install the 'psgdemos' package via pip. This package contains numerous demo programs and the Demo Browser application. ```Shell python -m pip install psgdemos ``` -------------------------------- ### Installing FreeSimpleGUIQt using pip3 (Linux) Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Command specifically for Linux systems using pip3, including the --no-cache-dir flag to prevent caching during installation or upgrade. ```bash pip3 install --upgrade --no-cache-dir FreeSimpleGUIQt ``` -------------------------------- ### FreeSimpleGUIQt SystemTray Event Loop Example Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Demonstrates a basic design pattern for using the FreeSimpleGUIQt SystemTray. It shows how to define a menu, create a SystemTray instance with an icon and menu, and enter an event loop that reads menu selections and performs actions like showing a popup or exiting. ```python import FreeSimpleGUIQt as sg menu_def = ['BLANK', ['&Open', '---', '&Save', ['1', '2', ['a', 'b']], '&Properties', 'E&xit']] tray = sg.SystemTray(menu=menu_def, filename=r'default_icon.ico') while True: # The event loop menu_item = tray.Read() print(menu_item) if menu_item == 'Exit': break elif menu_item == 'Open': sg.Popup('Menu item chosen', menu_item) ``` -------------------------------- ### Installing FreeSimpleGUI Demos via Pip (Python3) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Command line instruction for environments where 'python3' is the primary executable for Python. It installs the 'psgdemos' package using pip, providing access to demo programs and the Demo Browser. ```Shell python3 -m pip install psgdemos ``` -------------------------------- ### Install FreeSimpleGUI via pip (Linux/MacOS) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Installs the FreeSimpleGUI package using pip as a Python module. This command is the suggested method for initial installation on Linux and MacOS systems. ```Shell python3 -m pip install FreeSimpleGUI ``` -------------------------------- ### Single-Line FreeSimpleGUI Window with Aliases - Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Shows the same single-line FreeSimpleGUI window creation as the previous example, but uses shorthand aliases (T for Text, I for Input, B for Button) to further condense the code for brevity. ```python event, values = sg.Window('Window Title', [[sg.T("What's your name?")],[sg.I()],[sg.B('Ok')]]).read(close=True) ``` -------------------------------- ### Defining SystemTray Menu with Keys (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Example demonstrating how to define a menu structure for the SystemTray element in FreeSimpleGUIQt, specifically showing the syntax for adding keys to menu items using the '::' separator. ```python menu_def = ['File', ['Hide::key', '&Open::key', '&Save',['1', '2', ['a','b']], '&Properties', 'E&xit']] ``` -------------------------------- ### Get Filename with FreeSimpleGUI Popup (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This snippet demonstrates how to use FreeSimpleGUI's high-level popup functions to prompt the user for a filename using `popup_get_file` and then display the selected filename in another popup using `popup`. It requires the FreeSimpleGUI library. ```python import FreeSimpleGUI as sg filename = sg.popup_get_file('Enter the file you wish to process') sg.popup('You entered', filename) ``` -------------------------------- ### Upgrade FreeSimpleGUI via Pip - Linux/MacOS Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This command upgrades the FreeSimpleGUI library using pip as a Python module. The --upgrade flag ensures the latest version is installed, and --no-cache-dir prevents caching issues on Linux and MacOS systems. ```Shell python3 -m pip install --upgrade --no-cache-dir FreeSimpleGUI ``` -------------------------------- ### Launching the FreeSimpleGUI Demo Browser (Shell) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Command line instruction to launch the FreeSimpleGUI Demo Browser application after it has been successfully installed using pip. The browser allows searching, editing, and running demo programs. ```Shell psgdemos ``` -------------------------------- ### Creating Button Grid with List Comprehension - Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Illustrates using nested list comprehensions in Python to generate a 4x4 grid of Button elements for a FreeSimpleGUI layout efficiently. Shows the necessary import and the concise window creation/reading. ```python import FreeSimpleGUI as sg layout = [[sg.Button(f'{row}, {col}') for col in range(4)] for row in range(4)] event, values = sg.Window('List Comprehensions', layout).read(close=True) ``` -------------------------------- ### Single-Line FreeSimpleGUI Window Creation - Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Demonstrates condensing the definition, creation, display, and data collection of a simple FreeSimpleGUI window into a single line of Python code. Includes Text, Input, and Button elements directly within the layout definition. ```python event, values = sg.Window('Window Title', [[sg.Text("What's your name?")],[sg.Input()],[sg.Button('Ok')]]).read(close=True) ``` -------------------------------- ### Setting FreeSimpleGUI Theme (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This snippet demonstrates how to set the visual theme for a FreeSimpleGUI application. It imports the library and then calls the `theme` function with the desired theme name. This single call changes the appearance of all subsequent widgets created in the window. ```Python import FreeSimpleGUI as sg sg.theme('dark grey 9') ``` -------------------------------- ### Installing FreeSimpleGUI with pip (Bash) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Command to install the FreeSimpleGUI Python package using the pip package manager. This is the standard way to add the library to your Python environment. ```bash pip install FreeSimpleGUI ``` -------------------------------- ### Defining FreeSimpleGUI Layout with Rows - Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Shows how to define a FreeSimpleGUI window layout using a list of lists, where each inner list represents a row containing GUI elements. Includes Text, Input, and Button elements to illustrate the row structure. ```python layout = [ [sg.Text('Row 1'), sg.Text("What's your name?")], [sg.Text('Row 2'), sg.Input()], [sg.Text('Row 3'), sg.Button('Ok')] ] ``` -------------------------------- ### Installing FreeSimpleGUI and PyInstaller via Pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md These bash commands use the pip package manager to install the FreeSimpleGUI library and the PyInstaller tool. Both packages are necessary for developing FreeSimpleGUI applications and packaging them into standalone executables. ```bash pip install FreeSimpleGUI pip install PyInstaller ``` -------------------------------- ### Install Remi Dependency via pip Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWeb/readme.md Installs the Remi package using the pip package manager. Remi is a required dependency for FreeSimpleGUIWeb to function, as it provides the web server and GUI rendering capabilities. ```Shell pip install remi ``` -------------------------------- ### Create Styled FreeSimpleGUI Window (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This snippet shows how to create a FreeSimpleGUI window without a titlebar and with a specific transparency level using the `no_titlebar` and `alpha_channel` parameters during window creation. It requires the FreeSimpleGUI library and a defined `layout` variable for the window content. ```python window = sg.Window('My window', layout, no_titlebar=True, alpha_channel=0.5) ``` -------------------------------- ### Get File Path and Display with Popups (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Demonstrates how to use FreeSimpleGUI's high-level popup functions to prompt the user for a file path and then display the selected path in another popup window. Requires the FreeSimpleGUI library. ```python import FreeSimpleGUI as sg filename = sg.popup_get_file('Enter the file you wish to process') sg.popup('You entered', filename) ``` -------------------------------- ### Defining a Sized Text Element with Key (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This snippet shows how to define a `sg.Text` element within a layout. It specifies the element's size in characters (width, height) and assigns a unique `key` which allows the element to be easily referenced and updated later in the code. ```python [sg.Text(size=(40,1), key='-OUTPUT-')], ``` -------------------------------- ### Closing a FreeSimpleGUI Window (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This line demonstrates the standard way to close a FreeSimpleGUI window, releasing system resources. It is typically called after the main event loop has finished. ```python window.close() ``` -------------------------------- ### Updating Text Element Content and Color (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md Building upon the basic update, this snippet shows how to change multiple properties of an element using the `update` method. Here, it updates both the text content and sets the `text_color` parameter to 'yellow', demonstrating how to modify element appearance dynamically. ```python window['-OUTPUT-'].update('Hello ' + values['-INPUT-'] + "! Thanks for trying FreeSimpleGUI", text_color='yellow') ``` -------------------------------- ### Updating a Text Element Content (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This code demonstrates how to find a specific element in the window using its `key` (`-OUTPUT-`) and then call its `update` method to change its displayed text content. The new content is constructed by concatenating a greeting with the value entered by the user in another input element (`values['-INPUT-']`). ```python window['-OUTPUT-'].update('Hello ' + values['-INPUT-'] + "! Thanks for trying FreeSimpleGUI") ``` -------------------------------- ### Handling Window Close or Quit Event (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/docs/readme.md This conditional statement within the event loop checks the returned `event` value. If the event signifies the window was closed by the user (e.g., clicking the 'X') or if a button with the text 'Quit' was clicked, the `break` statement exits the loop, allowing the application to terminate. ```python if event == sg.WINDOW_CLOSED or event == 'Quit': break ``` -------------------------------- ### Creating and Reading FreeSimpleGUIWx System Tray Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWx/readme.md Initializes a FreeSimpleGUIWx SystemTray object with a context menu and icon, displays a startup message, and enters a blocking loop to read events from the tray icon or its menu. The loop prints the event and breaks if the 'Exit' menu item is selected. ```python import FreeSimpleGUIWx as sg tray = sg.SystemTray(menu=['menu', ['Open', ['&Save::KEY', '---', 'Issues', '!Disabled'], 'E&xit']], filename=r'C:\Python\PycharmProjects\GooeyGUI\default_icon.ico') tray.ShowMessage('My Message', 'The tray icon is up and runnning!') while True: event = tray.Read() print(event) if event == 'Exit': break ``` -------------------------------- ### Initializing FreeSimpleGUIQt SystemTray Object Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Defines the constructor signature and parameters for the SystemTray object in FreeSimpleGUIQt. It lists the parameters used to configure the system tray icon, including menu definition, icon source (filename, in-ram data, or base64), and tooltip text. ```python SystemTray(menu=None, filename=None, data=None, data_base64=None, tooltip=None): ''' SystemTray - create an icon in the system tray :param menu: Menu definition :param filename: filename for icon :param data: in-ram image for icon :param data_base64: basee-64 data for icon :param tooltip: tooltip string ''' ``` -------------------------------- ### Condensing FreeSimpleGUI Window Creation (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Illustrates how to combine layout definition, window creation, display, and event reading into a single line of Python code using FreeSimpleGUI, demonstrating its conciseness for simple GUI tasks. ```python event, values = sg.Window('Window Title', [[sg.Text("What's your name?")],[sg.Input()],[sg.Button('Ok')]]).read(close=True) ``` -------------------------------- ### Creating a One-Shot FreeSimpleGUI Window (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Demonstrates the structure of a simple FreeSimpleGUI program that displays a window, collects input once, and then closes. It covers importing the library, defining the layout, creating the window, reading events/values, and closing the window. ```python import FreeSimpleGUI as sg # Part 1 - The import # Define the window's contents layout = [ [sg.Text("What's your name?")], # Part 2 - The Layout [sg.Input()], [sg.Button('Ok')] ] # Create the window window = sg.Window('Window Title', layout) # Part 3 - Window Defintion # Display and interact with the Window event, values = window.read() # Part 4 - Event loop or Window.read call # Do something with the information gathered print('Hello', values[0], "! Thanks for trying FreeSimpleGUI") # Finish up by removing from the screen window.close() # Part 5 - Close the Window ``` -------------------------------- ### Creating an Interactive FreeSimpleGUI Window (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Shows how to create a FreeSimpleGUI window that remains open and responsive to user interactions using an event loop. It demonstrates handling window close events and button clicks to update elements within the window. ```python import FreeSimpleGUI as sg # Define the window's contents layout = [[sg.Text("What's your name?")], [sg.Input(key='-INPUT-')], [sg.Text(size=(40,1), key='-OUTPUT-')], [sg.Button('Ok'), sg.Button('Quit')]] # Create the window window = sg.Window('Window Title', layout) # Display and interact with the Window using an Event Loop while True: event, values = window.read() # See if user wants to quit or window was closed if event == sg.WINDOW_CLOSED or event == 'Quit': break # Output a message to the window window['-OUTPUT-'].update('Hello ' + values['-INPUT-'] + "! Thanks for trying FreeSimpleGUI") ``` -------------------------------- ### Switch PySimpleGUI Port (Backend) Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md This Python snippet illustrates how to switch between different PySimpleGUI backends (like tkinter or Qt) by commenting and uncommenting the respective import statements at the beginning of the script. ```Python from matplotlib import use # import FreeSimpleGUI as sg import FreeSimpleGUIQt as sg; use('qt5agg') ``` -------------------------------- ### Creating Button Grid with List Comprehension (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Shows how to leverage Python's list comprehension to efficiently create a complex layout, specifically a 4x4 grid of buttons, in just a few lines of code using FreeSimpleGUI. This requires importing the FreeSimpleGUI library. ```python import FreeSimpleGUI as sg layout = [[sg.Button(f'{row}, {col}') for col in range(4)] for row in range(4)] event, values = sg.Window('List Comprehensions', layout).read(close=True) ``` -------------------------------- ### Creating Windows EXE with PyInstaller Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md This bash command uses PyInstaller to bundle a Python script (`my_program.py`) into a single, standalone Windows executable (`my_program.exe`). The `-wF` flags ensure a windowed application is created (`-w`) and that all dependencies are bundled into one file (`-F`). The resulting executable is placed in a 'dist' subdirectory. ```bash pyinstaller -wF my_program.py ``` -------------------------------- ### Reading SystemTray Menu Events in FreeSimpleGUIQt Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Documents the Read method of the FreeSimpleGUIQt SystemTray object. It explains the optional timeout parameter for controlling blocking behavior and describes the return value, which is the string representation of the chosen menu item, including any associated key. ```python def Read(timeout=None) ''' Reads the context menu :param timeout: Optional. Any value other than None indicates a non-blocking read :return: String representing meny item chosen. None if nothing read. ''' ``` -------------------------------- ### Importing FreeSimpleGUIQt in Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Standard Python import statement to use the FreeSimpleGUIQt library, aliasing it as sg for convenience, following common FreeSimpleGUI practice. ```python import FreeSimpleGUIQt as sg ``` -------------------------------- ### Defining Menu Structure in FreeSimpleGUIQt Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Illustrates the list-based format for defining menus in FreeSimpleGUIQt. It shows how to create nested submenus, add separators ('---'), specify keyboard shortcuts using '&', add unique keys using '::', and disable menu items using '!'. ```python menu_def = ['BLANK', ['&Open', '&Save', ['1', '2', ['a', 'b']], '!&Properties', 'E&xit']] ``` -------------------------------- ### Creating Mac App with PyInstaller (Basic) Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md This PyInstaller command attempts to create a standalone Mac application (.app) from a Python script (`your_program.py`). It uses the `--onefile` option and includes the Tk and Tcl frameworks, which are often required dependencies for PySimpleGUI applications using the Tkinter backend. ```bash pyinstaller --onefile --add-binary='/System/Library/Frameworks/Tk.framework/Tk':'tk' --add-binary='/System/Library/Frameworks/Tcl.framework/Tcl':'tcl' your_program.py ``` -------------------------------- ### Creating Mac App with PyInstaller (Windowed) Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md Similar to the previous command, this PyInstaller command creates a standalone Mac application but adds the `--windowed` option. This prevents a separate console window from opening when the application is launched, providing a cleaner user experience for GUI applications. It also includes the necessary Tk and Tcl frameworks. ```bash pyinstaller --onefile --add-binary='/System/Library/Frameworks/Tk.framework/Tk':'tk' --windowed --add-binary='/System/Library/Frameworks/Tcl.framework/Tcl':'tcl' your_program.py ``` -------------------------------- ### Condensing FreeSimpleGUI Window with Aliases (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Shows the same single-line window creation as the previous snippet but utilizes FreeSimpleGUI's shorthand aliases (e.g., `T` for `Text`, `I` for `Input`, `B` for `Button`) to further reduce code length and improve conciseness. ```python event, values = sg.Window('Window Title', [[sg.T("What's your name?")],[sg.I()],[sg.B('Ok')]]).read(close=True) ``` -------------------------------- ### FreeSimpleGUIWx SystemTray ShowMessage Method Signature Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWx/readme.md Defines the signature for the `ShowMessage` method of the FreeSimpleGUIWx SystemTray object. This method displays a balloon message above the system tray icon with a specified title, message, and optional icon and display time. ```python ShowMessage(title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000): ''' Shows a balloon above icon in system tray :param title: Title shown in balloon :param message: Message to be displayed :param filename: Optional icon filename :param data: Optional in-ram icon :param data_base64: Optional base64 icon :param time: How long to display message in milliseconds :return: ''' ``` -------------------------------- ### Migrating from PySimpleGUI to FreeSimpleGUI (Diff) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Shows the minimal code change required to switch from using PySimpleGUI to FreeSimpleGUI. It highlights replacing the import statement. ```diff - import PySimpleGUI as sg + import FreeSimpleGUI as sg ``` -------------------------------- ### Showing SystemTray Icon (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Shows a system tray icon that was previously hidden using the Hide or Close methods. ```python def UnHide() ``` -------------------------------- ### Showing SystemTray Message (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Displays a balloon message above the system tray icon. Allows customization of title, message, icon (via filename, data, or base64), preset icon type, and display duration. ```python ShowMessage(title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000): ''' Shows a balloon above icon in system tray :param title: Title shown in balloon :param message: Message to be displayed :param filename: Optional icon filename :param data: Optional in-ram icon :param data_base64: Optional base64 icon :param time: How long to display message in milliseconds :return: ''' ``` -------------------------------- ### FreeSimpleGUIWx SystemTray Update Method Signature Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWx/readme.md Defines the signature for the `Update` method of the FreeSimpleGUIWx SystemTray object. This method allows updating the tray's properties such as the menu definition, tooltip text, or icon image. ```python Update(menu=None, tooltip=None,filename=None, data=None, data_base64=None,) ''' Updates the menu, tooltip or icon :param menu: menu defintion :param tooltip: string representing tooltip :param filename: icon filename :param data: icon raw image :param data_base64: icon base 64 image :return: ''' ``` -------------------------------- ### FreeSimpleGUIWx SystemTray Read Method Signature Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWx/readme.md Defines the signature for the `Read` method of the FreeSimpleGUIWx SystemTray object. This method reads events from the system tray, such as menu selections or icon clicks. It can be blocking or non-blocking depending on the `timeout` parameter. ```python def Read(timeout=None) ''' Reads the context menu :param timeout: Optional. Any value other than None indicates a non-blocking read :return: String representing meny item chosen. None if nothing read. ''' ``` -------------------------------- ### Updating SystemTray Properties (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Updates properties of the system tray icon, including the menu definition, tooltip text, or the icon image itself. Any combination of these properties can be updated in a single call. ```python Update(menu=None, tooltip=None,filename=None, data=None, data_base64=None,): ''' Updates the menu, tooltip or icon :param menu: menu defintion :param tooltip: string representing tooltip :param filename: icon filename :param data: icon raw image :param data_base64: icon base 64 image :return: ''' ``` -------------------------------- ### Setting Theme in FreeSimpleGUI (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md This snippet demonstrates how to import the FreeSimpleGUI library and set a global theme for all subsequent windows created in the application. Calling `sg.theme()` with a theme name changes the default colors and appearance of GUI elements. ```python import FreeSimpleGUI as sg sg.theme('dark grey 9') ``` -------------------------------- ### Defining FreeSimpleGUI Layout with Rows (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Demonstrates the basic 'list of lists' structure for defining a FreeSimpleGUI window layout. Each inner list represents a row containing elements like `sg.Text` and `sg.Input`, illustrating how rows are structured. ```python layout = [ [sg.Text('Row 1'), sg.Text("What's your name?")], [sg.Text('Row 2'), sg.Input()], [sg.Text('Row 3'), sg.Button('Ok')] ] ``` -------------------------------- ### Create Rainmeter-Style Window (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Shows how to customize a FreeSimpleGUI window to remove the title bar and set transparency, creating a 'Rainmeter-style' appearance. This is achieved by setting the `no_titlebar` and `alpha_channel` parameters during window creation. ```python window = sg.Window('My window', layout, no_titlebar=True, alpha_channel=0.5) ``` -------------------------------- ### Defining a Blank Text Element with Key and Size (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Defines a blank Text element within the layout. It uses the 'size' parameter to set its dimensions in characters (width, height) and assigns a 'key' for easy reference later in the code. ```Python [sg.Text(size=(40,1), key='-OUTPUT-')], ``` -------------------------------- ### Import FreeSimpleGUIWeb in Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIWeb/readme.md Imports the FreeSimpleGUIWeb library into a Python script, typically aliasing it as 'sg'. This allows you to use FreeSimpleGUI functions and elements in your web application. ```Python import FreeSimpleGUIWeb as sg ``` -------------------------------- ### Redirecting Python Print to FreeSimpleGUI Window Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md This Python snippet replaces the standard `print` function with `sg.Print` from FreeSimpleGUI. After executing these lines, all subsequent calls to `print` will display their output in a scrolling GUI window provided by FreeSimpleGUI, which is useful for debugging GUI applications. ```python import FreeSimpleGUI as sg print = sg.Print ``` -------------------------------- ### Upgrade FreeSimpleGUI via pip (Windows) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Upgrades the FreeSimpleGUI package using pip as a Python module. The --upgrade flag performs the upgrade, and --no-cache-dir prevents caching. This command is suggested for Windows systems. ```Shell python -m pip install --upgrade --no-cache-dir FreeSimpleGUI ``` -------------------------------- ### Update PySimpleGUI Element Value (New Convention) Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md This snippet shows the current, preferred method for updating the value of a PySimpleGUI element using dictionary-style access `[]`. ```Python window['status'].Update(event) ``` -------------------------------- ### Upgrade FreeSimpleGUI via pip (Linux/MacOS) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Upgrades the FreeSimpleGUI package using pip as a Python module. The --upgrade flag performs the upgrade, and --no-cache-dir prevents caching. This command is suggested for Linux and MacOS systems. ```Shell python3 -m pip install --upgrade --no-cache-dir FreeSimpleGUI ``` -------------------------------- ### Closing SystemTray Icon (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Closes the system tray icon. This method performs the same action as the Hide method. ```python def Close() ``` -------------------------------- ### Update PySimpleGUI Element Value (Old Convention) Source: https://github.com/spyoungtech/freesimplegui/blob/main/DemoPrograms/readme.md This snippet shows the older method for updating the value of a PySimpleGUI element using the `FindElement` method. ```Python window.FindElement('status').Update(event) ``` -------------------------------- ### Updating a Text Element with Input Value (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Locates the element with the key '-OUTPUT-' and calls its 'update' method to change its displayed text. The new text is a string concatenated with the value entered by the user in the element with the key '-INPUT-'. ```Python window['-OUTPUT-'].update('Hello ' + values['-INPUT-'] + "! Thanks for trying FreeSimpleGUI") ``` -------------------------------- ### Cleanly Closing PySimpleGUI Windows with Threads - Python Source: https://github.com/spyoungtech/freesimplegui/blob/main/readme_creator/markdown input files/3_FOOTER.md This snippet demonstrates the recommended sequence for closing a PySimpleGUI window when running in a multi-threaded application to prevent the 'Tcl_AsyncDelete' error. It involves closing the window, setting the layout and window variables to None, and explicitly triggering Python's garbage collection using the 'gc' module. This ensures Tkinter widgets are cleaned up in the main thread context. ```python import gc # Do all your windows stuff... make a layout... show your window... then when time to exit window.close() layout = None window = None gc.collect() ``` -------------------------------- ### Updating Text Element Content and Color (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md Similar to the previous snippet, this updates the content of the '-OUTPUT-' Text element. Additionally, it uses the 'text_color' parameter in the 'update' method to change the color of the displayed text to yellow. ```Python window['-OUTPUT-'].update('Hello ' + values['-INPUT-'] + "! Thanks for trying FreeSimpleGUI", text_color='yellow') ``` -------------------------------- ### Hiding SystemTray Icon (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/FreeSimpleGUIQt/readme.md Hides the system tray icon. Note that message balloons are not shown while the icon is hidden. ```python def Hide() ``` -------------------------------- ### Closing the FreeSimpleGUI Window (Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md This line of code is typically placed after the main event loop finishes to properly close and clean up the FreeSimpleGUI window. ```Python window.close() ``` -------------------------------- ### Handling Window Close or Quit Button Event (FreeSimpleGUI Python) Source: https://github.com/spyoungtech/freesimplegui/blob/main/README.md This conditional statement within the event loop checks if the event received is either the window being closed by the user (clicking the 'X') or the 'Quit' button being clicked. If either is true, the 'break' statement exits the loop. ```Python if event == sg.WINDOW_CLOSED or event == 'Quit': break ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.