| 1 |
# (C) Copyright 2004-2023 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
|
| 11 |
""" Demo showing how to use the Windows specific Internet Explorer editor. |
| 12 |
""" |
| 13 |
|
| 14 |
# Imports: |
| 15 |
from traitsui.wx.extra.windows.ie_html_editor import IEHTMLEditor |
| 16 |
|
| 17 |
from traits.api import Str, List, Button, HasTraits |
| 18 |
|
| 19 |
from traitsui.api import View, VGroup, HGroup, Item, TextEditor, ListEditor |
| 20 |
|
| 21 |
# The web page class: |
| 22 |
|
| 23 |
|
| 24 |
class WebPage(HasTraits): |
| 25 |
|
| 26 |
# The URL to display: |
| 27 |
url = Str('http://code.enthought.com') |
| 28 |
|
| 29 |
# The page title: |
| 30 |
title = Str() |
| 31 |
|
| 32 |
# The page status: |
| 33 |
status = Str() |
| 34 |
|
| 35 |
# The browser navigation buttons: |
| 36 |
back = Button('<--') |
| 37 |
forward = Button('-->') |
| 38 |
home = Button('Home') |
| 39 |
stop = Button('Stop') |
| 40 |
refresh = Button('Refresh') |
| 41 |
search = Button('Search') |
| 42 |
|
| 43 |
# The view to display: |
| 44 |
view = View( |
| 45 |
HGroup( |
| 46 |
'back', |
| 47 |
'forward', |
| 48 |
'home', |
| 49 |
'stop', |
| 50 |
'refresh', |
| 51 |
'search', |
| 52 |
'_', |
| 53 |
Item('status', style='readonly'), |
| 54 |
show_labels=False, |
| 55 |
), |
| 56 |
Item( |
| 57 |
'url', |
| 58 |
show_label=False, |
| 59 |
editor=IEHTMLEditor( |
| 60 |
home='home', |
| 61 |
back='back', |
| 62 |
forward='forward', |
| 63 |
stop='stop', |
| 64 |
refresh='refresh', |
| 65 |
search='search', |
| 66 |
title='title', |
| 67 |
status='status', |
| 68 |
), |
| 69 |
), |
| 70 |
) |
| 71 |
|
| 72 |
|
| 73 |
# The demo class: |
| 74 |
|
| 75 |
|
| 76 |
class InternetExplorerDemo(HasTraits): |
| 77 |
|
| 78 |
# A URL to display: |
| 79 |
url = Str('http://') |
| 80 |
|
| 81 |
# The list of web pages being browsed: |
| 82 |
pages = List(WebPage) |
| 83 |
|
| 84 |
# The view to display: |
| 85 |
view = View( |
| 86 |
VGroup( |
| 87 |
Item( |
| 88 |
'url', |
| 89 |
label='Location', |
| 90 |
editor=TextEditor(auto_set=False, enter_set=True), |
| 91 |
) |
| 92 |
), |
| 93 |
Item( |
| 94 |
'pages', |
| 95 |
show_label=False, |
| 96 |
style='custom', |
| 97 |
editor=ListEditor( |
| 98 |
use_notebook=True, |
| 99 |
deletable=True, |
| 100 |
dock_style='tab', |
| 101 |
export='DockWindowShell', |
| 102 |
page_name='.title', |
| 103 |
), |
| 104 |
), |
| 105 |
) |
| 106 |
|
| 107 |
# Event handlers: |
| 108 |
def _url_changed(self, url): |
| 109 |
self.pages.append(WebPage(url=url.strip())) |
| 110 |
|
| 111 |
|
| 112 |
# Create the demo: |
| 113 |
demo = InternetExplorerDemo( |
| 114 |
pages=[ |
| 115 |
WebPage(url='http://code.enthought.com/projects/traits/'), |
| 116 |
WebPage(url='http://dmorrill.com'), |
| 117 |
] |
| 118 |
) |
| 119 |
|
| 120 |
# Run the demo (if invoked from the command line): |
| 121 |
if __name__ == '__main__': |
| 122 |
demo.configure_traits() |