Issue
I have an application where I can create the layout in pyqt designer which will make a .ui file. I also have a gui script that when running uses this .ui file.
I have been able to convert the .ui file into a .py file however I would like to have my code call the converted .py file.
summary:
main.ui file which is generated from pyqt designer
main.py file which is generated from main.ui
gui.py which uses main.ui as shown in code snip below
how could I make gui.py use main.py and not main.ui?
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.ui = uic.loadUi('main.ui', self)
Solution
Generated code consists of helper class, just import it, instantiate and call setupUi
in __init__
from main import Ui_MainWindow
class MainWindow(QtWidgets.QMainWindow)
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
ui = Ui_MainWindow()
ui.setupUi(self)
self.ui = ui
Answered By - mugiseyebrows
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.