Launching Dialogs from hyperlink clicks

I have a question regarding 2.5.1.5 and iewin.IEHtmlWindow (on Python
2.3 and Windows XP, if that matters).

I'd like to be able to "catch" hyperlink-clicks on the IE rendered HTML and, depending on the link clicked, either:
     1. change the HTML on display (provide IE with new
        HTML as string); or
     2. show a wizard or other dialog

I've figured out that I need to catch IE's 'OnBeforeNavigate2' events and:
     1. set evt.Cancel to True, stopping IE from further
        processing of the url
     2. Use the LoadString() method to change the rendered
        HTML
     3. Or just launch the dialog/wizard ...

Point 3 has me a bit worried. Its working but I'm wondering what's happening with all the event loops. The dialog will need an event loop, but I'm obviously getting a call out from an event loop ...

So, will this starting an event loop from inside an event loop callback approach start to have problems later? Is there some more robust way of doing this? Perhaps its all just find as is?

My (rather straight-forward) code for OnBeforeNavigate2() is here:

def OnBeforeNavigate2(self, evt):

     # Cancel IE's URL load, we'll look after it
     evt.Cancel = True

     # now process the URL
     if evt.URL == "http://changeHTML/":
         self.ie.LoadString(anHTMLstring)
     else:
         dlg = wx.MessageDialog(self, 'Hello from OnBeforeNav2()',
                           'A Message Box', wx.OK | wx.ICON_INFORMATION)
         dlg.ShowModal()
         dlg.Destroy()

Cheers,
Mike

Mike Thompson wrote:

    3. Or just launch the dialog/wizard ...

Point 3 has me a bit worried. Its working but I'm wondering what's happening with all the event loops. The dialog will need an event loop, but I'm obviously getting a call out from an event loop ...

So, will this starting an event loop from inside an event loop callback approach start to have problems later? Is there some more robust way of doing this? Perhaps its all just find as is?

If you ShowModal a dialog from a button or a menu event handler then the same thing happens. You are starting a new event loop in that case too, it is designed to work this way. There are a few situations however where showing a modal dialog is not a good idea, such as when the window has the mouse captured during an event. In those cases (or anytime you are in doubt) you can use wx.CallAfter to call a function in the next idle event that will show your modal dialog.

···

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