https://github.com/alejandroautalan/pygubu-designer
A simple GUI designer for the python tkinter module
https://github.com/alejandroautalan/pygubu-designer
python-gui-development python-gui-programming tkinter tkinter-graphic-interface tkinter-gui tkinter-python
Last synced: about 1 month ago
JSON representation
A simple GUI designer for the python tkinter module
- Host: GitHub
- URL: https://github.com/alejandroautalan/pygubu-designer
- Owner: alejandroautalan
- License: gpl-3.0
- Created: 2020-04-06T16:41:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-05-06T03:15:45.000Z (about 1 month ago)
- Last Synced: 2025-05-06T04:25:07.420Z (about 1 month ago)
- Topics: python-gui-development, python-gui-programming, tkinter, tkinter-graphic-interface, tkinter-gui, tkinter-python
- Language: Python
- Homepage:
- Size: 3.48 MB
- Stars: 950
- Watchers: 24
- Forks: 109
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Authors: AUTHORS
Awesome Lists containing this project
README
[Leer en Español](Documentation/README/es.md). More translations [here](Documentation/README)
Welcome to Pygubu!
============================================`Pygubu` is a [RAD tool](https://en.wikipedia.org/wiki/Rapid_application_development) to enable _quick_ and _easy development of user interfaces_ for the Python's `tkinter` module.
The user interfaces designed are saved as [XML](https://en.wikipedia.org/wiki/XML) files, and, by using the _pygubu builder_, these can be loaded by applications dynamically as needed.
Pygubu is inspired by [Glade](https://gitlab.gnome.org/GNOME/glade).
Installation
============The latest version of pygubu requires Python >= 3.8
You can install pygubu-designer using:
### pip
```
pip install pygubu-designer
```
### Arch Linux ([AUR](https://aur.archlinux.org/packages/pygubu-designer))
```
yay pygubu-designer
```
### Notes for Windows Users:If your Python installation directory contains spaces (e.g., `C:\Program Files\Python312`), you may encounter errors. Use one of the following solutions:
1. Use quotation marks when running commands:
```
"C:\Program Files\Python312\Scripts\pygubu-designer.exe"
```2. Add Python to your system's PATH:
- Open **System Properties** > **Environment Variables**.
- Under **System Variables**, select `Path` > **Edit**.
- Add the path to your Python installation (e.g., `C:\Program Files\Python312`).3. Use the short pathname format for directories with spaces:
```
C:\PROGRA~1\Python312\Scripts\pygubu-designer.exe
```Screenshot
==========
Usage
=====Type on the terminal one of the following commands depending on your system.
### Unix-like systems
```
pygubu-designer
```### Windows
```
C:\Python3\Scripts\pygubu-designer.exe
```Where `C:\Python3` is the path to **your** Python installation directory.
Now, you can start creating your tkinter application using the widgets that you
find in the top panel called `Widget Palette`.After you finished creating your _UI definition_, save it to a `.ui` file by
going to the top menu `File > Save`.The following is a UI definition example called
[helloworld.ui](examples/helloworld/helloworld.ui) created using pygubu:```xml
200
both
Hello World App
200
200
20
200
true
top
center
Helvetica 26
#0000b8
Hello World !
top
```
Then, you should create your _application script_ as shown below
([helloworld.py](examples/helloworld/helloworld.py)):```python
# helloworld.py
import pathlib
import tkinter as tk
import tkinter.ttk as ttk
import pygubuPROJECT_PATH = pathlib.Path(__file__).parent
PROJECT_UI = PROJECT_PATH / "helloworld.ui"class HelloworldApp:
def __init__(self, master=None):
# 1: Create a builder and setup resources path (if you have images)
self.builder = builder = pygubu.Builder()
builder.add_resource_path(PROJECT_PATH)# 2: Load an ui file
builder.add_from_file(PROJECT_UI)# 3: Create the mainwindow
self.mainwindow = builder.get_object('mainwindow', master)# 4: Connect callbacks
builder.connect_callbacks(self)def run(self):
self.mainwindow.mainloop()if __name__ == '__main__':
app = HelloworldApp()
app.run()```
Note that instead of `helloworld.ui` in the following line:
```python
PROJECT_UI = PROJECT_PATH / "helloworld.ui"
```You should insert the _filename_ (or path) of your just saved UI definition.
Note also that instead of `'mainwindow'` in the following line:
```python
self.mainwindow = builder.get_object('mainwindow', master)
```You should have the name of your _main widget_ (the parent of all widgets),
otherwise you will get an error similar to the following:Exception: Widget not defined.
See [this](https://github.com/alejandroautalan/pygubu/issues/40) issue for
more information.Documentation
=============Visit the [wiki](https://github.com/alejandroautalan/pygubu-designer/wiki) for
more documentation.The following are some good tkinter (and tk) references:
- [TkDocs](http://www.tkdocs.com)
- [Graphical User Interfaces with Tk](https://docs.python.org/3/library/tk.html)
- [Tkinter 8.5 reference: a GUI for Python](https://tkdocs.com/shipman)
- [An Introduction to Tkinter](http://effbot.org/tkinterbook) [(archive)](http://web.archive.org/web/20200504141939/http://www.effbot.org/tkinterbook)
- [Tcl/Tk 8.5 Manual](http://www.tcl.tk/man/tcl8.5/)You can also see the [examples](examples) directory or watch [this introductory video tutorial](http://youtu.be/wuzV9P8geDg).
History
=======See the list of changes [here](HISTORY.md).