本文整理汇总了Python中view.View.page方法的典型用法代码示例。如果您正苦于以下问题:Python View.page方法的具体用法?Python View.page怎么用?Python View.page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view.View
的用法示例。
在下文中一共展示了View.page方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Window
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import page [as 别名]
class Window(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setupTrayIcon()
self.setIcon()
self.trayIcon.show()
self.setupView()
self.view.load(QUrl(config.WX_URL))
self.view.setZoomFactor(self.physicalDpiX() * 0.008)
self.setupLayout()
QNetworkProxy.setApplicationProxy(proxy)
def setupView(self):
self.view = View(self)
self.populateJavaScript()
def setupLayout(self):
layout = QVBoxLayout(self)
layout.addWidget(self.view)
def showFront(self):
self.setWindowState(self.windowState() & ~Qt.WindowMinimized)
self.activateWindow()
self.show()
def quitApp(self):
QApplication.instance().quit()
def setupTrayIcon(self):
self.trayIcon = TrayIcon(self)
self.trayIcon.setup(self.showFront, self.quitApp)
def setIcon(self):
icon = QIcon(config.icon_path)
self.trayIcon.setIcon(icon)
self.setWindowIcon(icon)
def populateJavaScript(self):
with open(config.inject_js_path, "r") as f:
injectJS = f.read()
self.view.page().runJavaScript(injectJS)
示例2: Window
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import page [as 别名]
class Window(QWidget):
def __init__(self, dbg=False):
super(Window, self).__init__()
self.view = View(self)
s = QShortcut(self)
s.setKey(Qt.Key_Tab)
s.activated.connect(self.tabKeyPressed)
self.splitter = QSplitter(self)
self.splitter.setOrientation(Qt.Vertical)
layout = QVBoxLayout(self)
layout.setMargin(0)
layout.addWidget(self.splitter)
self.splitter.addWidget(self.view)
if dbg:
self.setupInspector()
self.splitter.addWidget(self.inspector)
else:
self.view.mouseDoubleClickEvent = lambda e: e.ignore()
self.view.mouseMoveEvent = lambda e: e.ignore()
self.view.mousePressEvent = lambda e: e.ignore()
self.view.mouseReleaseEvent = lambda e: e.ignore()
self.view.wheelEvent = lambda e: e.ignore()
self.view.setContextMenuPolicy(Qt.NoContextMenu)
def tabKeyPressed(self):
e = QKeyEvent(QEvent.KeyPress, Qt.Key_Tab, Qt.NoModifier)
self.view.keyReleaseEvent(e)
def setupInspector(self):
page = self.view.page()
page.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
self.inspector = QWebInspector(self)
self.inspector.setPage(page)
shortcut = QShortcut(self)
shortcut.setKey(Qt.Key_F12)
shortcut.activated.connect(self.toggleInspector)
self.inspector.setVisible(False)
def toggleInspector(self):
self.inspector.setVisible(not self.inspector.isVisible())
def closeEvent(self, event):
App.backend.evalJS('ui.saveState()')
pass