enthought/traitsui — Issue #36: BUG: ProgressEditor basic usage
Author: kwmsmith
Created: 2011-10-21 14:33:29+00:00
State: open

There is little documentation on the ProgressEditor, so this may be incorrect usage. But I don't think so.

The following example will correctly update the GUI progress editor on wx, but each iteration in `_go_button_fired()` raises an exception.

```python
from traits.etsconfig.etsconfig import ETSConfig
ETSConfig.toolkit = 'wx'

from time import sleep

from traits.api import HasTraits, Button, Int
from traitsui.api import ProgressEditor, View, Item, HGroup

MAX = 100

class Foo(HasTraits):

val = Int
go_button = Button("GO")

def _go_button_fired(self):
while self.val < MAX:
sleep(0.1)
self.val += 1
self.val = 0

def traits_view(self):
return View(
HGroup(
Item('go_button', show_label=False),
Item('val',
show_label=False,
editor=ProgressEditor(
min=0,
max=MAX,
),
),
),
)

if __name__ == '__main__':
f = Foo()
f.configure_traits()
```