May 2019
Intermediate to advanced
542 pages
13h 37m
English
If you don't mind a little conversion overhead during runtime, you can actually avoid the step of manually converting your .ui files by converting them on the fly inside your program using PyQt's uic library (on which pyuic5 is based).
Let's try this with our MainWindow GUI. Start by commenting out your import of Ui_MainWindow and importing uic, like so:
#from calendar_form import Ui_MainWindowfrom PyQt5 import uic
Then, before your MainWindow class definition, call uic.loadUiType(), as follows:
MW_Ui, MW_Base = uic.loadUiType('calendar_form.ui')
loadUiType() takes a path to the .ui file and returns a tuple containing the generated UI class and the Qt base class on which it is based (in this case, QWidget ...
Read now
Unlock full access