I have made a new post here which pointed out this thread. I'm sorry if I suddenly revive this thread. Nobody was replying at the thread I made so I thought if replying here would help me with what I'm asking ^^;;
I would like to ask you, aladagemre or jaybstory or anyone who can help, if by making ui through QtDesigner (with eric4 as I'm using it) the 2nd ui form, how do you by chance open it just like I made in the original thread I posted?
Below are parts of the 2nd post I replied within the original post
-----------------------------------
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?
-----------------------------------
Would it be alright if I ask what I'm doing wrong or something to solve this problem by chance? Thank you *bows deeply*
Bookmarks