Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This is for high DPI scaling:
"""Opens a file dialog to save the ZIP archive. """ mimetype = item.mimeType() if "octet-stream" in mimetype: ext = ".png" elif "svg" in item.mimeType(): ext = ".svg" elif "zip" in mimetype: ext = ".zip" else: ext = ""
path = QtWidgets.QFileDialog.getSaveFileName(None, "Select destination folder and file name", "", "")[0] item.setPath("{path}{ext}".format(path=path, ext=ext)) item.accept()
super(ApplicationThread, self).__init__() self.application = application self.port = port
self.wait()
self.application.run(port=self.port)
super(WebPage, self).__init__() self.root_url = root_url
self.load(QtCore.QUrl(self.root_url))
ready_url = url.toEncoded().data().decode() is_clicked = kind == self.NavigationTypeLinkClicked
if is_clicked and (self.root_url not in ready_url): QtGui.QDesktopServices.openUrl(url) return False return super(WebPage, self).acceptNavigationRequest(url, kind, is_main_frame)
"""Initialize Qt web engine, start Flask application. """ if argv is None: argv = sys.argv
# Starting the Flask application: qtapp = QtWidgets.QApplication(argv) web = ApplicationThread(application, port) web.start()
def kill(application=web): """Kill the Flask process. """ application.terminate()
qtapp.aboutToQuit.connect(kill)
# Setting width and height individually based on the # screen resolution: 93% of the screen for width, # 80% for height: screen = qtapp.primaryScreen() size = screen.size() width = size.width() - size.width() / 100 * 7 height = size.height() - size.height() / 100 * 20
# Applying settings and loading the home page: webview = QtWebEngineWidgets.QWebEngineView() webview.resize(width, height) webview.setWindowTitle(title) webview.setWindowIcon(QtGui.QIcon(icon))
page = WebPage('http://localhost:{}'.format(port)) page.home() webview.setPage(page)
# If the user clicks a download button, a window pops up: webview.page().profile().downloadRequested.connect(download_request)
# Show the webview: webview.show() return qtapp.exec_()
"""Run Topics Explorer. """ sys.exit(init_gui(views.web)) |