Web Analytics Made Easy - Statcounter
Skip to content

Goal 1 - "You Have Fun"

Many of the topics pertaining to programming are "subjective". What does that mean? One definition stated:

"based on a person's experience, understanding and feelings; personal or individual"

"An opinion" is maybe the easiest to understand the "subjective" definition.

In programming, almost everything is subjective. There rarely is a "best". PySimpleGUI is not the "best Python GUI". There are so many variables involved in programming that making a simple, blanket statement is not possible. Your skill level is one important variable. Others include the operating system/environment, the time you have to write the code, the speed of the target machine, the project requirements, etc.

Just as there's no "best" answer for GUI frameworks, the same holds true for "fun". What's fun for you may be different than what's fun for me. How then can "You have fun" be a goal? Maybe this list has a few things you think would be fun..

PySimpleGUI is Fun Because

  • It's easy to install
  • It is fundamentally simple and thus quick to learn
  • A complete beginner can build an impressive application
  • You build your application incrementally
  • The architecture is linear, like the human brain likes it
  • There is a lot of documentation
  • Over 300 ready to run programs are available as starting points
  • Support is available for everyone
  • The code is compact and the syntax is consistent
  • Documentation is built into the code and integrates with your IDE
  • Every type of GUI widget is available
  • An entire program can be 1 line of code
  • You get to use the fun features of Python like list comprehensions
  • Activities related to GUI programming have also been simplified
  • The amount of code is 1/10 to 1/2 of other frameworks
  • Object-oriented development is not mandated
  • Can be highly customized to match your desired look and feel
  • The long, tedious, boilerplate code is done for you. You are left with the fun part.
  • PySimpleGUI was designed to maximize your enjoyment & success
  • Frustration is rare
  • Help is available
  • 10,000's of users from around the world have said it is

GUIs Traditionally Aren't "Fun"

Unlike "simplified" GUI packages, PySimpleGUI has a full set of "widgets". PySimpleGUI implements all of the major widgets you expect in a professional desktop library... text, button, sliders, menus, spinboxes, drop-downs, yadda, yadda. It's got 32 "Elements", the term used in PySimpleGUI instead of "Widgets", and the term we'll use from here on out. This window has your basic pallet of Elements.

image

"Verbose" is maybe the best summary of what GUI code tends to be. There can be 100s of lines of code to make a straightforward window. Why is this? It's usually because of the tedious requirement to set each and every aspect of a GUI widget. The size, the colors, the font, the placement, .... , and many times each setting is 1 line of code. There is a lot of code needed to create a window. "Boilerplate" code is not something I've ever heard a single person say they just can't wait to write.

The Two Reasons PySimpleGUI Was Created

One...

This "lengthy code problem" is one of the two reason PySimpleGUI came to be. It's tiring, tedious, boring to write so much code that results in so little being accomplished.

PySimpleGUI cuts the code required to a shockingly small amount. One line of code can create a surprisingly complex user interface.

Here's a 1-line GUI to get the name of a pet and the type of animal it is. The line has been broken apart of readability. This one line of code displays a window with a custom set of elements, gets the input from your user and provides you with the data entered and the button clicked.

import PySimpleGUI as sg

event, values = sg.Window('My one line window', 
                          [[sg.Text('Name of your pet?'), sg.Input(size=15)],
                           [sg.Text('What kind of animal?'), sg.Combo(['Dog', 'Cat', 'Fish','Turtle','Bird','Lizard', 'Other'])], 
                           [sg.Ok(), sg.Cancel()]]).read(close=True)

one_line_example

Give it a try to see that indeed, this one line of code makes a functioning GUI window...

Two...

The second reason was the non-linear or asynchronous design traditional GUI frameworks use.

With most GUI frameworks, when something happens, when a button is clicked for example, a function in your code is called. This design results in code that is disjointed, spread out, and executes in what appears to be "non-linear" ways. In other words, your execution doesn't flow from top to bottom of your program. Execution jumps all over your file, running a little here, then returning, then running a little there.