how to keep my simple IE based on wxPython to staty in front of the window?

Hi everyone,
    I am new to wxPython and just made a simply IE
based on the example in demo of wxPython for my
project. Everything is fine with me
except the following features:
     1. How to keep this IE always to stay in front of
the window, i.e. even a user open another application,
this IE can stay at top of them.
     2. How to grab the content loaded by this IE
within wxPython? Here are the part of the code (see
the attached for details).

...
import wx.lib.iewin as iewin
...
self.ie = iewin.IEHtmlWindow(dlg, -1,
  style = wx.NO_FULL_REPAINT_ON_RESIZE )
...
self.ie.LoadUrl("http://www.google.com")
...

many thanks.

Ouyang

pyIE.py (2.02 KB)

···

#####################################
import wx

#import sys
#sys.setdefaultencoding('UTF-8')

if wx.Platform == '__WXMSW__':
    import wx.lib.iewin as iewin

class App(wx.App):
    def OnInit(self):
            title = 'test'
            dlg =
wx.Dialog(parent=None,id=-1,title=title,
          size=(800, 700), pos=(-1,-1),
          style=wx.SUNKEN_BORDER|wx.DEFAULT_DIALOG_STYLE)
            sizer = wx.BoxSizer(wx.VERTICAL)
            self.ie = iewin.IEHtmlWindow(dlg, -1,
          style = wx.NO_FULL_REPAINT_ON_RESIZE )
  
            sizer.Add(self.ie, 1, wx.EXPAND)
            self.location = wx.ComboBox(
                            dlg, -1, "",
style=wx.CB_DROPDOWN|wx.PROCESS_ENTER
                            )
            self.Bind(wx.EVT_COMBOBOX,
self.OnLocationSelect, self.location)
            self.location.Bind(wx.EVT_KEY_UP,
self.OnLocationKey)
            self.location.Bind(wx.EVT_CHAR,
self.IgnoreReturn)
            self.current = "http://www.google.com"
            self.ie.LoadUrl(self.current)
            self.location.Append(self.current)
            dlg.SetSizer(sizer)
            # Since this is a wxWindow we have to call
Layout ourselves
            self.Bind(wx.EVT_SIZE, self.OnSize)

      dlg.Bind(wx.EVT_CLOSE, self.OnClose)
            dlg.ShowModal()
            return True

    def OnClose(self, evt):
      wx.MessageBox("You can not close the window right
now. Sorry.",
          "That's all folks!")
      evt.Veto()
    
    def OnSize(self, evt):
        self.Layout()

    def OnLocationSelect(self, evt):
        url = self.location.GetStringSelection()
        self.log.write('OnLocationSelect: %s\n' % url)
        self.ie.Navigate(url)

    def OnLocationKey(self, evt):
        if evt.KeyCode() == wx.WXK_RETURN:
            URL = self.location.GetValue()
            self.location.Append(URL)
            self.ie.Navigate(URL)
        else:
            evt.Skip()

    def IgnoreReturn(self, evt):
        if evt.GetKeyCode() != wx.WXK_RETURN:
            evt.Skip()

if __name__ == '__main__':
    app = App()
    app.MainLoop()

#####################################

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

zhihua ouyang wrote:

Hi everyone,
    I am new to wxPython and just made a simply IE
based on the example in demo of wxPython for my
project. Everything is fine with me
except the following features:
     1. How to keep this IE always to stay in front of
the window, i.e. even a user open another application,
this IE can stay at top of them.

If you have a "legitimate" reason :wink: for it then use wx.STAY_ON_TOP style for the frame window. Otherwise see Tim's response.

     2. How to grab the content loaded by this IE
within wxPython?

self.ie.GetText()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!