Exemplo n.º 1
0
class ReadonlyEditor ( Editor ):
    """ Base class for read-only style editors, which displays a read-only text
    field, containing a text representation of the object trait value.
    """
    #---------------------------------------------------------------------------
    #  Finishes initializing the editor by creating the underlying toolkit
    #  widget:
    #---------------------------------------------------------------------------

    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = Label()
        self.control.setImmediate(True)
        self.control.setValue( str(self.str_value) )

#        if self.item.resizable is True or self.item.height != -1.0:
#            self.control.setSizePolicy(QtGui.QSizePolicy.Expanding,
#                                       QtGui.QSizePolicy.Expanding)
#            self.control.setWordWrap(True)

        self.set_tooltip()

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------

    def update_editor ( self ):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        self.control.setValue( str(self.str_value) )