wx.Postevent is only processed at the end

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

wx.Postevent is only processed at the end

franz steinhaeusler
Hello, I don't have a runnable expample, so I try to show with pseudo code_

In a thread, I have a loop, which should update a dialog with progress bar.

Examplecode in thread:

while i < 10:
  event = wx.CommandEvent ()
  event.SetEventType (wx.wxEVT_COMMAND_BUTTON_CLICKED)
  event.SetId (9999)
  wx.PostEvent(self.m_pWndProgress, event) # this shall call OnUpdateProgress
  print "post event"
  # is here something missing, so that the UI is getting the posted events?
  #time.sleep(0.1)
  ++i

in Progress dialog
wx.EVT_BUTTON(self, 9999, self.OnUpdateProgress)

def OnUpdateProgress(self, event):
  print 'update'

output is:
post event
post event
...
post event
post event

update
update
...
update
update

so the update is not called before all PostEvents are delivered.

What do I have to to to get the OnUpdateProgress processed immediatly?

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.Postevent is only processed at the end

franz steinhaeusler
Sorry, solved, this was a bug in my program in another location...

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.Postevent is only processed at the end

Chris Barker - NOAA Federal


On Tue, May 30, 2017 at 5:48 AM, franz steinhaeusler <[hidden email]> wrote:
Sorry, solved, this was a bug in my program in another location...

glad you got it solved, but I can't help myself:

This looks like a much messier way to do this than you need. Rather than try to emulate a button click, why not simply call OnUpdateProgress? -- something like:

wx.CallAfter(the_dialog.OnUpdateProgress, None)

-CHB


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.Postevent is only processed at the end

franz steinhaeusler
Hello Chris,

of course you are right, it's only because I port/ported wxWidgets C++ Code. Here in wxPython, wx.CallAfter would be first choice (and less (and more clean code)) and I change it to that.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.