def __init__(self, parent=0, *args, **kwargs): super(DashbordViewWidget, self).__init__( parent=parent, *args, **kwargs) self.parentWidget().set_window_title("TABLEAU DE BORD") self.parent = parent vbox = QVBoxLayout() # self.resize(self.wc, self.hc) self.title = FPageTitle("TABLEAU DE BORD") self.title_alert = FBoxTitle(u"Les alertes") jinja = Environment(loader=FileSystemLoader('static')) template = jinja.get_template('chart.html') cc_list = CooperativeCompanie.select().order_by('-start_date') dataset = { "wc": self.width(), "hc": self.height(), "toal_scoop": cc_list.count(), "sc_coop_ca": cc_list.where(CooperativeCompanie.forme == "b").count(), "sc_scoops": cc_list.where(CooperativeCompanie.forme == "a").count(), "union": cc_list.where(CooperativeCompanie.forme == "bv").count(), "federation": cc_list.where(CooperativeCompanie.forme == "bf").count(), "confederation": cc_list.where(CooperativeCompanie.forme == "bc").count(), } graph1 = template.render(base_url=ROOT_DIR, data=dataset) template2 = jinja.get_template('table.html') table_html = template2.render(base_url=ROOT_DIR, dataset=dataset) web_graphic = QWebView() web_graphic.setHtml(graph1) tab_graphic = QVBoxLayout() # tab_graphic.setMargin(20) tab_graphic.addWidget(web_graphic) web_table = QWebView() web_table.setHtml(table_html) tab_table = QVBoxLayout() tab_table.addWidget(web_table) tab_widget = tabbox((tab_graphic, u"Graphique"), (tab_table, u"Tableau")) # tab_widget1 = tabbox((tab_table, u"Tableau")) vbox.addWidget(self.title) vbox.addWidget(tab_widget) # vbox.addWidget(tab_widget1) self.setLayout(vbox)
def __init__(self): super(NotificationPresenter, self).__init__() rect = QApplication.desktop().availableGeometry() self.setGeometry(QRect(rect.width() - 300, 0, 300, rect.height())) self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup | Qt.Tool) self.setAttribute(Qt.WA_TranslucentBackground, True) self.webview = QWebView(self) self.webview.settings().setAttribute(QWebSettings.JavascriptEnabled, True) self.webview.settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) self.webview.settings().setAttribute( QWebSettings.LocalContentCanAccessRemoteUrls, True) self.webview.settings().setAttribute(QWebSettings.LocalStorageEnabled, True) self.webview.settings().setLocalStoragePath(AppProperty.HomeDir + "/data") self.webview.setContextMenuPolicy(Qt.NoContextMenu) self.webview.settings().setDefaultTextEncoding("utf-8") self.webview.setGeometry(0, 0, self.width(), self.height()) self.webview.setStyleSheet( "QWebView{background-color: rgba(255, 193, 245, 0%); }") self.webview.load( QUrl.fromLocalFile(AppProperty.HomeDir + "/html/notification.html")) self.webview.page().linkClicked.connect(self.linkClicked) self.webview.page().mainFrame().javaScriptWindowObjectCleared.connect( self.setJavaScriptObject) self.webview.page().setLinkDelegationPolicy( self.webview.page().DelegateAllLinks)
def __init__(self, widget, chart='Line', data=[], xkey='', ykeys=[], labels=[], raw='', **attrs): ''' @param {QWidget} widget = instance of QWidget @param {string} name = namefile chart @param {string} chart = morris type chart: Line, Bar, Donnut @param {list} data = list of data to show @param {string} xkey = a string containing the name of the attribute that contains X labels @param {string} ykeys = a list of strings containing names of attributes that contain Y values @param {list} labels = a list of strings containing labels for the data series to be plotted @param {string} raw = string params to append in morris options ''' self.widget = widget self.name = 'chart.html' # chart name file self.chart = chart.capitalize() # Line | Bar | Donut self.data = data # [] self.xkey = xkey self.ykeys = ykeys # ['a', 'b'] self.labels = labels # ['label a', 'label b'] self.attrs = attrs self.raw = raw self.program_folder = getProgramFolderPath() self.tmpl = convertPath(self.program_folder + 'morris/template.html') self.path_file = convertPath(self.program_folder + self.name) self.webview = QWebView() self.webview.setPage(WebPage()) self.webview.page().settings().setAttribute( QWebSettings.JavascriptEnabled, True) self.widget.setLayout(QtGui.QVBoxLayout()) self.widget.layout().setContentsMargins(0, 0, 0, 0) self.widget.layout().addWidget(self.webview)
def __init__(self, base, url): QDialog.__init__(self) self.base = base self.setWindowTitle(i18n.get('authorize_turpial')) self.resize(800, 550) self.setModal(True) self.webview = QWebView() qurl = QUrl(url) self.webview.setUrl(qurl) message = QLabel(i18n.get('copy_the_pin')) #message.setAlignment(Qt.AlignRight) self.pin = QLineEdit() self.pin.setPlaceholderText(i18n.get('type_the_pin')) authorize_btn = QPushButton(i18n.get('save')) authorize_btn.clicked.connect(self.accept) widgets_box = QHBoxLayout() widgets_box.setSpacing(3) widgets_box.setContentsMargins(3, 3, 3, 3) widgets_box.addWidget(message, 1) widgets_box.addWidget(self.pin) widgets_box.addWidget(authorize_btn) layout = QVBoxLayout() layout.addWidget(self.webview) layout.addLayout(widgets_box) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.exec_()
def __init__(self, parent): super(HtmlViewerWidget, self).__init__(parent) self.setLayout(QGridLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.view = QWebView() self.view.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) self.frame = QFrame() self.frame.setLayout(QGridLayout()) self.frame.layout().setContentsMargins(0, 0, 0, 0) self.toolbar = QToolBar() self.spacer = QWidget() self.spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.copyAction = self.toolbar.addAction(QIcon(":/icons/clipboard"), "Copy Text") self.label = QLabel() self.closeAction = self.toolbar.addAction(QIcon(":/icons/cancel"), "Close") self.spaceraction = self.toolbar.insertWidget(self.closeAction, self.spacer) self.labelaction = self.toolbar.insertWidget(self.spaceraction, self.label) self.closeAction.triggered.connect(self.close) self.copyAction.triggered.connect(self.copy_text) self.layout().addWidget(self.frame) self.frame.layout().addWidget(self.toolbar) self.frame.layout().addWidget(self.view) self.effect = QGraphicsOpacityEffect() self.label.setGraphicsEffect(self.effect) self.anim = QPropertyAnimation(self.effect, "opacity") self.anim.setDuration(2000) self.anim.setStartValue(1.0) self.anim.setEndValue(0.0) self.anim.setEasingCurve(QEasingCurve.OutQuad)
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 zobrazím_html_stránku(html_soubor): ''' vytvoří prohlížeč pomocí PyQt a zobrazí v něm stránku ''' if not os.path.isfile(html_soubor): raise IOError('Nejestvuje soubor "{}", nemožu jej zobrazit.'.format(html_soubor)) import sys # from PyQt4.QtCore import QUrl from PyQt4.QtGui import QApplication from PyQt4.QtWebKit import QWebView with open(file = html_soubor, mode = 'r', encoding = 'UTF-8') as soubor: obsah = soubor.read() # prohlížeč = davaj_prohlížeč() app = QApplication(sys.argv) prohlížeč = QWebView() prohlížeč.setHtml(obsah) prohlížeč.show() sys.exit(app.exec_())
def __init__(self, parent, network_analyzer, url=None): QWidget.__init__(self, parent) self.webView = QWebView() self.webView.setPage(QgepWebPage(self.webView)) self.networkAnalyzer = network_analyzer settings = QSettings() layout = QVBoxLayout(self) if url is None: url = settings.value( "/QGEP/SvgProfilePath", u'qrc:///plugins/qgepplugin/svgprofile/index.html') developermode = settings.value("/QGEP/DeveloperMode", False, type=bool) if developermode is True: self.webView.page().settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) else: self.webView.setContextMenuPolicy(Qt.NoContextMenu) self.webView.load(QUrl(url)) self.frame = self.webView.page().mainFrame() self.frame.javaScriptWindowObjectCleared.connect(self.initJs) layout.addWidget(self.webView)
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, parent=None): super(Info, self).__init__(parent) self.resize(460, 420) self.setStyleSheet("background-color:#3B4141;") self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) #self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup) self.layout = QtGui.QVBoxLayout() self.setLayout(self.layout) self.web_view = QWebView() self.layout.addWidget(self.web_view) self.quitAction = QtGui.QAction("&Quit", self, triggered=QtGui.qApp.quit) self.on_offAction = QtGui.QAction("&Switch", self, triggered=self.on_off) self.trayIconMenu = QtGui.QMenu(self) self.trayIconMenu.addAction(self.on_offAction) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.quitAction) self.trayIconMenu.setStyleSheet("color:#ffffff;font-size:18px") self.trayIcon = QtGui.QSystemTrayIcon(self) self.trayIcon.setContextMenu(self.trayIconMenu) self.trayIcon.setIcon(QtGui.QIcon(":/imgs/dictionary-icon.png")) self.trayIcon.show() self.cpb = QtGui.QApplication.clipboard() self.cpb.selectionChanged.connect(self.query) self.flag = True
def __init__(self, session, parent=None, webdriver_class=None): super(WWTDataViewer, self).__init__(session, parent=parent) self._browser = QWebView() url = QtCore.QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'wwt.html')) self._browser.setUrl(url) self._browser.page().mainFrame().setScrollBarPolicy( Qt.Vertical, Qt.ScrollBarAlwaysOff) self._browser.page().mainFrame().setScrollBarPolicy( Qt.Horizontal, Qt.ScrollBarAlwaysOff) self._driver = WWTDriver(self._browser) self.option_panel = WWTOptionPanel(self) self.setCentralWidget(self._browser) self.resize(self._browser.size()) self.setWindowTitle("WWT") self.run_js.connect(self._driver.run_js) self._update_foreground() self._update_background()
def _create_view(self, svg, section=None): view = QWebView(self) view.setRenderHint(QtGui.QPainter.TextAntialiasing, False) view.setPage(LoggingWebPage()) view.setContextMenuPolicy(QtCore.Qt.PreventContextMenu) # the HTML page that will contain the SVG path = os.path.dirname(os.path.realpath(__file__)) html = QUrl(os.path.join(path, "index.html")) # make file configurable # setup the JS interface frame = view.page().mainFrame() self.js = JSInterface(frame) #self.js.registered.connect(self.register) self.js.visibility.connect(self.listen) # mouse interaction signals self.clicked = self.js.leftclicked self.rightClicked = self.js.rightclicked # Inject JSInterface into the JS global namespace as "Widget" frame.addToJavaScriptWindowObject('Widget', self.js) # confusing? # when the page (and all the JS) has loaded, load the SVG def load_svg(): print "blorrt", svg self.js.load(svg, section) view.loadFinished.connect(load_svg) # load the page # print "url", QUrl(url) view.load(html) return view
def mainPyQt4Youtube(): # 必要なモジュールのimport from PyQt4.QtCore import QUrl from PyQt4.QtGui import QApplication from PyQt4.QtWebKit import QWebView, QWebSettings from PyQt4.QtNetwork import QNetworkProxyFactory url = 'https://www.youtube.com/?hl=ja&gl=JP' app = QApplication(sys.argv) # Youtube動画を読み込むための設定 QNetworkProxyFactory.setUseSystemConfiguration(True) QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.DnsPrefetchEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True) QWebSettings.globalSettings().setAttribute(QWebSettings.LocalStorageEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True) # QWebViewによるWebページ表示 browser = QWebView() browser.load(QUrl(url)) browser.setEnabled(True) browser.show() sys.exit(app.exec_())
def setupUi(self, ViewerWindow): ViewerWindow.setObjectName(_fromUtf8("ViewerWindow")) ViewerWindow.resize(733, 324) self.centralwidget = QtGui.QWidget(ViewerWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.WebView = QWebView(self.centralwidget) self.WebView.setObjectName(_fromUtf8("WebView")) self.verticalLayout.addWidget(self.WebView) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.okButton = QtGui.QPushButton(self.centralwidget) self.okButton.setObjectName(_fromUtf8("okButton")) self.horizontalLayout.addWidget(self.okButton) self.verticalLayout.addLayout(self.horizontalLayout) ViewerWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(ViewerWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 733, 26)) self.menubar.setObjectName(_fromUtf8("menubar")) ViewerWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(ViewerWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) ViewerWindow.setStatusBar(self.statusbar) self.retranslateUi(ViewerWindow) QtCore.QMetaObject.connectSlotsByName(ViewerWindow)
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, webview_ready): super(BrowserView, self).__init__() BrowserView.instance = self self._file_name_semaphor = threading.Semaphore(0) self.resize(width, height) self.setWindowTitle(title) if not resizable: self.setFixedSize(width, height) if fullscreen: self.showFullScreen() self.setMinimumSize(min_size[0], min_size[1]) self.view = QWebView(self) self.view.setContextMenuPolicy( QtCore.Qt.NoContextMenu) # disable right click context menu if url != None: self.view.setUrl(QtCore.QUrl(url)) self.setCentralWidget(self.view) self.url_trigger.connect(self._handle_load_url) self.html_trigger.connect(self._handle_load_html) self.dialog_trigger.connect(self._handle_file_dialog) self.destroy_trigger.connect(self._handle_destroy_window) self.move(QApplication.desktop().availableGeometry().center() - self.rect().center()) self.activateWindow() self.raise_() webview_ready.set()
def __init__(self): super(TweetWindow, self).__init__() self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup | Qt.Tool) self.setAttribute(Qt.WA_TranslucentBackground, True) self.resize(550, 520) point = Utils.getDesktopCenterPoint(self) self.move(point["x"], point["y"]) self.webview = QWebView(self) self.webview.settings().setAttribute(QWebSettings.JavascriptEnabled, True) self.webview.settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) self.webview.settings().setAttribute( QWebSettings.LocalContentCanAccessRemoteUrls, True) self.webview.settings().setAttribute(QWebSettings.LocalStorageEnabled, True) self.webview.settings().setLocalStoragePath(AppProperty.HomeDir + "/data") #self.webview.setContextMenuPolicy(Qt.NoContextMenu) self.webview.settings().setDefaultTextEncoding("utf-8") self.webview.setGeometry(1, 1, self.width() - 2, self.height() - 2) self.webview.page().mainFrame().javaScriptWindowObjectCleared.connect( self.setJavaScriptObject) self.webview.setStyleSheet( "QWebView{background-color: rgba(255, 193, 245, 0%); }") self.webview.page().networkAccessManager().setCookieJar( AppProperty.CookieJar) self.webview.load( QUrl.fromLocalFile(AppProperty.HomeDir + "/html/tweetWindow.html"))
def __init__(self, opts, log, cover_data=None, toc=None): from calibre.gui2 import is_ok_to_use_qt from calibre.utils.podofo import get_podofo if not is_ok_to_use_qt(): raise Exception('Not OK to 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 initialize(self): self.loaded = 1 grid = QGridLayout() self.browser = QWebView() # handle clicking of links self.browser.linkClicked.connect(self.handleLinkClicked) url = 'file:///' + os.path.dirname( os.path.realpath(__file__)) + '/../html/index.html' self.url_input = UrlInput(self.browser) # Load the main page of the website self.loadIndexPage() # This does something for following links self.browser.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) # url_input at row 1 column 0 of our grid grid.addWidget(self.url_input, 1, 0) # Button for adding link self.lbutton = QPushButton('Add external link', self) self.lbutton.clicked.connect(self.lbuttonHandle) # Button placed in row 1 column 1 or grid grid.addWidget(self.lbutton, 1, 1) # Button for adding link to internal link self.nbutton = QPushButton('Add internal link', self) self.nbutton.clicked.connect(self.nbuttonHandle) # button at row 1 column 2 of our grid grid.addWidget(self.nbutton, 1, 2) # Button for rebuilding site # self.rbutton = QPushButton('Rebuild site', self) # self.rbutton.clicked.connect(self.rbuttonHandle) # # button at row 1 column 1 of our grid # grid.addWidget( self.rbutton, 1, 3 ) # browser frame below it grid.addWidget(self.browser, 2, 0, 1, 4) self.setLayout(grid)
def __init__(self, network_manager, splash_proxy_factory, splash_request, verbose=False): self.network_manager = network_manager self.web_view = QWebView() self.web_page = SplashQWebPage() self.web_page.setNetworkAccessManager(self.network_manager) self.web_view.setPage(self.web_page) self.web_view.setAttribute(Qt.WA_DeleteOnClose, True) settings = self.web_page.settings() settings.setAttribute(QWebSettings.JavascriptEnabled, True) settings.setAttribute(QWebSettings.PluginsEnabled, False) settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, True) settings.setAttribute(QWebSettings.LocalStorageEnabled, True) settings.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) self.web_page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) self.web_page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) self.splash_request = splash_request self.web_page.splash_request = splash_request self.web_page.splash_proxy_factory = splash_proxy_factory self.verbose = verbose self.deferred = defer.Deferred()
def brow(self): app1 = QtGui.QApplication(sys.argv) grid = QGridLayout() browser = QWebView() global browser url_input = UrlInput(browser) requests_table = RequestsTable() manager = Manager(requests_table) page = QWebPage() page.setNetworkAccessManager(manager) browser.setPage(page) js_eval = JavaScriptEvaluator(page) # action_box = ActionInputBox(page) grid.addWidget(url_input, 1, 0) # grid.addWidget(action_box, 2, 0) grid.addWidget(browser, 3, 0) # grid.addWidget(requests_table, 4, 0) # grid.addWidget(js_eval, 5, 0) main_frame = QWidget() main_frame.setLayout(grid) main_frame.show() sys.exit(app.exec_())
def show(): path = os.path.abspath(__file__) while path: path = path[:path.rfind("/")] # specialize for Mac app bundle p = path if path.endswith(".app/Contents"): p += "/Resources" p += "/docs/projects/steamshovel/index.html" if os.path.exists(p): path = p break if not path: return False try: import IPython from PyQt4.QtWebKit import QWebView from PyQt4.QtCore import QUrl view = QWebView() view.setUrl(QUrl(path)) view.show() view.raise_() view.activateWindow() __main__.view = view # keep view alive return True except ImportError: # fall back to webbrowser module import webbrowser as wb w = wb.get() # work-around for bug in Python2.7 on MacOS, only Safari works if isinstance(w, wb.MacOSXOSAScript): w = wb.get("Safari") return w.open(path)
def __init__(self, URL, process=None, main=None): QWidget.__init__(self) BaseCentralWidget.__init__(self) self.path = URL self.process = process v_box = QVBoxLayout(self) #Web Frame QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True) self.webFrame = QWebView() self.webFrame.setAcceptDrops(False) factory = WebPluginFactory(self, main) self.webFrame.page().setPluginFactory(factory) self.webFrame.load(QUrl(URL)) v_box.addWidget(self.webFrame) if process is not None: time.sleep(0.5) self.webFrame.reload() if self.path.endswith( 'startPage.html') and sys.platform.find('win') != -1: content = manage_files.read_file_content(self.path) pathCss = os.path.join(resources.PRJ_PATH, 'doc', 'styles', 'ninja.css') pathJs = os.path.join(resources.PRJ_PATH, 'doc', 'rsc') content = content.replace('styles/ninja.css', pathCss).replace('src="rsc', 'src="' + pathJs) self.webFrame.setHtml(content)
def GUI(self): self.frm0 = QFormLayout() self.model = QStandardItemModel() self.viewlogger = QListView() self.widget = QWidget() self.layout = QVBoxLayout(self.widget) if QWebView_checker: self.ExportPDF = QWebView() # check all files logger empty or round self.viewlogger.setModel(self.model) self.layout.addLayout(self.frm0) # group file type self.GroupBoxFile = QGroupBox() self.layoutGroupFile = QVBoxLayout() self.GroupBoxFile.setLayout(self.layoutGroupFile) self.GroupBoxFile.setTitle('Options:') self.checkHTML = QRadioButton('HTML') self.checkPDF = QRadioButton('PDF') self.checkPDF.setEnabled(QWebView_checker) self.layoutGroupFile.addWidget(self.checkHTML) self.layoutGroupFile.addWidget(self.checkPDF) # group informations self.GroupBoxINFO = QGroupBox() self.layoutGroupINFO = QFormLayout() self.GroupBoxINFO.setLayout(self.layoutGroupINFO) self.GroupBoxINFO.setTitle('Information:') self.labelStart = QLabel() self.labelStop = QLabel() self.layoutGroupINFO.addRow('started AP at:', self.labelStart) self.layoutGroupINFO.addRow('stoped AP at:', self.labelStop) # get all session data add combobox self.CB_Data_Logger = QComboBox(self) all_sessions = [] for key in self.sessions.keys(): all_sessions.append(self.sessions[key]['started']) all_sessions.append('select All logger file...') self.CB_Data_Logger.addItems(all_sessions) self.connect(self.CB_Data_Logger, SIGNAL('activated(QString)'), self.combo_clicked) index = self.CB_Data_Logger.findText( all_sessions[len(all_sessions) - 2], Qt.MatchFixedString) self.CB_Data_Logger.setCurrentIndex(index) self.combo_clicked(self.CB_Data_Logger.currentText()) self.btnSave = QPushButton('Export') self.btnSave.clicked.connect(self.exportFilesSystem) self.frm0.addRow('Session:', self.CB_Data_Logger) self.frm0.addRow(self.GroupBoxINFO) self.frm0.addRow(self.viewlogger) self.frm0.addRow(self.GroupBoxFile) self.frm0.addRow(self.btnSave) self.Main.addWidget(self.widget) self.setLayout(self.Main)
def __init__(self, title, url, width, height, resizable, fullscreen): super(BrowserView, self).__init__() BrowserView.instance = self self.resize(width, height) self.setWindowTitle(title) if not resizable: self.setFixedSize(width, height) if fullscreen: self.showFullScreen() self.view = QWebView(self) self.view.setUrl(QtCore.QUrl(url)) #layout = QVBoxLayout(self) #self.layout.setContentsMargins(0, 0, 0, 0) #self.layout.addWidget(self.view) self.setCentralWidget(self.view) self.trigger.connect(self._handle_load_url) self.move(QApplication.desktop().availableGeometry().center() - self.rect().center()) self.activateWindow() self.raise_()
def __init__(self, opts, log, cover_data=None, toc=None): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') QObject.__init__(self) self.logger = self.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 = ''
def __init__(self, banner_path=None, content=None): QtGui.QWidget.__init__(self) if banner_path is None: banner_path = shared_data(openalea.oalab, 'icons/logo/banner.png') self._lay = QtGui.QVBoxLayout(self) p = QtGui.QSizePolicy self._banner = QtGui.QLabel() self._banner.setStyleSheet("QLabel { background-color : #ffffff;}") banner = QtGui.QPixmap(banner_path) size = banner.size() self._banner.setPixmap(banner) self._content = QWebView() if hasattr(self._content, "setReadOnly"): self._content.setReadOnly(True) self._content.setHtml(content) self._footer = QtGui.QLabel() self._footer.setStyleSheet("QLabel { background-color : #459454;}") self._lay.addWidget(self._banner) self._lay.addWidget(self._content) self._lay.addWidget(self._footer) self._lay.setContentsMargins(0, 0, 0, 0) self._lay.setSpacing(0)
def __init__(self, parent): super(HtmlViewerWidget, self).__init__(parent) self.setLayout(QGridLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.view = QWebView() self.view.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) self.layout().addWidget(self.view)
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.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 show(self): self.webview = QWebView() self.webview.setPage(self.webpage) window = self.webview.window() window.setAttribute(Qt.WA_DeleteOnClose) self.application.syncX() self.webview.show()
def set_type(self): try: ext = self.file_name.split(".")[-1] print(ext) except: ext = "" self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self)) pass if ext == "py": self.text_edit_field.setLexer(Qsci.QsciLexerPython(self)) self.hide_web() print("type python") elif ext == "cpp" or ext == "c": self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self)) self.hide_web() print("type cpp") elif ext == "html": self.text_edit_field.setLexer(Qsci.QsciLexerHTML(self)) self.terminal.setHidden(True) self.browser = QWebView(self) self.browser.load(QUrl(self.file_name)) self.browser.move(self.x_y[0] * 66, 30) self.browser.setFixedSize(self.x_y[0] * 0.33, self.x_y[1] - 20) self.browser.show() #self.browser.move(500,0) #self.setGeometry((self.screen.width()-self.wd+200)/2,0,self.wd,self.ht-50) #self.setFixedSize(self.wd+200,self.ht-50) print("type html")