Open a dialog from MainWindow - pyQT4 - Beginner :-)

Florian Wollenschein Florian.Wollenschein at FernUni-Hagen.de
Tue May 5 11:43:09 EDT 2009


nickgaens at gmail.com wrote:
> On May 4, 7:31 pm, Florian Wollenschein <Florian.Wollensch... at FernUni-
> Hagen.de> wrote:
>> Dear folks,
>>
>> I'm just working on a pyQT4 version of my txt to html converter thc (see
>> listick.org for details).
>>
>> I created the MainWindow with QT Designer and then converted it to .py
>> with pyuic4. It works well so far. Then I created a new UI for my
>> abtDialog (about dialog for my application). I did the same as with the
>> MainWindow, so I have two UIs and two *_ui.py files now. How can I open
>> the dialog from my main application class?
>>
>> Here's part of the code I'm using:
>>
>> ...
>> self.connect(self.actionAbout,
>>                  QtCore.SIGNAL("triggered()"), self.OpenAbout)
>> ...
>>   def OpenAbout(self):
>>          pass
>> ...
>>
>> The OpenAbout function should open the dialog. I've already tried a
>> abtDialog.show() after creating it via abtDialog = ThcAboutDialog()
>> (ThcAboutDialog is the class for this dlg).
>>
>> Any ideas?
>>
>> Thanks,
>> Listick Lorchhttp://www.listick.org
>>
>> PS: Keep in mind that I'm quite a beginner in the field of python and qt...
> 
> def OpenAbout(self):
>     # don't forget to connect the "Ok"-button of this about-dialog to
> QDialog::accept() ;-)
>     abtDialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
>     abtDialog.exec_()
> 
> R3
> 
> ps: you could take a look at a QMessageBox::information or so to make
> this more "simple"

Wow, thanks for your help. Now it's working :-)

Great.
Regards,
Listick



More information about the Python-list mailing list