Result of Modal window

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Result of Modal window

Jake Ross
Hi All

Ive been using the following pattern (see below) for editing trait objects but there is one issue that I know will be a problem for my users.

The problem is that ui.result is True when the window is closed by either the "OK" button or the upper left hand corner "X" button. Ui.result is False only when "Cancel" is clicked.

I noticed that if I use a "wizard" view the "X" button sets ui.result but I would rather not use a wizard nor is it clear from the documentation how to add multiple wizard pages.

Im using Mac OSX 10.7 and EPD 7.2

Thanks
Jake


#==============================================
from traits.api import HasTraits, Str, Button, Instance
from traitsui.api import View

class A(HasTraits):
    foo=Str
   
class B(HasTraits):
    def set_parameter(self, p):
        self._parameter=p
       
class C(HasTraits):
    edit_button=Button
    a=Instance(A, ())
    b=Instance(B, ())
    traits_view=View('edit_button')
   
    def _edit_button_fired(self):
        ui=self.a.edit_traits()
        if ui.result:
            print 'edit accepted'
            self.b.set_parameter(self.a.foo)
            self.b.edit_traits()
        else:
            print 'edit canceled'
           
if __name__=='__main__':
    C().configure_traits()

#==============================================
--
Jake Ross
NM Tech
[hidden email]
[hidden email]
575-835-5994 (office)

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev