[pygtk] Using multiple dialog boxes

Steve McClure smcclure at racemi.com
Thu Jun 12 19:24:55 WST 2008


See http://faq.pygtk.org/index.py?req=show&file=faq10.006.htp

On Jun 12, 2008, at 6:21 AM, Timo wrote:

> OK, here is a small part of my code that is relevant I think.
> So, the first time, the options dialog opens just fine and I can do
> everything with it that should work. The I close that dialog and if I
> want to re-open it, I get this error:
>
> AttributeError: 'NoneType' object has no attribute 'run'
>
>
>
> main dialog code snippet:
>
> import options_dialog
>
> class MainDlg:
>    def __init__(self):
>        self.gladefile = "qfc.glade"
>        self.wTree = gtk.glade.XML(self.gladefile)
>        dic = { "on_settings_clicked" : self.settings_clicked,
>                "on_maindlg_destroy" : gtk.main_quit }
>        self.wTree.signal_autoconnect(dic)
>
>        self.optsdlg = options_dialog.OptionsDlg()
>
>    def settings_clicked(self, widget):
>        self.optsdlg.run()
>
> if __name__ == "__main__":
>    hwg = MainDlg()
>    gtk.main()
>
>
> options dialog code snippet:
>
> class OptionsDlg:
>
>    def __init__(self):
>        self.gladefile = "qfc.glade"
>        self.wTree = gtk.glade.XML(self.gladefile, "optionsdlg")
>        dic = { "on_cancel_clicked" : self.cancel_clicked }
>        self.wTree.signal_autoconnect(dic)
>
>    def run(self):
>        self.dlg = self.wTree.get_widget("optionsdlg")
>        self.dlg.run()
>
>    def cancel_clicked(self, widget):
>        self.dlg.destroy()
>
>
>
>
> Markus W. Barth schreef:
>> The first window (main window) should be gtk.Window, the others  
>> should
>> probably be gtk.Dialog
>>
>> You create an instance of your dialog and call run()
>>
>> It's difficult to tell why this happens without seeing the code.
>>
>> On Wednesday 11 June 2008 14:42:59 Timo wrote:
>>
>>> Hello all, I'm writing a program that has 3 dialog boxes, 1 main  
>>> which
>>> is the main window and runs on startup. Then I have 2 other that  
>>> have to
>>> show when the appropriat button is pressed. I made these 3 windows  
>>> in
>>> Glade.
>>>
>>> Now, since my program was getting big, I splitted up my .py file  
>>> in 3,
>>> each dialog has it's own .py file, but now my calls for opening the
>>> dialogs aren't working as they should be anymore. They show the  
>>> first
>>> time I click the button, but the second time they don't and I have  
>>> to
>>> restart my program.
>>>
>>> What is the proper way to call a dialog box that is in another .py- 
>>> file?
>>>
>>> Hope this explanation makes sense.
>>>
>>> Greets,
>>> Timo
>>> _______________________________________________
>>> pygtk mailing list   pygtk at daa.com.au
>>> http://www.daa.com.au/mailman/listinfo/pygtk
>>> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>>>
>>
>>
>> _______________________________________________
>> pygtk mailing list   pygtk at daa.com.au
>> http://www.daa.com.au/mailman/listinfo/pygtk
>> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>>
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>

--
Steve McClure
smcclure at racemi.com



More information about the pygtk mailing list