/usr/share/pyshared/PythonCard/components/htmlwindow.py is in python-pythoncard 0.8.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | """
__version__ = "$Revision: 1.17 $"
__date__ = "$Date: 2004/05/13 02:40:24 $"
"""
import wx
from wx import html
from PythonCard import event, log, widget
class HtmlWindowSpec(widget.WidgetSpec):
def __init__(self):
events = []
attributes = {
'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] },
'text' : { 'presence' : 'optional', 'default' : '' },
}
widget.WidgetSpec.__init__(self, 'HtmlWindow', 'Widget', events, attributes )
class HtmlWindow(widget.Widget, html.HtmlWindow):
"""
An HTML window.
"""
_spec = HtmlWindowSpec()
def __init__(self, aParent, aResource):
self._addressField = None
html.HtmlWindow.__init__(
self,
aParent,
widget.makeNewId(aResource.id),
aResource.position,
aResource.size,
#style = wx.HW_SCROLLBAR_AUTO | wx.CLIP_SIBLINGS,
name = aResource.name
)
widget.Widget.__init__(self, aParent, aResource)
self._setText(aResource.text)
self._bindEvents(event.WIDGET_EVENTS)
def setAddressField(self, field):
self._addressField = field
def _getText(self) :
return self.GetOpenedPage()
def _setText(self, aString):
if aString == '' or aString[0] == '<':
self.SetPage(aString)
else:
# filename
self.LoadPage(aString)
#self._delegate.Refresh()
def base_LoadPage(self, url):
log.debug("base_LoadPage " + url)
if self._addressField is not None:
self._addressField.text = url
log.debug("loaded")
html.HtmlWindow.base_LoadPage(self, url)
def LoadPage(self, url):
log.debug("LoadPage " + url)
if self._addressField is not None:
self._addressField.text = url
log.debug("loaded")
html.HtmlWindow.LoadPage(self, url)
def SetPage(self, text):
log.debug("SetPage " + text)
#if self._addressField is not None:
# self._addressField.text = text
# log.debug("set")
html.HtmlWindow.SetPage(self, text)
def OnLinkClicked(self, link):
log.debug("OnLinkClicked " + str(link))
if self._addressField is not None:
url = self.GetOpenedPage()
log.debug("url: " + url)
baseURL = url[:url.rfind('/')]
log.debug("baseURL: " + baseURL)
href = link.GetHref()
log.debug("href: " + href)
if href.find('://') != -1:
self._addressField.text = href
else:
self._addressField.text = baseURL + '/' + href
log.debug("full url: " + self._addressField.text)
# Virtuals in the base class have been renamed with base_ on the front.
html.HtmlWindow.base_OnLinkClicked(self, link)
text = property(_getText, _setText)
import sys
from PythonCard import registry
registry.Registry.getInstance().register(sys.modules[__name__].HtmlWindow)
|