John Bender wrote:
John Bender wrote:
I'm having a strange problem specific to WxPython 2.9.4.0 in
Windows.
The code works fine in Mac and Ubuntu. I posted to StackOverflow
with no
luck, so I thought I'd try here.
Basically, the problem boils down to this -- how could the
assertion on
the second line ever fail?
self.next_button.Enable(self.____next_enabled)
assert(self.next_button.__Enabled == self.__next_enabled)
I checked the type of next_button and everything else I could
think of,
and as I said, it works fine on Mac and Ubuntu. In fact, if I
execute
the function containing this code with a slight delay using a
Timer, it
also works. Somehow Windows accepts the Enable() call but doesn't
actually execute it.
Any ideas?
I suppose that it's possible on Windows for the widget to reject the
change in enabled state in certain conditions, but we would really
need to see a runnable example of this problem to even guess what
might be causing it in your case.
Attached is a demo app. Apparently what's happening is that in Windows,
opening a ProgressDialog disables the buttons in my main window, even
though I set the dialog's parent to None and its style to 0. This is not
the case in Linux or Mac, and I believe it's also different from Wx 2.8
in Windows.
In 2.9 the ProgressDialog on Windows was switched to a native dialog implementation instead of the generic one that was being used before, so that is probably the source of the differences. The old class is now available as wx.GenericProgressDialog.
I'm not certain that this is precisely what's happening in my
application, but it's very similar. In the attached app, the buttons
re-enable themselves after some period of time (0.1 < t < 0.5 on my
machine).
The dialog's Destroy method doesn't actually destroy anything, it just adds the dialog to a list of items to be destroyed later when all pending events have been processed. So in your example control has to first return to the event loop, and the event queue has to become empty, and then the dialog will be destroyed, triggering it to enable any widgets that it had disabled before.
BTW, using a threading.Timer to call a function that deals with the UI is a bad idea. You can use wx.CallLater instead and it will use a wx.Timer and the callable will be invoked in the context of the UI thread.
···
On Sun, Mar 31, 2013 at 3:16 PM, Robin Dunn <robin@alldunn.com > <mailto:robin@alldunn.com>> wrote:
--
Robin Dunn
Software Craftsman