PySimple GUI: The simplest way of creating Graphical user interface with python

Vijaya Kumar Chinthala
3 min readNov 17, 2020

--

It is easy to use with simple yet HIGHLY customizable features of GUI for Python. It is based solely on Tkinter.

It is a Python GUI For Humans that Transforms Tkinter, PyQt, Remi, WxPython into portable user-friendly Pythonic interfaces

You can use Python and the PySimpleGUI package to create nice-looking user interfaces that you and your users will enjoy! PySimpleGUI is a new Python GUI library that has been gaining a lot of interest recently.

Installing PySimpleGUI

Creating Basic UI Elements in PySimpleGUI

You may have heard the term widgets. A widget is a generic term used to describe the elements that make up the user interface (UI), such as buttons, labels, windows, and more. In PySimpleGUI, widgets are referred to as elements, which you may sometimes see capitalized elsewhere as Elements.

Program 1: Let us write a program to create a simple GUI with title Hello World

Output:

One of the basic building blocks of PySimpleGUI is the Window()

Window() takes lots of different arguments—too many to be listed here. However,in the above code we haveWindow() a title and a layout and set the margins, which is how big the UI window will be in pixels.

In thetitle we gave the string Hello World and same is displayed as title of window.

Program 2: Let us write a program to create a simple GUI with title Hello World and two elements text and button.

Output:

PySimpleGUI uses nested Python lists to lay out its elements. In this case, you add a Text() element and a Button() element. Then you create the window and pass in your custom layout.

The last block of code is the event loop. A graphical user interface needs to run inside a loop and wait for the user to do something. For example, the user might need to press a button in your UI or type something with their keyboard. When they do that, those events are processed by the event loop.

When you use PySimpleGUI, you make an event loop by creating an infinite while loop that reads events from the window object. If the user presses the OK button or the Exit button, then you want the program to end. To accomplish that, you break out of the loop and close() the window.

--

--