Issue
I have 2 forms, form_1
and form_2
(in another class
and file
), I'll open form_2
from form_1
with button,
How to create it in PyQT?
form_1
code :
def retranslateUi(self, MainWindow):
QtCore.QObject.connect(
self.bt_form1, QtCore.SIGNAL(_fromUtf8("clicked()")), self.show_form2())
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.bt_form1.setText(_translate("MainWindow", "FORM_1", None))
def show_form2(self):
self.form2 = form2(self) # in here ??????
Solution
I'm still pretty new to PyQT but I think you can do it like this -
def show_form2(self):
newDialog = uic.loadUi(r"uifile.ui")
newDialog.show()
or if you've subclassed it, make sure you import
it if it's in another file and use
def show_form2(self):
newDialog = subDialog.subDialog()
newDialog.show()
edit - oh and make sure you connect it to the buttons click
self.bt_form1.clicked.connect(self.show_form2)
Answered By - SketchyManDan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.