Package: pygubu-designer
Leer en EspañolWelcome to Pygubu!Pygubuis aRAD toolto enablequickandeasy development of user interfacesfor the Python'stkintermodule.The user interfaces designed are saved asXMLfiles, and, by using thepygubu builder, these can be loaded by applications dynamically as needed.Pygubu is inspired byGlade.InstallationThe latest version of pygubu requires Python >= 3.6You can install pygubu-designer using:pippip install pygubu-designerArch Linux (AUR)yay pygubu-designerScreenshotUsageType on the terminal one of the following commands depending on your system.Unix-like systemspygubu-designerWindowsC:\Python3\Scripts\pygubu-designer.exeWhereC:\Python3is the path toyourPython installation directory.Now, you can start creating your tkinter application using the widgets that you
find in the top panel calledWidget Palette.After you finished creating yourUI definition, save it to a.uifile by
going to the top menuFile > Save.The following is a UI definition example calledhelloworld.uicreated using pygubu:<?xml version='1.0' encoding='utf-8'?><interfaceversion="1.2"><objectclass="tk.Toplevel"id="mainwindow"><propertyname="height">200</property><propertyname="resizable">both</property><propertyname="title"translatable="yes">HelloWorldApp</property><propertyname="width">200</property><child><objectclass="ttk.Frame"id="mainframe"><propertyname="height">200</property><propertyname="padding">20</property><propertyname="width">200</property><layoutmanager="pack"><propertyname="expand">true</property><propertyname="side">top</property></layout><child><objectclass="ttk.Label"id="label1"><propertyname="anchor">center</property><propertyname="font">Helvetica26</property><propertyname="foreground">#0000b8</property><propertyname="text"translatable="yes">HelloWorld!</property><layoutmanager="pack"><propertyname="side">top</property></layout></object></child></object></child></object></interface>Then, you should create yourapplication scriptas shown below
(helloworld.py):# helloworld.pyimportpathlibimporttkinterastkimporttkinter.ttkasttkimportpygubuPROJECT_PATH=pathlib.Path(__file__).parentPROJECT_UI=PROJECT_PATH/"helloworld.ui"classHelloworldApp: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 filebuilder.add_from_file(PROJECT_UI)# 3: Create the mainwindowself.mainwindow=builder.get_object('mainwindow',master)# 4: Connect callbacksbuilder.connect_callbacks(self)defrun(self):self.mainwindow.mainloop()if__name__=='__main__':app=HelloworldApp()app.run()Note that instead ofhelloworld.uiin the following line:PROJECT_UI=PROJECT_PATH/"helloworld.ui"You should insert thefilename(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 yourmain widget(the parent of all widgets),
otherwise you will get an error similar to the following:Exception: Widget not defined.Seethisissue for
more information.DocumentationVisit thewikifor
more documentation.The following are some good tkinter (and tk) references:TkDocsGraphical User Interfaces with TkTkinter 8.5 reference: a GUI for PythonAn Introduction to Tkinter(archive)Tcl/Tk 8.5 ManualYou can also see theexamplesdirectory or watchthis introductory video tutorial.HistorySee the list of changeshere.