本文整理汇总了Python中PyQt4.QtWebKit.QWebInspector类的典型用法代码示例。如果您正苦于以下问题:Python QWebInspector类的具体用法?Python QWebInspector怎么用?Python QWebInspector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWebInspector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_inspector
def show_inspector(self, event=None):
"""Show the web inspector."""
if not self.inspector:
inspect = QWebInspector()
inspect.setPage(self.page())
self.inspector = inspect
self.inspector.show()
示例2: WebView
class WebView(QWebView):
def __init__(self, parent=None):
QWebView.__init__(self, parent)
self.inspector = QWebInspector(self)
w = QApplication.instance().desktop().availableGeometry(self).width()
self._size_hint = QSize(int(w/3), int(w/2))
settings = self.page().settings()
apply_settings(settings, config().parse())
settings.setMaximumPagesInCache(0)
settings.setAttribute(settings.JavaEnabled, False)
settings.setAttribute(settings.PluginsEnabled, False)
settings.setAttribute(settings.PrivateBrowsingEnabled, True)
settings.setAttribute(settings.JavascriptCanOpenWindows, False)
settings.setAttribute(settings.JavascriptCanAccessClipboard, False)
settings.setAttribute(settings.LinksIncludedInFocusChain, False)
settings.setAttribute(settings.DeveloperExtrasEnabled, True)
settings.setDefaultTextEncoding('utf-8')
self.page().setNetworkAccessManager(NetworkAccessManager(self))
self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
self.clear()
def sizeHint(self):
return self._size_hint
def refresh(self):
self.pageAction(self.page().Reload).trigger()
@dynamic_property
def scroll_pos(self):
def fget(self):
mf = self.page().mainFrame()
return (mf.scrollBarValue(Qt.Horizontal), mf.scrollBarValue(Qt.Vertical))
def fset(self, val):
mf = self.page().mainFrame()
mf.setScrollBarValue(Qt.Horizontal, val[0])
mf.setScrollBarValue(Qt.Vertical, val[1])
return property(fget=fget, fset=fset)
def clear(self):
self.setHtml('<p>')
def inspect(self):
self.inspector.parent().show()
self.inspector.parent().raise_()
self.pageAction(self.page().InspectElement).trigger()
def contextMenuEvent(self, ev):
menu = QMenu(self)
menu.addAction(actions['reload-preview'])
menu.addAction(QIcon(I('debug.png')), _('Inspect element'), self.inspect)
menu.exec_(ev.globalPos())
示例3: toggleInspector
def toggleInspector(self):
if self.__inspector_window is None:
self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
web_inspector = QWebInspector()
web_inspector.setPage(self.page())
self.__inspector_window = QMainWindow(self)
self.__inspector_window.setCentralWidget(web_inspector)
self.__inspector_window.resize(900, 600)
self.__inspector_window.setVisible(False)
self.__inspector_window.setVisible(not self.__inspector_window.isVisible())
示例4: _page_loaded
def _page_loaded(self, success):
if self.develop and self.display:
if self.inspector is None:
self.inspector = QWebInspector()
self.inspector.setPage(self.page)
self.inspector.show()
scripts = [
'atoms.js',
'htmlutils.js',
]
if self.jquery_namespace:
scripts.append('jquery-1.9.1.min.js', )
for script in scripts:
self.evaluate_js_file(os.path.dirname(__file__) + '/javascripts/' + script)
if self.jquery_namespace:
self.evaluate(u"%s=jQuery.noConflict();" % self.jquery_namespace)
self._loaded = True
# self.cache.clear()
logger.debug("Page load finished")
示例5: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
vbox = QVBoxLayout(self)
self._webInspector = QWebInspector(self)
vbox.addWidget(self._webInspector)
self.btnDock = QPushButton(translations.TR_UNDOCK)
vbox.addWidget(self.btnDock)
ExplorerContainer.register_tab(translations.TR_TAB_WEB_INSPECTOR, self)
示例6: toggle_inspector
def toggle_inspector():
if self._inspector:
self._inspector.setVisible(not self._inspector.isVisible())
else:
# create the inspector "on demand"
page.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
self._inspector = QWebInspector(self)
self._inspector.setPage(page)
self.splitter.addWidget(self._inspector)
示例7: __init__
def __init__(self, parent=None):
QWebView.__init__(self, parent)
self.inspector = QWebInspector(self)
w = QApplication.instance().desktop().availableGeometry(self).width()
self._size_hint = QSize(int(w/3), int(w/2))
self._page = WebPage(self)
self.setPage(self._page)
self.inspector.setPage(self._page)
self.clear()
示例8: WebInspector
class WebInspector(QDialog):
def __init__(self, parent, page):
QDialog.__init__(self, parent)
self.setWindowTitle(_('Inspect book code'))
self.setWindowIcon(QIcon(I('debug.png')))
l = QVBoxLayout()
self.setLayout(l)
self.inspector = QWebInspector(self)
self.inspector.setPage(page)
l.addWidget(self.inspector)
self.bb = bb = QDialogButtonBox(QDialogButtonBox.Close)
l.addWidget(bb)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
self.resize(self.sizeHint())
geom = gprefs.get('viewer_inspector_geom', None)
if geom is not None:
self.restoreGeometry(geom)
def save_geometry(self):
gprefs['viewer_inspector_geom'] = bytearray(self.saveGeometry())
def closeEvent(self, ev):
self.save_geometry()
return QDialog.closeEvent(self, ev)
def accept(self):
self.save_geometry()
QDialog.accept(self)
def reject(self):
self.save_geometry()
QDialog.reject(self)
示例9: WebView
class WebView(QWebView):
def __init__(self, parent=None):
QWebView.__init__(self, parent)
self.inspector = QWebInspector(self)
w = QApplication.instance().desktop().availableGeometry(self).width()
self._size_hint = QSize(int(w/3), int(w/2))
self._page = WebPage(self)
self.setPage(self._page)
self.inspector.setPage(self._page)
self.clear()
def sizeHint(self):
return self._size_hint
def refresh(self):
self.pageAction(self.page().Reload).trigger()
@dynamic_property
def scroll_pos(self):
def fget(self):
mf = self.page().mainFrame()
return (mf.scrollBarValue(Qt.Horizontal), mf.scrollBarValue(Qt.Vertical))
def fset(self, val):
mf = self.page().mainFrame()
mf.setScrollBarValue(Qt.Horizontal, val[0])
mf.setScrollBarValue(Qt.Vertical, val[1])
return property(fget=fget, fset=fset)
def clear(self):
self.setHtml(_(
'''
<h3>Live preview</h3>
<p>Here you will see a live preview of the HTML file you are currently editing.
The preview will update automatically as you make changes.
<p style="font-size:x-small; color: gray">Note that this is a quick preview
only, it is not intended to simulate an actual ebook reader. Some
aspects of your ebook will not work, such as, page breaks,
page margins and embedded fonts that use font name aliasing.
'''))
def inspect(self):
self.inspector.parent().show()
self.inspector.parent().raise_()
self.pageAction(self.page().InspectElement).trigger()
def contextMenuEvent(self, ev):
menu = QMenu(self)
ca = self.pageAction(QWebPage.Copy)
if ca.isEnabled():
menu.addAction(ca)
menu.addAction(actions['reload-preview'])
menu.addAction(QIcon(I('debug.png')), _('Inspect element'), self.inspect)
menu.exec_(ev.globalPos())
示例10: WebInspector
class WebInspector(QWidget):
def __init__(self, parent):
QWidget.__init__(self, parent)
vbox = QVBoxLayout(self)
self._webInspector = QWebInspector(self)
vbox.addWidget(self._webInspector)
self.btnDock = QPushButton(translations.TR_UNDOCK)
vbox.addWidget(self.btnDock)
ExplorerContainer.register_tab(translations.TR_TAB_WEB_INSPECTOR, self)
def refresh_inspector(self):
self._webInspector.hide()
self._webInspector.show()
def set_inspection_page(self, page):
self._webInspector.setPage(page)
self._webInspector.setVisible(True)
示例11: __init__
def __init__(self, parent=None):
QWebView.__init__(self, parent)
self.inspector = QWebInspector(self)
w = QApplication.instance().desktop().availableGeometry(self).width()
self._size_hint = QSize(int(w/3), int(w/2))
settings = self.page().settings()
apply_settings(settings, config().parse())
settings.setMaximumPagesInCache(0)
settings.setAttribute(settings.JavaEnabled, False)
settings.setAttribute(settings.PluginsEnabled, False)
settings.setAttribute(settings.PrivateBrowsingEnabled, True)
settings.setAttribute(settings.JavascriptCanOpenWindows, False)
settings.setAttribute(settings.JavascriptCanAccessClipboard, False)
settings.setAttribute(settings.LinksIncludedInFocusChain, False)
settings.setAttribute(settings.DeveloperExtrasEnabled, True)
settings.setDefaultTextEncoding('utf-8')
self.page().setNetworkAccessManager(NetworkAccessManager(self))
self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
self.clear()
示例12: WebInspector
class WebInspector(QWidget):
"""WebInspector widget class"""
def __init__(self, parent):
QWidget.__init__(self, parent)
vbox = QVBoxLayout(self)
self._webInspector = QWebInspector(self)
vbox.addWidget(self._webInspector)
self.btnDock = QPushButton(translations.TR_UNDOCK)
vbox.addWidget(self.btnDock)
ExplorerContainer.register_tab(translations.TR_TAB_WEB_INSPECTOR, self)
IDE.register_service('web_inspector', self)
def refresh_inspector(self):
"""Refresh WebInspector widget by hiding and showing"""
self._webInspector.hide()
self._webInspector.show()
def set_inspection_page(self, page):
"""Method to load an argument page object on the WebInspector"""
self._webInspector.setPage(page)
self._webInspector.setVisible(True)
示例13: WebView
class WebView(QWebView):
def __init__(self, parent=None):
QWebView.__init__(self, parent)
self.inspector = QWebInspector(self)
w = QApplication.instance().desktop().availableGeometry(self).width()
self._size_hint = QSize(int(w/3), int(w/2))
self._page = WebPage(self)
self.setPage(self._page)
self.inspector.setPage(self._page)
self.clear()
def sizeHint(self):
return self._size_hint
def refresh(self):
self.pageAction(self.page().Reload).trigger()
@dynamic_property
def scroll_pos(self):
def fget(self):
mf = self.page().mainFrame()
return (mf.scrollBarValue(Qt.Horizontal), mf.scrollBarValue(Qt.Vertical))
def fset(self, val):
mf = self.page().mainFrame()
mf.setScrollBarValue(Qt.Horizontal, val[0])
mf.setScrollBarValue(Qt.Vertical, val[1])
return property(fget=fget, fset=fset)
def clear(self):
self.setHtml('<p>')
def inspect(self):
self.inspector.parent().show()
self.inspector.parent().raise_()
self.pageAction(self.page().InspectElement).trigger()
def contextMenuEvent(self, ev):
menu = QMenu(self)
menu.addAction(actions['reload-preview'])
menu.addAction(QIcon(I('debug.png')), _('Inspect element'), self.inspect)
menu.exec_(ev.globalPos())
示例14: GRobot
#.........这里部分代码省略.........
while not condition():
if time_for_stop != -1 and time.time() > (started_at + time_for_stop):
if self._loaded:
raise OperateTimeout, timeout_message
else:
# raise LoadingTimeout, timeout_message
self.trigger_action('Stop') #QWebPage::Stop
self._loaded = True
logger.warning("Page loading timeout.Force to stop the page")
break
gevent.sleep(2)
def wait_for_alert(self):
"""Waits for main frame alert().
"""
self.wait_for(lambda: self._alert is not None,
'User has not been alerted.')
msg, self._alert = self._alert, None
return msg
def _release_last_resources(self):
"""Releases last loaded resources.
:return: The released resources.
"""
last_resources, self.http_resources = self.http_resources[:], []
return last_resources
def _page_loaded(self, success):
if self.develop and self.display:
if self.inspector is None:
self.inspector = QWebInspector()
self.inspector.setPage(self.page)
self.inspector.show()
scripts = [
'atoms.js',
'htmlutils.js',
]
if self.jquery_namespace:
scripts.append('jquery-1.9.1.min.js', )
for script in scripts:
self.evaluate_js_file(os.path.dirname(__file__) + '/javascripts/' + script)
if self.jquery_namespace:
self.evaluate(u"%s=jQuery.noConflict();" % self.jquery_namespace)
self._loaded = True
# self.cache.clear()
logger.debug("Page load finished")
def _page_load_started(self):
logger.debug("Start load page")
self._loaded = False
def _unsupported_content(self, reply):
"""Adds an HttpResource object to http_resources with unsupported
content.
@param reply: The QNetworkReply object.
示例15: __init__
def __init__(self, urls, parent=None):
KParts.MainWindow.__init__(self, parent)
QWebSettings.globalSettings().setAttribute(
QWebSettings.DeveloperExtrasEnabled, True)
self.setWindowIcon(KIcon('text-editor'))
self.kate = KTextEditor.EditorChooser.editor()
self.editor = self.kate.createDocument(self).createView(self)
doc = self.editor.document()
self.editor.setContextMenu(self.editor.defaultContextMenu())
sizegrip = create_grip(self.editor)
sizegrip.show() #TODO: only show on windowstate change
self.renderer = Renderer(self)
@doc.textChanged.connect
def _start_markdown(doc=None, old_range=None, new_range=None):
"""Runs the renderer if it’s not currently rendering"""
if not self.renderer.isRunning():
self.renderer.start()
@self.renderer.finished.connect
def _stop_markdown():
"""
Replaces the preview HTML with the newly rendered one
and restores the scroll position
"""
url = self.editor.document().url().resolved(QUrl('.'))
self.preview.setHtml(self.renderer.html, url) #baseurl für extenes zeug
self.preview.page().mainFrame().setScrollPosition(self.renderer.scrollpos)
self.editor.document().documentNameChanged.connect(self.refresh_document)
self.guiFactory().addClient(self.editor)
self.setCentralWidget(self.editor)
self.toolbar = KToolBar(i18n('Markdowner Toolbar'), self)
self.toolbar.setWindowTitle(self.toolbar.objectName())
self.preview_button = self.toolbar.addAction(KIcon('document-preview'), i18n('Show Preview'))
self.preview_button.setCheckable(True)
self.preview = QWebView()
self.preview.settings().setUserStyleSheetUrl(base64css())
self.preview.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.preview.linkClicked.connect(self.intercept_link)
with self.setup_dock(self.preview, i18n('Preview'), Qt.RightDockWidgetArea) as dock:
page = self.preview.page()
palette = page.palette()
palette.setBrush(QPalette.Base, Qt.transparent)
page.setPalette(palette)
self.preview.setAttribute(Qt.WA_TranslucentBackground)
self.preview.setAttribute(Qt.WA_OpaquePaintEvent, False)
dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
dock.visibilityChanged.connect(self.preview_button.setChecked)
self.preview_button.triggered.connect(dock.setVisible)
inspector = QWebInspector()
with self.setup_dock(inspector, i18n('Inspector'), Qt.BottomDockWidgetArea) as dock:
inspector.setPage(self.preview.page())
dock.hide()
inspect_action = self.preview.page().action(QWebPage.InspectElement)
inspect_action.triggered.connect(dock.show)
if len(urls) != 0:
self.editor.document().openUrl(urls[0])
#TODO: spellcheck
self.setAutoSaveSettings()
self.kate.readConfig(self.autoSaveConfigGroup().config())