Okay, I think I kinda got it - I imported the class of the second form. This is somewhat the codes (but I changed the names of the classes mostly)
form1.py
from PyQt4.QtCore import pyqtSignature
from Ui_form1 import Ui_MainWindow
from ui.form2 import FormTwo
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
self.setupUi(self)
@pyqtSignature("")
def on_button_released(self):
"""
Slot documentation goes here.
"""
FT = FormTwo()
FT.show()
from PyQt4.QtGui import QMainWindow
from PyQt4.QtCore import pyqtSignature
from Ui_form1 import Ui_MainWindow
from ui.form2 import FormTwo
class FormOne(QMainWindow, Ui_MainWindow):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
QMainWindow.__init__(self, parent)
self.setupUi(self)
@pyqtSignature("")
def on_button_released(self):
"""
Slot documentation goes here.
"""
FT = FormTwo()
FT.show()
To copy to clipboard, switch view to plain text mode
form2.py
from PyQt4.QtCore import pyqtSignature
from Ui_form2 import Ui_Dialog
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
self.setupUi(self)
from PyQt4.QtGui import QDialog
from PyQt4.QtCore import pyqtSignature
from Ui_form2 import Ui_Dialog
class FormTwo(QDialog, Ui_Dialog):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
QDialog.__init__(self, parent)
self.setupUi(self)
To copy to clipboard, switch view to plain text mode
__init__.py
from PyQt4 import QtCore, QtGui
from ui.form1 import FormOne
if __name__ == "__main__":
import sys
ui = FormOne()
ui.show()
sys.exit(app.exec_())
from PyQt4 import QtCore, QtGui
from ui.form1 import FormOne
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
ui = FormOne()
ui.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
There is a new problem though that the 2nd form doesn't stay at all and closes immediately after I click the button on the first form. Would it be alright to ask how to correct and solve this?
Bookmarks