Designer for PySimpleGUI

Posted by


PySimpleGUI Designer is a powerful graphical user interface (GUI) builder for creating Python applications. With PySimpleGUI Designer, you can easily create and customize GUIs for your Python projects without writing a single line of code. In this tutorial, we will walk you through how to use PySimpleGUI Designer to create a simple GUI for a weather application.

Installing PySimpleGUI Designer

Before we get started, you will need to install PySimpleGUI Designer. You can install it using pip by running the following command:

pip install PySimpleGUI

Creating a new project

To start creating a new project in PySimpleGUI Designer, open the application and click on the "New" button in the top menu. This will create a new project with a blank window for your GUI.

Adding elements to the GUI

Next, you can start adding elements to your GUI by simply dragging and dropping them from the left panel onto the window. PySimpleGUI Designer provides a wide range of elements, such as buttons, text inputs, sliders, and checkboxes, that you can use to create your GUI.

For our weather application, let’s add a text input field for the user to enter a city name, a button to submit the city name, and a text output field to display the weather information.

To add a text input field, drag the "Input Text" element onto the window. You can customize the properties of the input field, such as its size and default text, by clicking on the element and adjusting the settings in the right panel.

Next, add a button to submit the city name by dragging the "Button" element onto the window. You can change the text displayed on the button by clicking on it and editing the "Text" property in the right panel.

Finally, add a text output field by dragging the "Output Element" element onto the window. This element will be used to display the weather information retrieved from the API.

Designing the GUI layout

Once you have added all the elements to your GUI, you can start designing the layout by arranging the elements on the window. You can move elements around the window by dragging them with your mouse and resize them by clicking on the element and adjusting its size.

For our weather application, let’s arrange the text input field at the top of the window, followed by the submit button, and then the text output field below the button.

Building the GUI

After you have designed the layout of your GUI, you can build it by clicking on the "Build" button in the top menu. This will generate the Python code for your GUI based on the elements and layout you have created in PySimpleGUI Designer.

You can copy the generated code and paste it into your Python script to use the GUI in your application. You can also export the GUI as a .py file by clicking on the "Export" button, which will create a standalone Python script for your GUI.

Adding functionality to the GUI

Now that you have created your GUI, you can add functionality to it by writing Python code to handle user inputs and perform actions, such as retrieving weather information based on the city name entered by the user.

For our weather application, you can use an API like OpenWeatherMap to retrieve the weather information for the specified city. You can write a function that makes a request to the API using the city name entered by the user and displays the weather information in the text output field.

import requests

def get_weather(city):
    api_key = 'your_api_key'
    url = f'https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric'
    response = requests.get(url)
    data = response.json()
    weather = data['weather'][0]['description']
    temperature = data['main']['temp']
    return f'The weather in {city} is {weather} with a temperature of {temperature}°C'

# Add event handler for button click
while True:
    event, values = window.read()
    if event == 'Submit':
        city = values['city_input']
        weather_info = get_weather(city)
        window['output'].update(weather_info)

In this example, we define a function get_weather that makes a request to the OpenWeatherMap API using the city name entered by the user and retrieves the weather information for that city. We then use an event handler to call this function when the submit button is clicked and display the weather information in the text output field.

Running the GUI

You can run your GUI by executing the Python script that contains the code generated by PySimpleGUI Designer. This will open the GUI window on your screen, where you can interact with the elements and see the output based on the functionality you have implemented.

In this tutorial, we have covered the basics of using PySimpleGUI Designer to create a simple GUI for a weather application. With PySimpleGUI Designer, you can easily design, build, and customize GUIs for your Python projects without writing code, making it a valuable tool for developers of all skill levels.

0 0 votes
Article Rating

Leave a Reply

34 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@somebellguy
18 days ago

This is great! Also, I spit out my coffee at 0:20

@johncongerton7046
18 days ago

Genius

@mirthmagic6370
18 days ago

This only shows how IMMATURE modern packages are. Clarion, Visual FoxPro, Borland Delphi, Visual Basic, Visial C++ came with everything needed since version one in 90-th.

@suretmeyenateistoc4252
18 days ago

pip install PySimpleGUIDesigner and PySide2
fish: Unknown command: PySimpleGUIDesigner why ??

