Skip to main content

A simple GUI designer for the python tkinter module

Project description

Leer en Español

Welcome to Pygubu!

Pygubu is a RAD tool to enable quick and easy development of user interfaces for the Python's tkinter module.

The user interfaces designed are saved as XML files, and, by using the pygubu builder, these can be loaded by applications dynamically as needed.

Pygubu is inspired by 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)

yay pygubu-designer

Screenshot

pygubu-desinger.png

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 created using pygubu:

<?xml version='1.0' encoding='utf-8'?>
<interface version="1.2">
  <object class="tk.Toplevel" id="mainwindow">
    <property name="height">200</property>
    <property name="resizable">both</property>
    <property name="title" translatable="yes">Hello World App</property>
    <property name="width">200</property>
    <child>
      <object class="ttk.Frame" id="mainframe">
        <property name="height">200</property>
        <property name="padding">20</property>
        <property name="width">200</property>
        <layout manager="pack">
          <property name="expand">true</property>
          <property name="side">top</property>
        </layout>
        <child>
          <object class="ttk.Label" id="label1">
            <property name="anchor">center</property>
            <property name="font">Helvetica 26</property>
            <property name="foreground">#0000b8</property>
            <property name="text" translatable="yes">Hello World !</property>
            <layout manager="pack">
              <property name="side">top</property>
            </layout>
          </object>
        </child>
      </object>
    </child>
  </object>
</interface>

Then, you should create your application script as shown below (helloworld.py):

# helloworld.py
import pathlib
import tkinter as tk
import tkinter.ttk as ttk
import pygubu

PROJECT_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:

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:

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 issue for more information.

Documentation

Visit the wiki for more documentation.

The following are some good tkinter (and tk) references:

You can also see the examples directory or watch this introductory video tutorial.

History

See the list of changes here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygubu_designer-0.39.3.tar.gz (961.6 kB view details)

Uploaded Source

Built Distribution

pygubu_designer-0.39.3-py3-none-any.whl (407.1 kB view details)

Uploaded Python 3

File details

Details for the file pygubu_designer-0.39.3.tar.gz.

File metadata

  • Download URL: pygubu_designer-0.39.3.tar.gz
  • Upload date:
  • Size: 961.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for pygubu_designer-0.39.3.tar.gz
Algorithm Hash digest
SHA256 ad3a6950307ec07684f165545748ebad1c61164ade67b3e74971098af09187df
MD5 f8cad2ff842e53944594667a8ab185e3
BLAKE2b-256 dab2026d217eafd29742d49d34933208878a712a381bae4fba87f65e55c18cc9

See more details on using hashes here.

File details

Details for the file pygubu_designer-0.39.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pygubu_designer-0.39.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7e95ab5818ad4f65767cf7739bb950253941b33943b622530ad05eeb3651dc6d
MD5 277e344cf9aea5a1ae748471e7c45e49
BLAKE2b-256 246ee2bf6cde45a3914eaceb9b1f14a7cfc3397b8b193ab07f6ac7e283a7dd63

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page