~ubuntu-branches/ubuntu/maverick/wxwidgets2.8/maverick-proposed

« back to all changes in this revision

Viewing changes to wxPython/demo/ActiveX_IEHtmlWindow.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2008-06-30 22:02:17 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080630220217-vag3tkfp91t0453d
Tags: 2.8.8.0-0ubuntu1
* New upstream version, based on the upstream tarball
  wxPython-src-2.8.8.0.tar.bz2, remove upstream debian dir (LP: #244355).
* Add debian/watch file, LP: #242164.
* Edit get-orig-source target to provide a .orig.tar.gz with the same md5 for
  each .orig.tar.gz generated.
* debian/rules: remove get-orig-source from .PHONY target.
* debian/control.in: add python-wxtools in python-wxgtk=V=U Suggests field.
* Do not apply fix_from_upstream_svn_r52465 patch, not needed.
* Regenerate octave_oct, tcl_tk_tcl patches for the new version.
* Fix spelling-error-in-description lintian warning.
* Fix depends-on-obsolete-package lintian error.
* Fix executable-not-elf-or-script lintian warnings.
* Fix script-not-executable lintian warnings.
* Fix missing-dependency-on-libc lintian error.
* Fix dbg-package-missing-depends lintian warnings.
* Fix package-contains-empty-directory lintian warnings.
* Fix manpage-has-errors-from-man lintian warning.
* Fix image-file-in-usr-lib lintian warnings:
  - add editra_pixmaps patch
  - add xrced_bitmaps patch
* Fix unused-override lintian info.
* Fix malformed-override lintian errors.
* Fix extra-license-file lintian warnings.
* Install upstream wx.pth instead of generated file links (LP: #211553).
* Add editra.png, pyshell.png (encoded using uuencode) icons, LP: #236876:
  - debian/rules: use uudecode to decode .png icons.
* Add a new pyshell.xpm icon.
* Fix doc-base-file-references-missing-file lintian error.
* Fix doc-base-unknown-section lintian warning.
* Fix ruby-script-but-no-ruby-dep lintian errors.
* Fix wish-script-but-no-wish-dep lintian errors.
* Fix missing-dep-for-interpreter errors.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import  wx
7
7
 
8
8
if wx.Platform == '__WXMSW__':
9
 
    import  wx.lib.iewin    as  iewin
 
9
    import wx.lib.iewin as iewin
10
10
 
11
11
#----------------------------------------------------------------------
12
12
 
27
27
        sizer = wx.BoxSizer(wx.VERTICAL)
28
28
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
29
29
 
30
 
        self.ie = iewin.IEHtmlWindow(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE)
 
30
        self.ie = iewin.IEHtmlWindow(self)
31
31
 
32
32
 
33
33
        btn = wx.Button(self, -1, "Open", style=wx.BU_EXACTFIT)
41
41
        btn = wx.Button(self, -1, "<--", style=wx.BU_EXACTFIT)
42
42
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
43
43
        btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
 
44
        self.Bind(wx.EVT_UPDATE_UI, self.OnCheckCanGoBack, btn)
44
45
 
45
46
        btn = wx.Button(self, -1, "-->", style=wx.BU_EXACTFIT)
46
47
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
47
48
        btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
 
49
        self.Bind(wx.EVT_UPDATE_UI, self.OnCheckCanGoForward, btn)
48
50
 
49
51
        btn = wx.Button(self, -1, "Stop", style=wx.BU_EXACTFIT)
50
52
        self.Bind(wx.EVT_BUTTON, self.OnStopButton, btn)
77
79
        self.location.Append(self.current)
78
80
 
79
81
        self.SetSizer(sizer)
80
 
        # Since this is a wxWindow we have to call Layout ourselves
 
82
        # Since this is a wx.Window we have to call Layout ourselves
81
83
        self.Bind(wx.EVT_SIZE, self.OnSize)
82
84
 
83
 
        # Hook up the event handlers for the IE window
84
 
        self.Bind(iewin.EVT_BeforeNavigate2, self.OnBeforeNavigate2, self.ie)
85
 
        self.Bind(iewin.EVT_NewWindow2, self.OnNewWindow2, self.ie)
86
 
        self.Bind(iewin.EVT_DocumentComplete, self.OnDocumentComplete, self.ie)
87
 
        ##self.Bind(iewin.EVT_ProgressChange,  self.OnProgressChange, self.ie)
88
 
        self.Bind(iewin.EVT_StatusTextChange, self.OnStatusTextChange, self.ie)
89
 
        self.Bind(iewin.EVT_TitleChange, self.OnTitleChange, self.ie)
 
85
 
 
86
        ## Hook up the event handlers for the IE window.  Using
 
87
        ## AddEventSink is how we tell the COM system to look in this
 
88
        ## object for method names matching the COM Event names.  They
 
89
        ## are automatically looked for in the ActiveXCtrl class, (so
 
90
        ## deriving a new class from IEHtmlWindow would also have been
 
91
        ## a good appraoch) and now they will be looked for here too.
 
92
        self.ie.AddEventSink(self)
 
93
 
90
94
 
91
95
 
92
96
    def ShutdownDemo(self):
98
102
    def OnSize(self, evt):
99
103
        self.Layout()
100
104
 
101
 
 
102
105
    def OnLocationSelect(self, evt):
103
106
        url = self.location.GetStringSelection()
104
107
        self.log.write('OnLocationSelect: %s\n' % url)
138
141
    def OnNextPageButton(self, event):
139
142
        self.ie.GoForward()
140
143
 
 
144
    def OnCheckCanGoBack(self, event):
 
145
        event.Enable(self.ie.CanGoBack())
 
146
        
 
147
    def OnCheckCanGoForward(self, event):
 
148
        event.Enable(self.ie.CanGoForward())
 
149
 
141
150
    def OnStopButton(self, evt):
142
151
        self.ie.Stop()
143
152
 
148
157
        self.ie.Refresh(iewin.REFRESH_COMPLETELY)
149
158
 
150
159
 
151
 
    def logEvt(self, evt):
152
 
        pst = ""
153
 
        for name in evt.paramList:
154
 
            pst += " %s:%s " % (name, repr(getattr(evt, name)))
155
 
        self.log.write('%s: %s\n' % (evt.eventName, pst))
156
 
 
157
 
 
158
 
    def OnBeforeNavigate2(self, evt):
159
 
        self.logEvt(evt)
160
 
 
161
 
    def OnNewWindow2(self, evt):
162
 
        self.logEvt(evt)
163
 
        # Veto the new window.  Cancel is defined as an "out" param
164
 
        # for this event.  See iewin.py
165
 
        evt.Cancel = True   
166
 
 
167
 
    def OnProgressChange(self, evt):
168
 
        self.logEvt(evt)
 
160
    # Here are some of the event methods for the IE COM events.  See
 
161
    # the MSDN docs for DWenBrowserEvents2 for details on what events
 
162
    # are available, and what the parameters are.
 
163
    
 
164
    def BeforeNavigate2(self, this, pDisp, URL, Flags, TargetFrameName,
 
165
                        PostData, Headers, Cancel):
 
166
        self.log.write('BeforeNavigate2: %s\n' % URL[0])
 
167
        if URL[0] == 'http://www.microsoft.com/':
 
168
            if wx.MessageBox("Are you sure you want to visit Microsoft?",
 
169
                             style=wx.YES_NO|wx.ICON_QUESTION) == wx.NO:
 
170
                # This is how you can cancel loading a page.  The
 
171
                # Cancel parameter is defined as an [in,out] type and
 
172
                # so setting the value means it will be returned and
 
173
                # checked in the COM control.
 
174
                Cancel[0] = True
 
175
                
 
176
 
 
177
    def OnNewWindow3(self, this, pDisp, Cancel, Flags, urlContext, URL):
 
178
        self.log.write('OnNewWindow2: %s\n' % URL)
 
179
        Cancel[0] = True   # Veto the creation of a  new window.
 
180
 
 
181
    #def ProgressChange(self, this, progress, progressMax):
 
182
    #    self.log.write('ProgressChange: %d of %d\n' % (progress, progressMax))
169
183
        
170
 
    def OnDocumentComplete(self, evt):
171
 
        self.logEvt(evt)
172
 
        self.current = evt.URL
 
184
    def DocumentComplete(self, this, pDisp, URL):
 
185
        self.current = URL[0]
173
186
        self.location.SetValue(self.current)
174
187
 
175
 
    def OnTitleChange(self, evt):
176
 
        self.logEvt(evt)
177
 
        if self.frame:
178
 
            self.frame.SetTitle(self.titleBase + ' -- ' + evt.Text)
179
 
 
180
 
    def OnStatusTextChange(self, evt):
181
 
        self.logEvt(evt)
182
 
        if self.frame:
183
 
            self.frame.SetStatusText(evt.Text)
184
 
 
 
188
    def TitleChange(self, this, Text):
 
189
        if self.frame:
 
190
            self.frame.SetTitle(self.titleBase + ' -- ' + Text)
 
191
 
 
192
    def StatusTextChange(self, this, Text):
 
193
        if self.frame:
 
194
            self.frame.SetStatusText(Text)
 
195
 
 
196
        
185
197
 
186
198
#----------------------------------------------------------------------
187
199
# for the demo framework...
223
235
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
224
236
 
225
237
 
 
238
 
226
239
#----------------------------------------------------------------------
227
240