class SimpleEditor ( Editor ): """ Simple style editor for HTML. """ #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # Is the HTML editor scrollable? This values override the default. scrollable = True # External objects referenced in the HTML are relative to this URL base_url = Str #--------------------------------------------------------------------------- # 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 = RichTextArea() self.control.setSizeFull() if self.factory.open_externally: raise NotImplementedError self.base_url = self.factory.base_url self.sync_value( self.factory.base_url_name, 'base_url', 'from' ) #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor ( self ): """ Updates the editor when the object trait changes external to the editor. """ text = self.str_value if self.factory.format_text: text = self.factory.parse_text( text ) if self.base_url: url = self.base_url if not url.endswith("/"): url += "/" self.control.setValue( text , urlopen ( url ) ) else: self.control.setValue( text ) #-- Event Handlers --------------------------------------------------------- def _base_url_changed ( self ): self.update_editor()