python - Opening a child dialog window from a main window with Pyside -


so i've started learning python pyside gui development, have been using qt designer speed , converting .ui files .py

i have "main window" ui , "about" ui (main window setup main window , empty dialog)

how open dialog main window? following code opens main window main.py

class mainwindow(qmainwindow, mainwindow.ui_mainwindow): def __init__(self, parent=none):     super(mainwindow, self).__init__(parent)     self.setupui(self)  app = qapplication(sys.argv) form = mainwindow() form.show()  app.exec_() 

that works fine, brings main window. in main window there menu items, 1 of "about" selection when user clicks want bring other dialog ui created, how can this?

in mainwindow.py (converted ui) there these references:

self.actionabout_mailer_0_0_1 = qtgui.qaction(mainwindow) self.actionabout_mailer_0_0_1.setobjectname("actionabout_mailer_0_0_1") self.menuabout.addaction(self.actionabout_mailer_0_0_1) 

and about.py (converted ui) looks this:

from pyside import qtcore, qtgui  class about_dialog(object): def setupui(self, dialog):     dialog.setobjectname("dialog")     dialog.resize(400, 300)     self.aboutlbl = qtgui.qlabel(dialog)     self.aboutlbl.setgeometry(qtcore.qrect(110, 40, 171, 16))     self.aboutlbl.setobjectname("aboutlbl")      self.retranslateui(dialog)     qtcore.qmetaobject.connectslotsbyname(dialog)  def retranslateui(self, dialog):     dialog.setwindowtitle(qtgui.qapplication.translate("dialog", "dialog", none, qtgui.qapplication.unicodeutf8))     self.aboutlbl.settext(qtgui.qapplication.translate("dialog", "mailer version 0.0.1 .....", none, qtgui.qapplication.unicodeutf8)) 

i figure need create new function inside mainwindow.py when called opens dialog, have no idea put in function, i'm confused slots , connections, if me out example code great.

edit:

i figured out function part of code, still figuring out how connect menu connected button press executes method opens fine:

def openabout(self):     aboutdialog = qtgui.qdialog(self)     aboutui = about.about_dialog()     aboutui.setupui(aboutdialog)     aboutdialog.show() 

if mainwindow have menu action named actionabout, , slot called openabout, need connect triggered signal actionabout slot openabout.

self.actionabout.triggered.connect(self.openabout) 

the process similar have done pushbutton. change names used in example ones in application.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -