Web Analytics Made Easy - Statcounter
Skip to content

PySimpleGUI Demo Programs

The PySimpleGUI Demo Programs are a collection of over 300 short complete programs that demonstrate how to use PySimpleGUI's features. They range from specific to an individual element to how to techniques for creating multi-window applications.

In addition to these programs, the Demo Program Browser is an application that aids in working with these programs by making it to easy to search, edit and run the Demo Programs.

Want to learn more about the Graph Element? Then use the Demo Browser to search for sg.Graph and you'll find all Demo Programs that use the Graph Element.

The Demo Programs make a great "starting point" for your application. Copy one of these and you've got a working program as a starting point. The Demo Programs follow the PySimpleGUI Coding Conventions so you'll be able to understand them more easily.

Obtaining the Demo Programs

There are 2 primary ways to get the Demo Programs and the Demo Browser:

  1. Pip install psgdemos
  2. Download the folder from GitHub / download the entire PySimpleGUI GitHub Repo

psgdemos PyPI Package

python -m pip install psgdemos

The quickest way to get all of the Demo Programs as well as the "Demo Program Browser" is to pip install them.

Once installed, launching the Demo Browser can be accomplished by typing psgdemos from the command line.

Downloading from GitHub

If you download the PySimpleGUI GitHub Repo, the Demo Programs are in the folder DemoPrograms. The Demo Browser is also in this folder and is named:

Browser_START_HERE_Demo_Programs_Browser.py

You can run this program from the command line or use a utility like psgshortcut to make a shortcut that you can pin to your taskbar or place on your desktop.

The Demo Browser

image

While this document explains using the Demo Browser with the PySimpleGUI Demo Programs, the program can be used to search, edit and run programs from any folder tree on your system.

It's not limited to PySimpleGUI Demo Programs. It's not even limited to Python files as there is an option to "Show ALL file types" so that any files can be searched.

There are 3 tasks that the Demo Browser performs:

  1. Finding files - by searching the filename or the contents of files
  2. Editing files - launches your editor, opening the chosen files
  3. Executing files - Run one or more files

Perhaps the best way to think of this program is that it's an easy way to search for file names or the contents of files in an entire tree of files on your hard disk.

Setup the Demo Browser

To change the settings click the "Settings" button.

You'll see a window like this one:

image

I've changed the theme to be "DarkGrey13" and checked "Use Advanced Interface". I know a number of users like "Dark Themes" so let's use a "dark grey 13" theme for this recipe and enable the advanced features.

After clicking OK the window changes to:

image

More Details on Settings

  • Fill in the input fields labeled Path to Demos and Editor Program
  • Path to Demos - Defaults to the location of the Demo when you run it the first time. You can leave unchanged if this program is going to remain with the other demos. Use an absolute path.
  • Editor Program - It is best to set up your editor in the PySimpleGUI System Settings. If you want to be able to use the "Edit" button in this browser to open and edit the demo programs, then fill in the name of the .EXE (for windows) of your editor/IDE. If you have set up an editor in the global settings for PySimpleGUI, then you don't need to set up an editor in the browser demo.
    • PyCharm
      • Windows - it's not an EXE but a batch file. It will look something like this: C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\bin\pycharm.bat
      • Linux - it's a bit trickier. It may resemble something like this: /home/mike/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/202.8194.15/bin/pycharm.sh
      • Mac - I dunno yet.... there's an open Issue on GitHub asking for help from Mac user
    • Notepad++
      • Windows - Something along the lines of C:\Program Files\NotePad++\notepad++.exe
    • Notepad
      • Windows - c:\windows\notepad
      • Linux - /usr/bin/notepad
    • Custom
      • Assuming your editor is invoked using "editor filename" when you can use any editor you wish by filling in the "Editor Program" field with a path to the editor executable

Editor Setup

It's going to be a much much better experience if you set up your editor in the PySimpleGUI System Settings. Setting it there will enable you to open your editor to the line number that matches your search. It also ables you to jump straight to lines in your code that PySimpleGUI finds an error on.

Window Sections

These are some of the important part of the window that are not as obvious as other parts.

download

Verbose Mode

Verbose mode will show you the full matching line from the file. This is handy for when you're looking for a specific way something is used.

By default the Verbose mode is turned off. This is because search results are updated in realtime as you type characters. If your project tree is large then your verbose output will be very very large as you type the first few characters of your search.

The best way to use the Verbose feature is to perform the search with it turned off. Once you get the list of files from your search, then click verbose to see the more detailed view of the results.

In this example, I've searched for the demos that use the Image element. Searching for "sg.Image(" will return the demos that make this element.

download

If I then uncheck the "Show only first match in file" then I can see when multiple matches are found in a file.

download

If verbose mode is on and all matches are shown, when a file is selected from the list and the "Edit" button is clicked, then another window will show you the list of lines that matched and allow you to click on the line to be taken to. Selecting a line will open your editor to that line.

"Open Folder" feature

If you have an explorer program specified in the settings or in the PySimpleGUI Global Settings, then choosing a file and clicking the "Open Folder" button will launch the file browser that you've specified and open the folder that the file is contained in.

"Copy Path" feature

If you highlight a file in the file list and click the "Copy Path" button, then the full, absolute path to that file will be copied to the clipboard. This is handy if you want to paste the filename into a Python program.

Show All file types

You can use the Demo Browser to search not only your own projects, but you can also use it to search file types other than .py and .pyw. Check the Show ALL File Types checkbox at the bottom of the window to enable all files to be displayed and searched.

image

Setting The Location of Your Source Tree

You can add as many paths as you want via the settings window. The "Path to Tree" field is where you can either use the "Folder Browse" button to browse to your folder of programs or you can paste the path into the Combobox that you see under the Path to Tree heading. This path will also appear at the top of the main window as shown in one of the above images.

This tool is particularly good for navigating other people's PySimpleGUI projects / repos. Simply download their repo and paste the path to it in the Combobox.