@Leao_da_Montanha
18 days ago

congratulations thats a fenomenal tool

@Esp1fs
18 days ago

how I run it?? where should I type PySimpleGUIDesigner?? in Vs Code? Terminal?

@ViniciusSchneiderRS
18 days ago

PySimpleGUIDesigner

Traceback (most recent call last):

File "/home/pi/.local/bin/PySimpleGUIDesigner", line 5, in <module>

from PySimpleGUIDesigner.main import cli

File "/home/pi/.local/lib/python3.9/site-packages/PySimpleGUIDesigner/main.py", line 13, in <module>

from .transpiler2 import *

File "/home/pi/.local/lib/python3.9/site-packages/PySimpleGUIDesigner/transpiler2.py", line 1, in <module>

from PySide2 import QtCore, QtGui, QtWidget

@qbukhari
18 days ago

I can't pass the first window asking for xml file. Please help

I have changed git but no use. Kindly tell steps what to do

@qbukhari
18 days ago

Thank you

@user-ix7lb1sx4k
18 days ago

Здравствуйте. Можно ли работать с PySimpleGUI Designer без использования ООП? Нет ли обучающего материала на русском по полному созданию какой нибудь простенькой программы? Какую версию PyQt надо устанавливать?

@SolidBuildersInc
18 days ago

Great Video,
Question,
How did you handle your Multi-Tab in your example?
Isn't that considered a "float", if not, what is a float to not break the rule?
In your example it appears you had a Multi -Tab form, but I don't think there was an explanation on how they are named…..
Do you place the tab in a group or container?
Not sure how you did this, but it's what I am looking for.
Thanks for any feedback……

@burnsy8799
18 days ago

i am also having this problem with "no obj_name=groupBox found". i am using pyside2 and dont have PyQt5 installed. i am also using the PySimpleGUIDesigner and it wont convert. any idea on what my problem might be?

@SomeeOne123
18 days ago

Hey so i installed it using pip and am trying to run it by just typing PySimpleGUIDesigner but it doesnt work, "'PySimpleGUIDesigner' is not recognized as an internal or external command, operable program or batch file." how to i fix this?

@abarlow7723
18 days ago

Does this run on Macintosh too? My Mac seemed to be successful with the PIP install, but when I run it, ( PySimpleGUIDesigner), I get a screen that looks entirely different than your tutorial here, and it seem to b dead.

@criblaj
18 days ago

after pip install not sure hot to run it …

@josea.caceresprado2918
18 days ago

But is PyQt not PySimpleGUI

@franek4always
18 days ago

When I try start to convert I receive an error:

Error:
'PySide2.QtWidgets.QTextEdit' object has no attribute 'text'

@user-de3wr9fw1v
18 days ago

can not run PySimpleGUIDesigner, error info:
File "d:anaconda3librunpy.py", line 194, in _run_module_as_main

return _run_code(code, main_globals, None,

File "d:anaconda3librunpy.py", line 87, in _run_code

exec(code, run_globals)

File "D:anaconda3ScriptsPySimpleGUIDesigner.exe__main__.py", line 4, in <module>

File "d:anaconda3libsite-packagesPySimpleGUIDesignermain.py", line 5, in <module>

from .transpiler2 import *

File "d:anaconda3libsite-packagesPySimpleGUIDesignertranspiler2.py", line 1, in <module>

from PySide2 import QtCore, QtGui, QtWidgets

File "d:anaconda3libsite-packagesPySide2__init__.py", line 107, in <module>

_setupQtDirectories()

File "d:anaconda3libsite-packagesPySide2__init__.py", line 58, in _setupQtDirectories

import shiboken2

File "d:anaconda3libsite-packagesshiboken2__init__.py", line 30, in <module>

_init_pyside_extension()

NameError: name '_init_pyside_extension' is not defined

@markconger8049
18 days ago

Is PySimpleGUIDesigner actively being developed? There are no updates in 3 months.

Google Translate into Russian:

Активно ли разрабатывается PySimpleGUI Designer? За 3 месяца обновлений нет.

@dann1kid
18 days ago

1 вопрос – что за плагин на сублайм с нитками?

34
0
Would love your thoughts, please comment.x
()
x