我有一个带有QWebView和隐藏的开发Web检查器的对话框。我已经将QWebPage子类化为重新实现javaScriptConsoleMessage,以便在发生JS错误时显示检查器。但是,当我重新实现javaScriptConsoleMessage时,检查器停止工作 - 它是空白的。
class WebPage(QWebPage):
""" Makes it possible to use a Python logger to print javascript console messages """
def __init__(self, logger=None, parent=None):
super(WebPage, self).__init__(parent)
if not logger:
logger = logging
self.logger = logger
def javaScriptConsoleMessage(self, msg, lineNumber, sourceID):
self.logger.warning("JS " + sourceID + ":" + unicode(lineNumber) + "\n" + msg)
# code here to reveal inspector
我怎样才能让它发挥作用?