Source code for enaml.wx.wx_html
#------------------------------------------------------------------------------
# Copyright (c) 2012, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
import wx.html
from .wx_control import WxControl
class wxProperHtmlWindow(wx.html.HtmlWindow):
""" A custom wx Html window that returns a non-braindead best size.
"""
_best_size = wx.Size(256, 192)
def GetBestSize(self):
""" Returns the best size for the html window.
"""
return self._best_size
[docs]class WxHtml(WxControl):
""" A Wx implementation of the Enaml Html widget.
"""
#--------------------------------------------------------------------------
# Setup Methods
#--------------------------------------------------------------------------
[docs] def create(self, tree):
""" Create and initialize the html control.
"""
super(WxHtml, self).create(tree)
self.set_source(tree['source'])
#--------------------------------------------------------------------------
# Message Handlers
#--------------------------------------------------------------------------
[docs] def on_action_set_source(self, content):
""" Handle the 'set_source' action from the Enaml widget.
"""
self.set_source(content['source'])
#--------------------------------------------------------------------------
# Widget Update Methods
#--------------------------------------------------------------------------
[docs] def set_source(self, source):
""" Set the source of the html widget
"""
self.widget().SetPage(source)