Hello, World! Example - alejandroautalan/pygubu-designer GitHub Wiki
Overview
The traditional way to check that your development environment is functioning is to make a "Hello, World!" application.
Key Concepts
- basic functionality
Design Steps
- Launch the designer or if already running use 'File' to start a 'New' project.
- Go to Components Palette > Containers, double-click tk.Tk item. A blue box should appear in the preview.
- With the "Tk" item selected in the Project Tree, navigate to Properties Panel > Appearance, locate the minsize property and set its value to width 320 and height 240. Then locate the title property and set it to "Hello App".
- Whenever a top-level widget is used, it is recommended to have a main frame that will group the other widgets and provide more configuration options. So, go to Components Palette > Containers, double-click ttk.Frame item.
- With Frame selected in the Project Tree, go to Properties Panel > Layout tab and click on it. This is the Layout panel. Set property expand to true and fill "both". This will expand the frame using all the space.
- Next go to Components Palette > Control and Display, double-click ttk.Label widget. In the preview pane, you should now see 'label1'.
- In the properties pane, locate the text property.
- Replace 'label1' with 'Hello, World!'.
- Locate the font property and set the value to: "Helvetica" 26 bold.
- Locate the foreground property and set the value to "#0000b8"
- With the label selected in the Project Tree, got to Properties Panel > Layout tab. Set property expand to true. This will show the label centered in the preview.
- Before proceeding, ensure that your screen looks as follows.
debian 13 screen-shot of pygubu-designer v0.43
Preview Steps
- Click 'Preview' in the top menu bar of the designer.
- Select 'Preview in Toplevel'.
- Observe the following somewhere on your screen, and then close it.
debian 13 screen-shot of pygubu-designer v0.43
Generating the python application
For this, first you need to save the ui file.
-
Create a directory or project folder using your favorite file manager. In your Home folder, create the directory ~/projects/helloapp
-
Back to Pygubu Designer, go to File > Save. Choose the created folder and enter the filename "helloapp.ui" to save the UI definition.
-
Go to Project > Settings. The Project Settings dialog is shown.
-
In General section, configure name to "Hello App" and description to "A simple hello program"
-
Go to Code tab. Here we will use the classic app method using pygubu builder and the *.ui interface file.
-
In template select Application that uses UI file
-
For main widget select tk1
-
Leave module namespace empty.
-
Set module name to "helloapp"
-
Set class name to "HelloApp"
-
Leave output directory empty.

-
Click Ok button.
-
Go to File > Save, to save current changes.
-
Go to Project > Generate code.
-
In your folder, you should see two python files generated.
user@mylaptop:~/Projects$ tree helloapp/ helloapp/ ├── helloapp.py ├── helloapp.ui └── helloappui.py 1 directory, 3 files -
In a command terminal run the following:
python3 helloapp.py -
The hello world app is shown.