質問

I'm using wxPython, and I've come into trouble. Basically, all I need is a basic htmlwindow, with forward and backwards buttons, but I have trouble when people click on links in the page. There seems to be no event that happens after a page is loaded, only when a link is clicked, so I cannot check to see if the forward/back buttons need to be updated.

Here is some stuff I've tried:

def log_link_clicked(self, evt):
    evt.Skip()
    self.log_check_history()

I thought I might be able to skip the event for link clicked which would load it and then call my check_history() method to update my buttons, but that didn't work.

Also I tried doing this too:

class BetterHtmlWindow(wx.html.HtmlWindow):
    def __init__(self, parent, window_id, pos, size, style, name = 'htmlWindow', frame=None):
        super(BetterHtmlWindow,self).__init__(parent,window_id,pos,size,style,name)
        self.frame = frame

    def __OnOpeningURL(self, type, url, redirect):
        res = super(BetterHtmlWindow,self).OnOpeningURL(type,url,redirect)
        self.LoadPage(url)
        self.frame.log_check_history()

Overwriting the method that happens on opening url, but that gave me nothing too.

Any ideas?

Thanks in advance. :)

役に立ちましたか?

解決

I just figured out how to do it. I had to override the LoadPage method, and override the link_clicked event to call my overridden version

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top