def fake_windows(win_registry, stubs, monkeypatch, qtbot): """Fixture which provides two fake main windows and tabbedbrowsers.""" win_registry.add_window(1) win0 = FakeMainWindow(b'fake-geometry-0', win_id=0) win1 = FakeMainWindow(b'fake-geometry-1', win_id=1) objreg.register('main-window', win0, scope='window', window=0) objreg.register('main-window', win1, scope='window', window=1) webview0 = QWebView() qtbot.add_widget(webview0) webview1 = QWebView() qtbot.add_widget(webview1) webview2 = QWebView() qtbot.add_widget(webview2) webview3 = QWebView() qtbot.add_widget(webview3) browser0 = FakeTabbedBrowser([webview0, webview1]) browser1 = FakeTabbedBrowser([webview2, webview3]) objreg.register('tabbed-browser', browser0, scope='window', window=0) objreg.register('tabbed-browser', browser1, scope='window', window=1) qapp = stubs.FakeQApplication(active_window=win0) monkeypatch.setattr('qutebrowser.misc.sessions.QApplication', qapp) yield browser0, browser1 objreg.delete('main-window', scope='window', window=0) objreg.delete('main-window', scope='window', window=1) objreg.delete('tabbed-browser', scope='window', window=0) objreg.delete('tabbed-browser', scope='window', window=1)
def __init__(self, url, process=None, parent=None): super(BrowserWidget, self).__init__(parent) self._process = process vbox = QVBoxLayout(self) #Web Frame if QT_VERSION < 0x50700: self.webFrame = QWebView(self) else: self.webFrame = QWebEngineView(self) self.webFrame.setAcceptDrops(False) self.webFrame.load(QUrl(url)) vbox.addWidget(self.webFrame) if process is not None: time.sleep(0.5) self.webFrame.load(QUrl(url)) if QT_VERSION < 0x50700: self.webFrame.page().currentFrame().setScrollBarPolicy( Qt.Vertical, Qt.ScrollBarAsNeeded) self.webFrame.page().currentFrame().setScrollBarPolicy( Qt.Horizontal, Qt.ScrollBarAsNeeded)
def __init__(self, opts, log, cover_data=None, toc=None): from calibre.gui2 import must_use_qt must_use_qt() QObject.__init__(self) self.logger = self.log = log self.mathjax_dir = P('mathjax', allow_user_override=False) current_log(log) self.opts = opts self.cover_data = cover_data self.paged_js = None self.toc = toc self.loop = QEventLoop() self.view = QWebView() self.page = Page(opts, self.log) self.view.setPage(self.page) self.view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.view.loadFinished.connect(self.render_html, type=Qt.QueuedConnection) self.view.loadProgress.connect(self.load_progress) self.ignore_failure = None self.hang_check_timer = t = QTimer(self) t.timeout.connect(self.hang_check) t.setInterval(1000) for x in (Qt.Horizontal, Qt.Vertical): self.view.page().mainFrame().setScrollBarPolicy( x, Qt.ScrollBarAlwaysOff) self.report_progress = lambda x, y: x self.current_section = '' self.current_tl_section = ''
def __init__(self): super(phpCliBrowser, self).__init__() # Make sure cache directory exists. In it we compile and store result html file if not os.path.isdir(self.cacheDir): os.makedirs(self.cacheDir) # Copy globals.php script to cache directory so that it will simplify the inclusion # of POST/GET/SESSION variables if not os.path.isfile(self.cacheDir + os.path.sep + 'globals.php'): copyfile(self.browserDir + os.path.sep + 'globals.php', self.cacheDir + os.path.sep + 'globals.php') # Read program's command line arguments self.parse_args() self.uriCache = 'file://' + self.cacheDir + os.path.sep # Start browser window pointing to php program index self.wb = QWebView(self) self.wb.loadFinished.connect(self.onLoadFinished) self.outputPhpScript(self.index) # Set initial icon if exists in the php script directory: #self.iconPath = self.scriptDir + os.path.sep + 'icon.ico' #if os.path.isfile(self.iconPath): # self.setWindowIcon(QIcon(self.iconPath)) self.setCentralWidget(self.wb)
def __init__(self): super().__init__() self.setWindowTitle('Expression Tree Viewer') self.setWindowIcon(QtGui.QIcon(os.path.join(app_path, 'icon.png'))) self.resize(280, 380) self.form_layout = QtWidgets.QVBoxLayout() self.expression_layout = QtWidgets.QHBoxLayout() self.expression_label = QtWidgets.QLabel('Expression') self.expression_box = QtWidgets.QLineEdit('') self.expression_label.setBuddy(self.expression_box) self.expression_layout.addWidget(self.expression_label) self.expression_layout.addWidget(self.expression_box) self.expression_layout.addItem(QtWidgets.QSpacerItem( 40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum )) self.tree_view = QWebView() self.tree_view.setHtml('') self.form_layout.addLayout(self.expression_layout) self.form_layout.addWidget(self.tree_view) self.expression_box.textChanged.connect(self.render_expression) self.setLayout(self.form_layout) self.page = lxml.etree.Element('html') self.head = lxml.etree.SubElement(self.page, 'head') self.body = lxml.etree.SubElement(self.page, 'body') self.style = lxml.etree.SubElement(self.head, 'style') with open(os.path.join(app_path, 'styles.css'), 'r') as file_handler: self.style.text = file_handler.read()
def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) self.setAttribute(Qt.WA_TranslucentBackground, True) # 设置父控件Widget背景透明 self.setWindowFlags(Qt.FramelessWindowHint) # 去掉边框 palette = self.palette() palette.setBrush(QPalette.Base, Qt.transparent) # 父控件背景透明 self.setPalette(palette) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) # QWebSettings.globalSettings().setAttribute( # QWebSettings.DeveloperExtrasEnabled, True)# web开发者工具 self.webView = QWebView(self) # 网页控件 layout.addWidget(self.webView) self.webView.setContextMenuPolicy(Qt.NoContextMenu) # 去掉右键菜单 self.mainFrame = self.webView.page().mainFrame() self.mainFrame.setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) # 去掉滑动条 self.mainFrame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) # 最大化 rect = app.desktop().availableGeometry() self.resize(rect.size()) self.webView.resize(rect.size())
def __make_gui(self): self.text_edit = QTextEdit() self.main_layout.addWidget(self.text_edit) #--- подсветка синтаксиса # self.hh = PythonHighlighter(self.text_edit.document()) # self.hh = MarkdownHighlighter(self.text_edit) self.web = QWebView() self.main_layout.addWidget(self.web) # self.web.setHtml(html) #--- controls controls = QHBoxLayout() self.main_layout.addLayout(controls) self.btn_view_edit = QPushButton("edit") self.btn_view_edit.clicked.connect(self.__on_set_view_edit) self.btn_view_web = QPushButton("web") self.btn_view_web.clicked.connect(self.__on_set_view_web) self.btn_show_edit = QPushButton("show_edit") self.btn_show_edit.clicked.connect(self.__on_show_edit) self.btn_save = QPushButton("save") self.btn_save.clicked.connect(self.__save) controls.addWidget(self.btn_view_web) controls.addWidget(self.btn_view_edit) controls.addStretch() controls.addWidget(self.btn_show_edit) controls.addStretch() controls.addWidget(self.btn_save)
def __init__(self, opts, log, cover_data=None, toc=None): from calibre.gui2 import must_use_qt from calibre.utils.podofo import get_podofo must_use_qt() QObject.__init__(self) self.logger = self.log = log self.podofo = get_podofo() self.doc = self.podofo.PDFDoc() self.loop = QEventLoop() self.view = QWebView() self.page = Page(opts, self.log) self.view.setPage(self.page) self.view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.view.loadFinished.connect(self._render_html, type=Qt.QueuedConnection) for x in (Qt.Horizontal, Qt.Vertical): self.view.page().mainFrame().setScrollBarPolicy( x, Qt.ScrollBarAlwaysOff) self.render_queue = [] self.combine_queue = [] self.tmp_path = PersistentTemporaryDirectory(u'_pdf_output_parts') self.opts = opts self.cover_data = cover_data self.paged_js = None self.toc = toc
def __init__(self): super(MainWindow, self).__init__() self.web = QWebView(self) self.web.showFullScreen() self.web.load( QUrl("http://www.ateneucandela.info/presentacio/index.html")) self.setCentralWidget(self.web)
def __init__(self, callback, xpos, ypos, width, height): super(Window, self).__init__() self._xpos = xpos self._ypos = ypos self._width = width self._height = height self._callback = callback self.setStyleSheet( "QWidget { background-color : #1B1D1E; color : #FFFFFF; }") self.setAsBar() view = QWebView(self) view.setContextMenuPolicy(Qt.CustomContextMenu) view.statusBarMessage.connect(self.qt_statusbar_callback) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(view) view.setPage(QWebPage()) view.setHtml( htmltemplate(self._width, self._height, "bottom" if ypos == 0 else "top")) self.view = view self.updateContent.connect(self.handle_updateContent)
def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = self.ui_class() self.ui.setupUi(self) self.ui.map_viewer.hide() self.view = self.view = QWebView() self.view.page().mainFrame().addToJavaScriptWindowObject("Spdom", self) map_fname = utils.get_resource_path('leaflet/map.html') self.view.setUrl(QUrl.fromLocalFile(map_fname)) self.ui.verticalLayout_3.addWidget(self.view) # this is where more complex build information would go such as # instantiating child widgets, inserting them into the layout, # tweaking the layout or individual widget properties, etc. # If you are using this base class as intended this should not # include extensive widget building from scratch. # setup drag-drop functionality for this widget and all it's children. self.setup_dragdrop(self) self.in_update = False self.raise_()
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent=None) self.file_path = self.__getPath() self.setFixedSize(1000, 600) self.parser = GPGGAParser("gpgga1.txt") self.mapVLayout = QtWidgets.QVBoxLayout() self.mapGridLayout = QtWidgets.QGridLayout() self.updateButton = QtWidgets.QPushButton("Обновить карту", self) self.changeRoute = QtWidgets.QPushButton("Изменить маршрут", self) self.routeData = QtWidgets.QPushButton("Данные по маршруту", self) self.zoomButton = QtWidgets.QPushButton("Увеличить", self) self.advancedButton = QtWidgets.QPushButton("Дополнительно", self) self.plotButton = QtWidgets.QPushButton("Визуализация данных", self) self.webMap = QWebView(self) self.url = QUrl("file:///" + self.file_path + "/map.html") self.webMap.load(self.url) self.mapVLayout.addWidget(self.webMap) self.mapVLayout.addLayout(self.mapGridLayout) self.mapGridLayout.addWidget(self.zoomButton, 0, 0) self.mapGridLayout.addWidget(self.updateButton, 0, 1) self.mapGridLayout.addWidget(self.routeData, 1, 0) self.mapGridLayout.addWidget(self.changeRoute, 1, 1) self.mapGridLayout.addWidget(self.advancedButton, 2, 0) self.mapGridLayout.addWidget(self.plotButton, 2, 1) self.zoomButton.clicked.connect(self.mapZoom) self.changeRoute.clicked.connect(self.createChangeWnd) self.routeData.clicked.connect(self.viewData) self.updateButton.clicked.connect(self.updateMap) self.advancedButton.clicked.connect(self.showAdvancedWnd) self.plotButton.clicked.connect(self.showPlotWnd) self.initUI()
def __init__(self, url): super(MainWindow, self).__init__() self.view = QWebView(self) self.view.load(url) self.view.setFixedSize(890, 550) # comment out the following line to allow refresh for debugging self.view.setContextMenuPolicy(Qt.NoContextMenu)
def __init__(self): super(WebRender, self).__init__() vbox, temporary_directory = QVBoxLayout(self), mkdtemp() # Web Frame self.webFrame = QWebView() # QWebView = QWebFrame + QWebSettings self.webFrame.setStyleSheet( "QWebView{ background:#fff }") # no dark bg settings = self.webFrame.settings() # QWebSettings instance settings.setDefaultTextEncoding("utf-8") settings.setIconDatabasePath(temporary_directory) settings.setLocalStoragePath(temporary_directory) settings.setOfflineStoragePath(temporary_directory) settings.setOfflineWebApplicationCachePath(temporary_directory) settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) settings.setAttribute(QWebSettings.LocalStorageEnabled, True) settings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True) settings.setAttribute(QWebSettings.PluginsEnabled, True) settings.setAttribute(QWebSettings.DnsPrefetchEnabled, True) settings.setAttribute(QWebSettings.JavascriptCanOpenWindows, True) settings.setAttribute(QWebSettings.JavascriptCanCloseWindows, True) settings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True) settings.setAttribute(QWebSettings.SpatialNavigationEnabled, True) settings.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) settings.setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled, True) vbox.addWidget(self.webFrame)
def __init__(self): super(Window, self).__init__() self.setWindowTitle('The HUD') view = QWebView(self) layout = QVBoxLayout(self) layout.addWidget(view) view.load(QUrl('http://localhost:5000'))
def __init__(self, parent, icon, prefs, html=None, page=None, title=''): self.prefs = prefs #QDialog.__init__(self, parent=parent) super(HelpView, self).__init__(parent, 'help_dialog') self.setWindowTitle(title) self.setWindowIcon(icon) self.l = QVBoxLayout(self) self.setLayout(self.l) self.wv = QWebView() if html is not None: self.wv.setHtml(html) elif page is not None: self.wv.load(QUrl(page)) self.wv.setMinimumHeight(100) self.wv.setMaximumHeight(16777215) self.wv.setMinimumWidth(400) self.wv.setMaximumWidth(16777215) self.wv.setGeometry(0, 0, 400, 100) self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.l.addWidget(self.wv) # Sizing sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()
def __init__(self): QWidget.__init__(self) self.setMinimumSize(1000,500) self.html = QWebView() vbox=QVBoxLayout() toolbar=QToolBar() toolbar.setIconSize(QSize(48, 48)) back = QAction(icon_get("go-previous.png"), _("back"), self) back.triggered.connect(self.html.back) toolbar.addAction(back) home = QAction(icon_get("user-home.png"), _("home"), self) home.triggered.connect(self.home) toolbar.addAction(home) self.tb_url=QLineEdit() self.tb_url.returnPressed.connect(self.browse) toolbar.addWidget(self.tb_url) vbox.addWidget(toolbar) self.default_url = "http://www.gpvdm.com/welcome.html" self.tb_url.setText(self.default_url) self.browse() vbox.addWidget(self.html) self.setLayout(vbox) return
def __init__(self, player, playlist, trackInfoList, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) view = QWebView(self) view.resize(800, 600) #для перехвата post page = QWebPage() self.qplayer = QPLAYER_COMMAND(player, playlist, trackInfoList) page.mainFrame().addToJavaScriptWindowObject("qplayer", self.qplayer) page.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True) view.setPage(page) with open(URL + "index.html", "rb") as f: template = Template(f.read().decode("utf8")) template_compos = "" #генерируем список воспроизведения for name in trackInfoList: template_compos += """ <div class="composition" onclick="select_music(%s, this)" valued="%s"> <div class="picture" > <div class="picture-play"> <div class="picture-play-span"> <span class="glyphicon glyphicon-play"></span> </div> </div> </div> <div class="composition_text">%s</div> </div>""" % (str(name[1] - 1), str(name[1] - 1), "<span class='number'>" + str(name[1]) + "</span> " + name[0]) view.setHtml(template.render(URL=URL, COMPOS=template_compos), QUrl("file:///" + URL)) self.setWindowTitle('VK Player') self.setWindowIcon( QIcon(os.path.dirname(os.path.abspath(__file__)) + "./icon.png"))
def __init__(self, url): super(FancyBrowser, self).__init__() self.progress = 0 fd = QFile(":/jquery.min.js") if fd.open(QIODevice.ReadOnly | QFile.Text): self.jQuery = QTextStream(fd).readAll() fd.close() else: self.jQuery = '' QNetworkProxyFactory.setUseSystemConfiguration(True) self.view = QWebView(self) self.view.load(url) self.view.loadFinished.connect(self.adjustLocation) self.view.titleChanged.connect(self.adjustTitle) self.view.loadProgress.connect(self.setProgress) self.view.loadFinished.connect(self.finishLoading) self.locationEdit = QLineEdit(self) self.locationEdit.setSizePolicy( QSizePolicy.Expanding, self.locationEdit.sizePolicy().verticalPolicy()) self.locationEdit.returnPressed.connect(self.changeLocation) toolBar = self.addToolBar("Navigation") toolBar.addAction(self.view.pageAction(QWebPage.Back)) toolBar.addAction(self.view.pageAction(QWebPage.Forward)) toolBar.addAction(self.view.pageAction(QWebPage.Reload)) toolBar.addAction(self.view.pageAction(QWebPage.Stop)) toolBar.addWidget(self.locationEdit) viewMenu = self.menuBar().addMenu("&View") viewSourceAction = QAction("Page Source", self) viewSourceAction.triggered.connect(self.viewSource) viewMenu.addAction(viewSourceAction) effectMenu = self.menuBar().addMenu("&Effect") effectMenu.addAction("Highlight all links", self.highlightAllLinks) self.rotateAction = QAction(self.style().standardIcon( QStyle.SP_FileDialogDetailedView), "Turn images upside down", self, checkable=True, toggled=self.rotateImages) effectMenu.addAction(self.rotateAction) toolsMenu = self.menuBar().addMenu("&Tools") toolsMenu.addAction("Remove GIF images", self.removeGifImages) toolsMenu.addAction("Remove all inline frames", self.removeInlineFrames) toolsMenu.addAction("Remove all object elements", self.removeObjectElements) toolsMenu.addAction("Remove all embedded elements", self.removeEmbeddedElements) self.setCentralWidget(self.view)
def create_browser_layout(web_page: str) -> QVBoxLayout: path = THIS_DIR.parents[1] / 'resources' / 'site' / web_page url = QUrl(path.as_uri()) vbox = QVBoxLayout() vbox.setContentsMargins(2, 2, 2, 2) browser = QWebView() browser.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) if platform.system() == 'Windows': # On Windows, QWebView does not adapt according to system scaling settings. # This leads to tiny fonts on high-dpi displays where scaling # is typically 200%. The work-around below sets the right scaling # via the browser's zoom factor. screen = QGuiApplication.primaryScreen() dpi = screen.logicalDotsPerInchX() zoom = dpi / 96 browser.setZoomFactor(zoom) # Open external links with the default browser. browser.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks) browser.linkClicked.connect(QDesktopServices.openUrl) browser.load(url) vbox.addWidget(browser) return vbox
def __init__(self, book_mi, annotations, parent=None): #QDialog.__init__(self, parent) self.prefs = plugin_prefs super(PreviewDialog, self).__init__(parent, 'annotations_preview_dialog') self.pl = QVBoxLayout(self) self.setLayout(self.pl) self.label = QLabel() self.label.setText("<b>" + _("{0} annotations · {1}").format( book_mi.reader_app, book_mi.title) + "</b>") self.label.setAlignment(Qt.AlignHCenter) self.pl.addWidget(self.label) self.wv = QWebView() self.wv.setHtml(annotations) self.pl.addWidget(self.wv) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Close) # self.buttonbox.addButton('Close', QDialogButtonBox.AcceptRole) self.buttonbox.setOrientation(Qt.Horizontal) # self.buttonbox.accepted.connect(self.close) self.buttonbox.rejected.connect(self.close) # self.connect(self.buttonbox, pyqtSignal('accepted()'), self.close) # self.connect(self.buttonbox, pyqtSignal('rejected()'), self.close) self.pl.addWidget(self.buttonbox) # Sizing sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()
def _setup_ui(self): '''加载界面ui''' self.left_widget.currentRowChanged.connect( self.right_widget.setCurrentIndex) # list和右侧窗口的index对应绑定 self.left_widget.setFrameShape(QListWidget.NoFrame) # 去掉边框 self.left_widget.setVerticalScrollBarPolicy( Qt.ScrollBarAlwaysOff) # 隐藏滚动条 self.left_widget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) list_str = ['Containers', 'Images', 'Log', 'Network', 'Dockerfile'] url_list = [ 'job_num_wordcloud.html', 'edu_need.html', 'salary_bar.html', 'edu_salary_bar.html' ] for i in range(len(list_str)): self.item = QListWidgetItem(list_str[i], self.left_widget) # 左侧选项的添加 self.item.setSizeHint(QSize(30, 60)) self.item.setTextAlignment(Qt.AlignCenter) # 居中显示 self.browser = QWebView() # 右侧用QWebView来显示html网页 # self.browser.setUrl(QUrl.fromLocalFile('D://python//code//vision//%s' % url_list[i])) self.right_widget.addWidget(self.browser)
def __init__(self, parent, size, url): super(GISCloudQgisWebBrowserDialog, self).__init__(parent.manager.main_widget) self.parent = parent self.setModal(True) self.cookies = None self.url = QUrl(url) self.nam = QtNetwork.QNetworkAccessManager() self.web_page = QWebPage() self.web_page.setNetworkAccessManager(self.nam) self.web_page.loadFinished.connect(self.loading_finished) def customuseragent(url): """setting up our own user agent""" # pylint: disable=W0613 return ("Mozilla/5.0 " + GISCloudNetworkHandler.app_id.encode( "unicode_escape").decode("latin-1")) self.web_page.userAgentForUrl = customuseragent self.web_view = QWebView(self) self.web_view.setPage(self.web_page) self.resize(size)
def initialized__(self): STATUS.emit('play-sound', 'SPEAK This is a test screen for Haas styled QT lathe') KEYBIND.add_call('Key_F3', 'on_keycall_F3') KEYBIND.add_call('Key_F4', 'on_keycall_F4') KEYBIND.add_call('Key_F5', 'on_keycall_F5') KEYBIND.add_call('Key_F6', 'on_keycall_F6') KEYBIND.add_call('Key_F7', 'on_keycall_F7') KEYBIND.add_call('Key_F9', 'on_keycall_F9') KEYBIND.add_call('Key_F11', 'on_keycall_F11') KEYBIND.add_call('Key_F12', 'on_keycall_F12') TOOLBAR.configure_action(self.w.actionCalculatorDialog, 'calculatordialog') TOOLBAR.configure_submenu(self.w.menuGridSize, 'grid_size_submenu') TOOLBAR.configure_action(self.w.actionToolOffsetDialog, 'tooloffsetdialog') TOOLBAR.configure_action(self.w.actionReload, 'Reload') TOOLBAR.configure_statusbar(self.w.statusbar, 'message_controls') self.w.pushbutton_metric.clicked[bool].connect(self.change_mode) # web view widget for SETUP SHEET page self.web_view = QWebView() self.w.verticalLayout_setup.addWidget(self.web_view) self.set_default_html() self.GCODES.setup_list() self.w.gcode_editor.hide()
def __init__(self, container, do_embed=False): self.container = container self.log = self.logger = container.log self.do_embed = do_embed must_use_qt() self.parser = CSSParser(loglevel=logging.CRITICAL, log=logging.getLogger('calibre.css')) self.first_letter_pat = regex.compile(r'^[\p{Ps}\p{Ps}\p{Pe}\p{Pi}\p{Pf}\p{Po}]+', regex.VERSION1 | regex.UNICODE) self.capitalize_pat = regex.compile(r'[\p{L}\p{N}]', regex.VERSION1 | regex.UNICODE) self.loop = QEventLoop() self.view = QWebView() self.page = Page(self.log) self.view.setPage(self.page) self.page.setViewportSize(QSize(1200, 1600)) self.view.loadFinished.connect(self.collect, type=Qt.QueuedConnection) self.render_queue = list(container.spine_items) self.font_stats = {} self.font_usage_map = {} self.font_spec_map = {} self.font_rule_map = {} self.all_font_rules = {} QTimer.singleShot(0, self.render_book) if self.loop.exec_() == 1: raise Exception('Failed to gather statistics from book, see log for details')
def __init__(self, parent=None, key_listen_loop=None): super(DictDotCn, self).__init__(parent) DoubleCtrlSignal.instance().doublle_ctrl_signal[str, int, int].connect( self.double_ctrl_event) DoubleCtrlSignal.instance().esc_signal.connect(self.hide) DoubleCtrlSignal.instance().show_signal.connect(self.center_show) self.key_listen_loop = key_listen_loop self.fadeflag = True self.word = '' self.resize(400, 450) self.layout = QVBoxLayout(self) self.webview = QWebView() self.layout.addWidget(self.webview) self.layout2 = QHBoxLayout() self.layout.addWidget(self.webview) self.layout.addLayout(self.layout2) self.text = QLineEdit() self.text.resize(400, 4) self.text.returnPressed.connect(self.queryword) self.layout2.addWidget(self.text) self.button = QPushButton('+') self.layout2.addWidget(self.button)
def __init__(self, opts, log, cover_data=None, toc=None): from calibre.gui2 import must_use_qt must_use_qt() QObject.__init__(self) self.logger = self.log = log current_log(log) self.opts = opts self.cover_data = cover_data self.paged_js = None self.toc = toc self.loop = QEventLoop() self.view = QWebView() self.page = Page(opts, self.log) self.view.setPage(self.page) self.view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.view.loadFinished.connect(self.render_html, type=Qt.QueuedConnection) for x in (Qt.Horizontal, Qt.Vertical): self.view.page().mainFrame().setScrollBarPolicy( x, Qt.ScrollBarAlwaysOff) self.report_progress = lambda x, y: x self.current_section = '' self.current_tl_section = ''
def __init__(self, parent=None, filename=""): QMainWindow.__init__(self, parent) self.filename = filename or os.path.join(app_dir, u"README.md") # Set environment variables self.set_env() # Configure Preview window self.set_window_title() self.resize(self.QSETTINGS.value("size", QSize(800,400))) self.move(self.QSETTINGS.value("pos", QPoint(0,0))) # Activate WebView self.web_view = QWebView() self.setCentralWidget(self.web_view) self.scroll_pos = {} # Configure and start file watcher thread self.thread1 = WatcherThread(self.filename) self.thread1.update.connect(self.update) self.watcher = QFileSystemWatcher([self.filename]) self.watcher.fileChanged.connect(self.thread1.run) self.thread1.run() self.web_view.loadFinished.connect(self.after_update) # Get style sheet self.stylesheet = self.QSETTINGS.value("stylesheet", "default.css") # Set GUI menus and toolbars self.set_menus() self.set_search_bar()
def cb_initialize_plugin(self): # --------------------------- # Read configuration # --------------------------- self.config = self.pl_get_current_config_ref() content = self.config['content']['value'] isUrl = self.config['isUrl']['value'] # -------------------------------- # Create Widget # -------------------------------- self.WebView = QWebView() # This call is important, because the background structure needs to know the used widget! # In the background the qmidiwindow will becreated and the widget will be added self.pl_set_widget_for_internal_usage( self.WebView ) print(isUrl) if isUrl == '1': url = QtCore.QUrl(content) self.WebView.load(url) else: self.WebView.setHtml(content) self.WebView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.WebView.customContextMenuRequested.connect(self.show_context_menu) return True
def getWebView(self): webView = QWebView() if not globalSettings.handleWebLinks: webView.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks) webView.page().linkClicked.connect(QDesktopServices.openUrl) webView.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, False) return webView