How do I Block Events in wxPython

Wanderer wanderer at dialup4less.com
Wed Dec 9 12:06:04 EST 2009


On Dec 9, 11:48 am, r0g <aioe.... at technicalbloke.com> wrote:
> Wanderer wrote:
> > I have a wxPython program which does some calculations and displays
> > the results. During these calculations if I click the mouse inside the
> > dialog the program locks up. If I leave the dialog alone the process
> > completes fine.
>
> If anything in your GUI app takes a non trivial length of time to
> execute you need to run it in either a thread or a separate process.
>
> http://linuxgazette.net/107/pai.html
>
> Roger

Thanks Everyone. I'll have to look over these wikis about threading. I
decided to go another route and user a timer to perform the loops.
That way the events can be processed normally.

    def DoEfficiency(self, event):


      ang = self.tc_angle.GetValue()
      hgt = self.tc_height.GetValue()
      hgt += 0.1
      if hgt > self.eclwidth:
        hgt = 0
        ang +=1
        self.tc_angle.SetValue(ang)
      self.height = hgt
      self.tc_height.SetValue(hgt)
      self.tc_height.SetValue(hgt)
      self.UpdateValues()
      self.Redraw()
      self.DrawRays()
      sPower = self.tc_power.GetValue()
      Power = sPower.split('%')
      self.TotalPower +=float(Power[0])
      self.Counter +=1
      efficiency = self.TotalPower/self.Counter
      self.tc_eff.SetLabel(str(round(efficiency,1)))
      if ang > 89:
        self.efftimer.Stop()
        self.timer.Start(10)



    # end DoEfficiency

    def OnEfficiency(self, event):

        self.TotalPower = 0
        self.Counter = 0
        self.tc_angle.SetValue(1)
        self.tc_height.SetValue(0)
        self.timer.Stop()
        self.efftimer.Start(100)


# end MyInterface

Found another strange bug (Strange to me, anyway). int(0.8 * 10.0) =
7. Had to change the code to int(0.8 * 10.0 + 0.0001).




More information about the Python-list mailing list