Albert J. Boehmler wrote:
>I do have a minor issue, though. I have an application which is using
>PythonCard version: 0.8.1 and wxPython version: 2.5.3.1 on Windows. It
>simulates output strings for a sensor and uses many "Choice" components.
>I am using a timer to build and send an output string based on the
>values of the GUI elements once a second.
>
>The issue I am running into is that the "stringSelection" values are
>read while the drop-down list is active and the highlighted value is
>sent. I'd like to only send the value when an item has been selected;
>until a different item has been selected, the original value should be
>sent. Is there any simple way to do this? I've noticed that the ComboBox
>doesn't do this, but I'd rather not use that if I can avoid it.
>
>
>
I created an example like you describe (I think - want to check this is
what you currently do). Resource file has just a single "Choice"
component called "Choice1" (oops - just noticed that I used selection
instead of stringSelection - but should be the same .... )
> #!/usr/bin/python
> from PythonCard import model, timer
>
> class MyBackground(model.Background):
>
> def on_initialize(self, event):
> # if you have any initialization
> # including sizer setup, do it here
> self.timer = timer.Timer(self.components.Choice1, -1)
> self.timer.start(1000)
> pass
>
> def on_Choice1_timer(self, event):
> print self.components.Choice1.selection
>
>
> if __name__ == '__main__':
> app = model.Application(MyBackground)
> app.MainLoop()
Then changed it by adding a variable (self.choice, which is initialized
to -1, and is set only when the "select" event happens. I think this
does what you want.
> #!/usr/bin/python
>
> """
> __version__ = "$Revision: 1.5 $"
> __date__ = "$Date: 2004/04/30 16:26:12 $"
> """
>
> from PythonCard import model, timer
>
> class MyBackground(model.Background):
>
> def on_initialize(self, event):
> # if you have any initialization
> # including sizer setup, do it here
> self.timer = timer.Timer(self.components.Choice1, -1)
> self.timer.start(1000)
> self.choice = -1
> pass
>
> def on_Choice1_select(self, event):
> self.choice = self.components.Choice1.selection
>
> def on_Choice1_timer(self, event):
> print self.components.Choice1.selection, self.choice
>
>
> if __name__ == '__main__':
> app = model.Application(MyBackground)
> app.MainLoop()
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 25/04/2005
|