[pygtk] FileChooserDialog can not run twice?
Zhenjiang Lan
lan.zhenjiang at gmail.com
Tue Mar 20 02:50:08 WST 2012
Thank all!
I got it now.
On Mon, Mar 19, 2012 at 1:30 AM, Neil Muller <drnlmuller+gtk at gmail.com> wrote:
> On 19 March 2012 06:02, Zhenjiang Lan <lan.zhenjiang at gmail.com> wrote:
>> Hi all experts,
>> I create a button, connect to a FileChooserDialog. When I click the
>> button, I can choose a file and print it's name.
>> But, if I click 'cancel' for the first time, then I click the button
>> again, it crashed..
>
> You have dialog as a class attribute on your choosefile class, so it's
> only instantiated once. Since you call dialog.destroy() in the run
> method, and then try to rerun the dialog, the crash is not surprising.
>
> There are a couple of ways to fix this. I'd explicitly make choosefile
> a singleton and use dialog.hide(), but you could also make it an
> instance variable (by creating in choosefile's __init__ method) and
> thus recreate the file chooser on each run.
>
> --
> Neil Muller
> drnlmuller at gmail.com
>
> I've got a gmail account. Why haven't I become cool?
More information about the pygtk
mailing list