wxProgressDialog problems
Larry Bates
larry.bates at websafe.com
Mon Feb 25 15:02:25 PST 2008
Robin Dunn wrote:
> Larry Bates wrote:
>> Robin Dunn wrote:
>>> Larry Bates wrote:
>>>> Robin Dunn wrote:
>>>>> Larry Bates wrote:
>>>
>>>>>> Thoughts?
>>>>>
>>>>> Do the other code in a thread, and make the callback use
>>>>> wx.CallAfter or post an event so the update of the progress dialog
>>>>> can be done in the gui thread. If the cancel button was pressed
>>>>> then set a flag that the download thread will check periodically so
>>>>> it knows to stop (or send the message in some other thread-safe way).
>>>>>
>>>>>
>>>> Real newbie here. It sounds like this would be the best way:
>>>>
>>>> > or post an event so the update of the progress dialog can be done in
>>>> > the gui thread.
>>>>
>>>> I "really" tried on this one, but it exhibits the same behavior.
>>>> Can't ever click on the Cancel button. See sample code below.
>>>>
>>>> Thanks for all your help.
>>>
>>> You still are not calling the app's MainLoop method. And you seem to
>>> have missed the "Do the other code in a thread" part of my comment.
>>>
>>>
>>
>> >>> Do the other code in a thread, and make the callback use
>> wx.CallAfter
>> >>> or post an event so the update of the progress dialog can be done in
>> >>> the gui thread.
>>
>> Sorry, I read your instructions as "Do in a thread and make callback
>> or post
>> an event..." Note the OR.
>>
>> I tried running my other code in a separate thread, but Python DAVLIB
>> refuses run in a separate thread and I'm not up to a complete rewrite
>> of that code at the present.
>>
>> I tried running the MainLoop in another thread, but it makes no
>> difference.
>
> To use wx in an alternate thread you need to do almost everything
> wx-related from that thread, essentially anything that interacts with
> the UI, including creating or modifying the app and window objects. It
> is safe to use wx.PostEvent or wx.CallAfter from the non-gui thread in
> order to pass messages or to invoke other functions in the context of
> the gui thread.
>
> Also, in your case you'll either need to create a top-level window, or
> call app.SetExitOnFrameDelete(False), otherwise the MainLoop will exit
> immediately since there are not any top-level windows existing at the
> time it is called.
>
>
Robin,
I appreciate your attempts to help me but I'm still dead-in-the-water. For some
reason the MailLoop does NOT exit immediately (even without
app.SetExitOnFrameDelete(False)). The messages that I post via wx.PostEvent in
my (non-GUI) loop DO get processed properly and the GUI dialog including the
title, message1 and gauge are all updated as expected, but I can't click on the
Cancel button (hourglass cursor whenever I hover over the dialog and clicks do
nothing). This is soooo... close, that its frustrating.
-Larry
More information about the wxpython-users
mailing list