image : Attachment 11368
Im trying to connect different Qt Dialogs using PyQt , but I can't figure out how to do that.
In my example, "dialog_inserir.ui" will be main window, so when I click "say hello !" button, the second window will appear.
How to do that in Python Qt code ?
The code im trying :
import dialog_inserir as di # the first window of image
import hello as hl # the "hello world" window
import sys
from PyQt4 import QtGui, QtCore
def __init__(self, parent=None):
QtGui.
QWidget.__init__
(self, parent
) self.ui = di.Ui_Dialog()
self.ui.setupUi(self)
QtCore.
QObject.
connect(self.
ui.
pushButtonSayHello, QtCore.
SIGNAL('clicked()'), self.
Hello)
def Hello(self):
# ... what here ? ...
pass
def __init__(self, parent=None):
QtGui.
QWidget.__init__
(self, parent
) self.helloui = hl.Ui_Dialog()
self.helloui.setupUi(self)
if __name__ == "__main__":
mywindow = MainWindow()
mywindow.show()
sys.exit(app.exec_())
import dialog_inserir as di # the first window of image
import hello as hl # the "hello world" window
import sys
from PyQt4 import QtGui, QtCore
class MainWindow(QtGui.QDialog):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = di.Ui_Dialog()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.pushButtonSayHello, QtCore.SIGNAL('clicked()'), self.Hello)
def Hello(self):
# ... what here ? ...
pass
class HelloWindow(QtGui.QDialog):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.helloui = hl.Ui_Dialog()
self.helloui.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mywindow = MainWindow()
mywindow.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks