PySimpleGUI
Developer(s) | M. Barnett |
---|---|
Initial release | 11 July 2018[1] |
Stable release | |
Repository | github |
Written in | Python |
Engine | |
Operating system | Cross-Platform |
License | GNU Lesser General Public License (LGPLV3+) |
Website | pypi |
Search PySimpleGUI on Amazon.
PySimpleGUI[edit]
PySimpleGUI is a wrapper to the Tkinter Python API that allows the programmer to utilize all the same UI elements as with Tkinter but with a more intuitive interface. PySimpleGUI was established in an effort to create a more user-friendly Python GUI development process. PySimpleGUI combines the most effective elements of packages like EasyGUI and WxSimpleGUI, and adds the ability to define custom layouts.[2]
Licensing[edit]
PySimpleGUI is OSI approved under the GNU LESSER GENERAL PUBLIC LICENSE V3 OR LATER (LGPLV3+).
Background[edit]
Launched in July, 2018, PySimpleGUI sought a solution to streamline the Python GUI development efforts and move users from the command line to a windowed / GUI experience.[1] The PySimpleGUI package is focused on the developer, allowing them to create a custom GUI with as concise code as possible.
Features[edit]
The PySimpleGUI functions can be split into “High Level” calls that enable the caller to perform input/output operations in a single function call, and “Custom GUI” capabilities. The high-level calls usually start with “Popup”. The most basic of these is Popup which displays a variable number of items in a pop-up window. They resemble the built-in “print” statement, taking any number of variables in any format and displaying them in a window. The Popup calls that gather user input include PopupGetText, PopupGetFile and PopupGetFolder. Custom GUIs are achieved by first creating a “GUI layout” that is used to create and display a Window. The GUI layout is composed of “Elements”, PySimpleGUI’s term for a GUI “Widget”.
Simplifying and compacting the code can be achieved by leveraging two of PySimpleGUI’s “shortcuts”. Element names can be written in a short-form format. It reduces the amount of text in the code without losing meaning.
A second shortcut mechanism is pre-defined buttons. These are buttons commonly found in all GUIs such as “ok”, “cancel”, “yes”. Rather than writing Button(‘ok’) a button shortcut allows writing Ok(*), Cancel(), Yes().
UI elements | Button-Shortcuts | Element abbreviations | ||
---|---|---|---|---|
Checkbox
Column FileBrowse Image InputCombo InputText Listbox Multiline Output |
ProgressBar
Radio ReadFormButton RealtimeButton SimpleButton Slider Spin Text |
FolderBrowse
Cancel Exit FileBrowse FileSaveAs FolderBrowse No OK Ok |
Quit
ReadFormButton RealtimeButton Save SimpleButton Submit Yes |
T = Text
Txt = Text In = InputText Input = IntputText Combo = InputCombo DropDown = InputCombo Drop = InputCombo |
The "High Level" API calls that output values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings.[3] For full list of features and how to implement them please refer to the PySimpleGUI CookBook.
Design Goals[edit]
PySimpleGUI's goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what is on the screen.[2]
Some examples of how this package attempts to use language constructs in a natural way and exploit some of Python's interesting features:
- Forms are represented as Python lists.
- A form is a list of rows
- A row is a list of elements
- Return values are a list of button presses and input values.
- Return values can also be represented as a dictionary
- The SDK calls collapse down into a single line of Python code that presents a custom GUI and returns values[4]
In addition to a Python-like API, the PYSimpleGUI documentation provides a number of example code snippets allowing developers in need to get up and running by copying, pasting, and sometimes modifying the code to create the desired GUI without needing to learn the library prior to use.[2]
Example[edit]
PySimpleGUI focuses on the creation of Python native UI in as simple code as possible. When creating UI with PySimpleGUI every call has optional parameters so that you can change the look and feel. Changing a button color can be done by adding a button_color parameter to your widget. The configure is done in-place.
With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line.
Hello World[edit]
import PySimpleGUI as sg
layout = [[sg.Text('Hello World!')],
[sg.Ok()]]
window = sg.Window('Wikipedia Window').Layout(layout)
event, data = window.Read()
Getting Started with PySimpleGUI[edit]
External links[edit]
For the latest news, configuring and getting started with PySimpleGUI you can refer to the GitHub project.
For a deeper look into the use of PySimpleGUI you can refer to the PySimpleGUI cookbook.
For a lower level look under the hood of PySimpleGUI refer to this explanation by the developer.[5]
Compatibility[edit]
- Python 2.7 tkinter
- Python 3 tkinter
- Qt
- Kivy (coming soon)
- WxPython (coming soon)
- RasberryPi (For examples running on a RasberryPi please refer to entries found on the Rasberrypi forums.[6])
- Windows
- Mac
- Linux
- PyPy3
References[edit]
- ↑ 1.0 1.1 1.2 "PySimpleGui". libraries.io. Retrieved 2018-09-07.
- ↑ 2.0 2.1 2.2 2.3 "PySimpleGUI". PyPI. Retrieved 2018-09-07.
- ↑ "Add GUIs to your programs and scripts easily with PySimpleGUI". Opensource.com. Retrieved 2018-09-07.
- ↑ "A simple yet powerful GUI built on top of tkinter". Python Awesome. 2018-07-19. Retrieved 2018-09-08.
- ↑ "PySimpleGui under the hood".
- ↑ "PySimpleGUI - New package for building custom GUIs in a few lines of code - Page 2 - Raspberry Pi Forums". www.raspberrypi.org. Retrieved 2018-09-08.
This article "PySimpleGUI" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:PySimpleGUI. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.