How to Build Python GUI with PySimpleGUI

In this lesson we want to learn  How to Build Python GUI with PySimpleGUI, PySimpleGUI is Python package that makes it easy to create graphical user interfaces (GUIs) for your Python programs. this is an example of how to create simple GUI using PySimpleGUI:


  1. First, install the PySimpleGUI package using pip:


  1. Next, import the package:



  1. Now, create layout for your GUI. You can use the sg.Layout method to create layout using the element types provided by the package, such as buttons, text boxes and labels. for example:


  1. Create the window by calling sg.Window method and passing in the layout title for the window and any other optional parameters you want to specify. for example:



  1. Use read method to handle user input and events in the window. for example following code will display the window and wait for the user to click the OK or Cancel button:



  1. Use an if statement to check the value of  event variable, and then perform the appropriate action based on the button that was clicked. for example:



  1. Close the window with close() method



This is just basic example of how to create GUI using PySimpleGUI. you can also add more elements to your layout, create custom styles for your elements and handle more complex events and user input.

You can find more information about PySimpleGUI on the package’s website, which includes documentation and a lot of examples.


This is an example of how you would create simple window with label, an input text and two buttons, when clicking on the OK button the program will print the text written in the input box and if you click the cancel button it will print goodbye.



Run the complete code and this will be the result 

How to Build Python GUI with PySimpleGUI
How to Build Python GUI with PySimpleGUI



Learn More on Python GUI Development



What are the Pros and Cons of PySimpleGUI

PySimpleGUI is popular package for creating graphical user interfaces (GUIs) in Python. these are some pros and cons of using PySimpleGUI:


  • PySimpleGUI is easy to use even for beginners with little to no experience with GUI development.
  • PySimpleGUI has large different types of elements that can be used to create GUI including buttons, labels, text boxes and more.
  • PySimpleGUI supports different platforms such as Windows, Linux and macOS.
  • PySimpleGUI is lightweight and has small footprint.
  • PySimpleGUI has good documentation and a lot of examples.



  • PySimpleGUI is wrapper for tkinter, wxPython and PyQt, so it might not have the same level of customization as working directly with one of those frameworks.
  • PySimpleGUI’s widgets are not as modern looking as other frameworks like Qt, so if you want more polished look it might not be the best option.
  • PySimpleGUI does not support mobile platforms like Android or iOS.
  • PySimpleGUI does not have designer that allows you to create the UI directly from visual editor.

In result we can say that PySimpleGUI is good choice for creating simple and lightweight GUIs for desktop applications. If you are looking for more feature rich framework, or need to support mobile platforms, you may want to consider other options like PyQt or Kivy.

Leave a Comment