~ubuntu-branches/ubuntu/utopic/python-traitsui/utopic

« back to all changes in this revision

Viewing changes to examples/demo/Extras/windows/internet_explorer.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-09 13:57:39 UTC
  • Revision ID: james.westby@ubuntu.com-20110709135739-x5u20q86huissmn1
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

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