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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
#--(Internet Explorer HTML Editor (Windows Only))-------------------------------
"""
Internet Explorer HTML Editor (Windows Only)
============================================
In Traits 3.0, a new **IEHTMLEditor** has been added to the Traits UI package.
The editor allows displaying (but not editing) HTML pages using the Microsoft
Internet Explorer browser.
This editor is currently only available for the Windows platform and is
located in the wxPython version of the Traits UI in the
*traitsui.wx.extras.windows* package. The purpose of the
*extras.windows* package is to provide a location for editors which may be
toolkit and Windows platform specific, and not necessarily available in all
Traits UI toolkit packages or platforms.
The traits supported by the **IEHTMLEditor** editor are as follows:
home
A string specifying the optional extended name of a trait event used to tell
Internet Explorer to display the user's home page. Set the specified trait
to **True** to cause the browser to display the user's home page.
back
A string specifying the optional extended name of a trait event used to tell
Internet Explorer to display the previous browser page. Set the specified
trait to **True** to cause the browser to display the previous browser page.
forward
A string specifying the optional extended name of a trait event used to tell
Internet Explorer to display the next (i.e. forward) browser page. Set the
specified trait to **True** to cause the browser to display the next browser
page (if available).
stop
A string specifying the optional extended name of a trait event used to tell
Internet Explorer to stop loading the current page. Set the specified trait
to **True** to cause the browser to stop loading the current page.
refresh
A string specifying the optional extended name of a trait event used to tell
Internet Explorer to refresh the current page. Set the specified trait to
**True** to cause the browser to refresh the current page.
search
A string specifying the optional extended name of a trait event used to tell
Internet Explorer to initiate a search of the current page. Set the
specified trait to **True** to cause the browser to start a search of the
current page.
status
A string specifying the optional extended name of a trait used contain the
current Internet Explorer status. This trait is automatically updated by the
browser as its internal status changes.
title
A string specifying the optional extended name of a trait used contain the
current Internet Explorer page title. This trait is automatically updated by
the browser as the current page title is changed.
page_loaded
A string specifying the optional extended name of a trait used contain the
URL of the current Internet Explorer page. This trait is automatically
updated by the browser as a page is loaded.
html
A string specifying the optional extended name of a trait used to get or
set the HTML page content of the current Internet Explorer page. This
trait is automatically updated by the browser as a page is loaded, and can
also be set by an application to cause the browser to display the content
provided.
The value edited by an **IEHTMLEditor** should be a string containing either the
URL or file name of the file that Internet Explorer should display. This is a
*read only* value that is not modified by the editor. Changing the value causes
the browser to display the page defined by the new value of the trait.
"""
#--[Imports]--------------------------------------------------------------------
from traitsui.wx.extra.windows.ie_html_editor \
import IEHTMLEditor
from traits.api \
import HasTraits, Str, List, Button
from traitsui.api \
import View, VGroup, HGroup, Item, TextEditor, ListEditor, spring
#--[WebPage Class]--------------------------------------------------------------
class WebPage ( HasTraits ):
# The URL to display:
url = Str( 'http://code.enthought.com' )
# The page title:
title = Str
# The page status:
status = Str
# The browser navigation buttons:
back = Button( '<--' )
forward = Button( '-->' )
home = Button( 'Home' )
stop = Button( 'Stop' )
refresh = Button( 'Refresh' )
search = Button( 'Search' )
# The view to display:
view = View(
HGroup( 'back', 'forward', 'home', 'stop', 'refresh', 'search', '_',
Item( 'status', style = 'readonly' ),
show_labels = False
),
Item( 'url',
show_label = False,
editor = IEHTMLEditor(
home = 'home', back = 'back',
forward = 'forward', stop = 'stop',
refresh = 'refresh', search = 'search',
title = 'title', status = 'status' )
)
)
#--[InternetExplorerDemo Class]-------------------------------------------------
class InternetExplorerDemo ( HasTraits ):
# A URL to display:
url = Str( 'http://' )
# The list of web pages being browsed:
pages = List( WebPage )
# The view to display:
view = View(
VGroup(
Item( 'url',
label = 'Location',
editor = TextEditor( auto_set = False, enter_set = True )
)
),
Item( 'pages',
show_label = False,
style = 'custom',
editor = ListEditor( use_notebook = True,
deletable = True,
dock_style = 'tab',
export = 'DockWindowShell',
page_name = '.title' )
)
)
# Event handlers:
def _url_changed ( self, url ):
self.pages.append( WebPage( url = url.strip() ) )
#--(Demo Notes)-----------------------------------------------------------------
"""
Demo Notes
==========
- Try dragging one of the browser tabs completely out of the tutorial window
and see what happens...
- Then, just for fun, try dragging it back...
"""
#--<Example*>-------------------------------------------------------------------
demo = InternetExplorerDemo(
pages = [ WebPage( url = 'http://code.enthought.com/traits/' ),
WebPage( url = 'http://dmorrill.com' ) ] )
|