WXPYTHON - Button Press Event

183 Views Asked by At

I have the following code - which is started by a button - say button1 which has to happen every one second -through a thread.

self.pump_rpm_text_control.AppendText(str(self.sheet_num.cell_value(self.sel+1,10)*(SortAndDecode(self.data, 'FrqQ5'))/65536))`

The problem I am facing here is - the "self.sel" is recorded from an excel sheet - when a selection from an excel sheet happens.

So I decided to write an if condition something like this:

        if not self.OnList():
            self.pump_rpm_text_control.AppendText("000")
        else:
            self.sheet_num.cell_value(self.sel + 1, 10)
            self.pump_rpm_text_control.AppendText(str(self.sheet_num.cell_value(self.sel+1,10)*(SortAndDecode(self.data, 'FrqQ5'))/65536))

OnList - is the event that is called when a selection is being made on a listbox. But however my code is still going to ELSE, even though my OnLIST event has not happened. Any help would be greatly appreciated.

1

There are 1 best solutions below

0
Rolf of Saxony On

In the same way that this code follows the else path?

>>> def Onlist():
...     return True
... 
>>> if not Onlist():
...     print False
... else:
...     print True
... 
True

It all depends on what value Onlist returns as furas commented