|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Hi, I encountered some problems when using wxPython :
1. I'm using a frame that includes wx.lib.iewin the Html page will include text and links. I would like to able to : 1.1 Capture the click event on the link 1.2 Cancel the click event so that the ActiveX browser won't navigate. 1.3 Open IE app with that link info The problem: 1.4 Which event does this ActiveX exposes so I can hook up to it? ( I couldn't find ANY documentation) 2. How to get the IE app path from the registry? ( and then use os.system(path) to run IE ) ( I tried to used the absolute path, but it doesn't work as well os.system("C:\\Program Files\\Internet\Explorer\\iexplore.exe") ) 2. Regarding raising events: I defined custom event class, and Icon class ( which creates an icon on the task bar). On dbl click on the icon, I want to raise custom event ( so listeners can hook up to it) , but since Icon class is a 'plain one ' - it doesn't have GetEventHandler() method What is the best way to achieve that? The code is attached: ###### The custom event class ######## import sys import wx class CustomEvt(wx.PyCommandEvent): def __init__(self, evtType, id=-1): wx.PyCommandEvent.__init__(self, evtType, id) self.myVal = None def SetMyVal(self, val): self.myVal = val def GetMyVal(self): return self.myVal ########## The IconClass ########## from wxPython.wx import * import sys from CustomeEvent import CustomEvt # custome Events myEVT_ICON_DBLCLICKED = wxNewEventType() EVT_ICON_DBLCLICKED = wxPyEventBinder(myEVT_ICON_DBLCLICKED, 0) class Icon(): def __init__(self): # instantiate task bar icon self.tbicon = wxTaskBarIcon() # set icon self.updateIcon() # set up event handlers to catch tray icon events EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnLeftDblClick) wxInitAllImageHandlers() return None def updateIcon(self): self.tbicon.SetIcon(wxIcon('icon1.ico', wxBITMAP_TYPE_ICO), '') def OnLeftDblClick(self,event): evt = CustomEvt(myEVT_ICON_DBLCLICKED) self.GetEventHandler().ProcessEvent(evt) event.Skip() Thanks a lot Roy |
|
#2
|
||||
|
||||
|
One thing you can do is define your own event handler for the pre-navigate event.
Code:
EVT_MSHTML_BEFORENAVIGATE2(self, -1, self.OnBeforeNavigate2)
def OnBeforeNavigate2(self, evt):
if evt.GetText1().find(self.homepage) != 0:
self.ie.Navigate(self.homepage)
The success of this is site dependent. You could combine that with a call to the webbrowser module. Have a look at the wx Demo it uses the taskbar icon and has it's own menu. Tip: when posting code use a code block to get the indentation right!
__________________
*** Experimental Python Markup CGI V2 *** |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > wxPython questions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|