0

I'm building a GUI for a machine with Traits and TraitsUI. I would like the machine to perform an action as long as a button on the GUI is pressed and of course having the GUI not freeze and display the outcome of this continuous action, i.e. in a separate thread.

I can define in the class which inherits HasTraits a button and a function which performs the actions when the button is pressed (def _button_fired:), but it seems to me that the way the _button_fired is defined, the GUI actually waits for the button-pressing to be over before performing the "Action". As stated above, I would like it to execute a function the second I press the button and stop this function execution (or execute a different function) when I release the button.

You can take as an example code snippet no. 7 from Gael's tutorial and just imagine that while pressing the button, the counter should increase.

Your help will be greatly appreciated.

Hellbourne

  • Does this help?: https://github.com/enthought/traitsui/blob/master/traitsui/wx/themed_window.py – Jonathan March Jan 24 '15 at 23:15
  • It probably would, if I knew wx... By the way, the themed_window.py does not stand by its own without adding a `control = Instance ( wx.Window )` in the `ThemedWindow` class. So this is the wx way of doing event-handling, right? Can you comment with a link to a simple wx guide to actually test this left-click event-handling? – hellbourne Jan 25 '15 at 21:01
  • I did not mean to suggest that you use the module, but only to use the button up/down techniques that it uses, which on very quick look (maybe too quick!) looked to be wx-independent. – Jonathan March Jan 26 '15 at 02:20
  • Yeah, they seem dependent. However, the concept is the same also in `enable.tools.drag_tool` or `chaco.tools.cursor_tool`, so I should be able to write my own adaptation. – hellbourne Jan 26 '15 at 11:24
  • If you are willing to drop down to enable you can definitely do it straightforwardly. – Jonathan March Jan 26 '15 at 17:29
  • What do you mean by "drop down"? – hellbourne Jan 27 '15 at 09:49
  • Referring to the fact that enable is a low level package (and very powerful) and will take a bit of study. – Jonathan March Jan 27 '15 at 10:25
  • As always, it is a matter of prioritization. Of course I would rather have a high level solution, but if worse comes to worst... – hellbourne Jan 27 '15 at 22:36

0 Answers0