1# Copyright (c) 2007, Enthought, Inc. 2# License: BSD Style. 3 4""" Demo showing how to use the Windows specific Internet Explorer editor. 5""" 6 7# Imports: 8from traitsui.wx.extra.windows.ie_html_editor \ 9 import IEHTMLEditor 10 11from traits.api \ 12 import Str, List, Button, HasTraits 13 14from traitsui.api \ 15 import View, VGroup, HGroup, Item, TextEditor, ListEditor 16 17# The web page class: 18 19 20class WebPage(HasTraits): 21 22 # The URL to display: 23 url = Str('http://code.enthought.com') 24 25 # The page title: 26 title = Str() 27 28 # The page status: 29 status = Str() 30 31 # The browser navigation buttons: 32 back = Button('<--') 33 forward = Button('-->') 34 home = Button('Home') 35 stop = Button('Stop') 36 refresh = Button('Refresh') 37 search = Button('Search') 38 39 # The view to display: 40 view = View( 41 HGroup('back', 'forward', 'home', 'stop', 'refresh', 'search', '_', 42 Item('status', style='readonly'), 43 show_labels=False 44 ), 45 Item('url', 46 show_label=False, 47 editor=IEHTMLEditor( 48 home='home', back='back', 49 forward='forward', stop='stop', 50 refresh='refresh', search='search', 51 title='title', status='status') 52 ) 53 ) 54 55# The demo class: 56 57 58class InternetExplorerDemo(HasTraits): 59 60 # A URL to display: 61 url = Str('http://') 62 63 # The list of web pages being browsed: 64 pages = List(WebPage) 65 66 # The view to display: 67 view = View( 68 VGroup( 69 Item('url', 70 label='Location', 71 editor=TextEditor(auto_set=False, enter_set=True) 72 ) 73 ), 74 Item('pages', 75 show_label=False, 76 style='custom', 77 editor=ListEditor(use_notebook=True, 78 deletable=True, 79 dock_style='tab', 80 export='DockWindowShell', 81 page_name='.title') 82 ) 83 ) 84 85 # Event handlers: 86 def _url_changed(self, url): 87 self.pages.append(WebPage(url=url.strip())) 88 89# Create the demo: 90demo = InternetExplorerDemo( 91 pages=[WebPage(url='http://code.enthought.com/projects/traits/'), 92 WebPage(url='http://dmorrill.com')]) 93 94# Run the demo (if invoked from the command line): 95if __name__ == '__main__': 96 demo.configure_traits() 97