How can I updating the view?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I updating the view?

Robert Unguran
Hi,

I have a Traitst with a view

class Status( HasTraits ):
    Sentout = Str
    ISentout = ImageResource( 'YellowDot', search_path = [os.path.join( os.path.dirname( __file__ ), '..', 'images' )] )


    traits_view = View(                     
                           VGrid(
                                 Label( "Message Sent: " ),
                                 Item( "ISentout", editor = ImageEditor(), show_label = False ),
                            ))

   def _Sentout_changed( self ):
        """
        """
        print self.Sentout
        print  self.__string2bool( self.Sentout )       
        self.ISentout = self.__get_image_resource_by_value( self.__string2bool( self.Sentout ) )


   def __get_image_resource_by_value( self, value ):
        """
        """
        if value == 1:
            return ImageResource( 'GreenDot', search_path = [os.path.join(
                            os.path.dirname( __file__ ), '..', 'images' )] )
       
        if value == 0:
            return ImageResource( 'RedDot', search_path = [os.path.join(
                            os.path.dirname( __file__ ), '..', 'images' )] )
       
           
        return ImageResource( 'YellowDot', search_path =
            [os.path.join( os.path.dirname( __file__ ), '..', 'images' )] )


When the Sentout value has changed the _Sentout_changed( self ): is called but on the view the icon is not changing, always it is the same. How can I update the icon?

Than you for your advices.

Regards,
Robert

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: How can I updating the view?

_jelle_
on first glance, probably you should use "def Sentout_changed( self ):"
 rather than "def _Sentout_changed( self ):" in your code.

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