WxPython - Binding an Event to a Randomly changing value - Algorithm Required
<p>I have a textBox on my WxPython GUI, where I am displaying a changing value (Which changes every 100 mS). I have two buttons - Button A, Button B. </p>

<p>Initial condition: Textbox has a value of between 2000-3000. Button A is enabled, Button B is disabled.</p>

<p>I need the following sequence of events to go on:
The user presses the Button A. After approximately 20 seconds or some user defined time (completely variable based on the user/ type of work he is doing), the textBox value goes under less 50. </p>

<p>Once the textBox value goes less than 50 - Button B should be enabled. </p>

<p>Currently this is my following code, where I am pressing the Button A - waiting for the textBox value to less than 50. Then enable the Button B - and it is not working. The button B is not getting enabled. I tried using other means, but they are leaving to an unresponsive GUI. My Button A is - DONE, Button B is START. textBox is pressure_text_control.</p>

<pre><code>def OnDone(self, event):
    self.WriteToController([0x04],'GuiMsgIn')
    self.status_text.SetLabel('PRESSURE CALIBRATION DONE \n DUMP PRESSURE')
    self.led1.SetBackgroundColour('GREY')
    self.add_pressure.Disable()
    while self.pressure_text_control.GetValue() &lt; 50:
        wx.CallAfter(self.StartEnable, 'Enabling start button')
        #self.start.Enable()

def StartEnable(self):
    self.start.Enable()
</code></pre>

<p>You haven't supplied sufficient code to be able to see what is going on.<br>
We don't know for example if <code>self.pressure_text_control.GetValue() &lt; 50</code> is in fact less than 50, given that you say the value is changing every 100mS.</p>

<p>If your issue is really about the fact that the GUI becomes unresponsive, then investigate <code>wx.Timer()</code><br>
See:<br>
<a href="http://www.blog.pythonlibrary.org/2009/08/25/wxpython-using-wx-timers/" rel="nofollow">http://www.blog.pythonlibrary.org/2009/08/25/wxpython-using-wx-timers/</a></p>

<p>The Timer class allows you to execute code at specified intervals, which allows you to process one or more periodic events (you can declare multiple <code>timers</code>), as long as they are not long or blocking processes, yet leave the GUI responsive.</p>

<p>mocked up as follows:</p>

<pre><code>    self.timer = wx.Timer(self)
    self.Bind(wx.EVT_TIMER, self.check, self.timer)

def StartmyButton(self):
    self.start.Enable()
    self.timer.Start(100)

def check(self, event):
    "check you input here and process any results"
</code></pre>

python wxpython