Python PyQt4.QtWebKit.QWebView() Examples

The following are 14 code examples of PyQt4.QtWebKit.QWebView(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt4.QtWebKit , or try the search function .
Example #1
Source File: browser.py    From shoogle with GNU General Public License v3.0 6 votes vote down vote up
def get_code(url, size=(640, 480), title="Google authentication"):
    """Open a QT webkit window and return the access code."""
    app = QtGui.QApplication([])
    dialog = QtGui.QDialog()
    dialog.setWindowTitle(title)
    dialog.resize(*size)
    webview = QtWebKit.QWebView()
    webpage = QtWebKit.QWebPage()
    webview.setPage(webpage)           
    webpage.loadFinished.connect(lambda: _on_qt_page_load_finished(dialog, webview))
    webview.setUrl(QtCore.QUrl.fromEncoded(url))
    layout = QtGui.QGridLayout()
    layout.addWidget(webview)
    dialog.setLayout(layout)
    dialog.authorization_code = None
    dialog.show()
    app.exec_()
    return dialog.authorization_code 
Example #2
Source File: coinbase_buyback.py    From encompass with GNU General Public License v3.0 6 votes vote down vote up
def propose_rebuy_qt(amount):
    web = QWebView()
    box = QMessageBox()
    box.setFixedSize(200, 200)

    credentials = read_local_oauth_credentials()
    questionText = _('Rebuy ') + format_satoshis(amount) + _(' BTC?')
    if credentials:
        credentials.refresh()
    if credentials and not credentials.invalid:
        credentials.store_locally()
        totalPrice = get_coinbase_total_price(credentials, amount)
        questionText += _('\n(Price: ') + totalPrice + _(')')

    if not question(box, questionText):
        return

    if credentials:
        do_buy(credentials, amount)
    else:
        do_oauth_flow(web, amount)
    return web 
Example #3
Source File: web_browser.py    From PyIntroduction with MIT License 6 votes vote down vote up
def mainPyQt4Simple():
    # 必要なモジュールのimport
    from PyQt4.QtCore import QUrl
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView

    url = 'https://github.com/tody411/PyIntroduction'

    app = QApplication(sys.argv)

    # QWebViewによるWebページ表示
    browser = QWebView()
    browser.load(QUrl(url))
    browser.show()

    sys.exit(app.exec_())

## PyQt4でのWebブラウザー作成(Youtube用). 
Example #4
Source File: ui_change_log.py    From stdm with GNU General Public License v2.0 6 votes vote down vote up
def setupUi(self, ChangeLog):
        ChangeLog.setObjectName(_fromUtf8("ChangeLog"))
        ChangeLog.resize(714, 557)
        self.verticalLayout = QtGui.QVBoxLayout(ChangeLog)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.webView = QtWebKit.QWebView(ChangeLog)
        self.webView.setUrl(QtCore.QUrl(_fromUtf8("about:blank")))
        self.webView.setObjectName(_fromUtf8("webView"))
        self.verticalLayout.addWidget(self.webView)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.buttonBox = QtGui.QDialogButtonBox(ChangeLog)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.horizontalLayout.addWidget(self.buttonBox)
        spacerItem = QtGui.QSpacerItem(600000, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.verticalLayout.addLayout(self.horizontalLayout)

        self.retranslateUi(ChangeLog)
        QtCore.QMetaObject.connectSlotsByName(ChangeLog) 
Example #5
Source File: memcanvas.py    From nightmare with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, mem, syms=None, parent=None):
        QtWebKit.QWebView.__init__(self, parent=parent)
        e_memcanvas.MemoryCanvas.__init__(self, mem, syms=syms)

        self.setContent(e_q_html.template, 'application/xhtml+xml')
        #self.setHtml(e_q_html.template)
        frame = self.page().mainFrame()
        self._canv_cache = None
        self._canv_rend_middle = False

        self._canv_curva = None
        self._canv_rendtagid = '#memcanvas'
        self._canv_hotkeys = {}

        self.page().mainFrame().addToJavaScriptWindowObject('vnav', self) 
Example #6
Source File: memcanvas.py    From nightmare with GNU General Public License v2.0 5 votes vote down vote up
def keyPressEvent(self, event):

        key = event.key()
        txt = str(event.text())
        #print 'KEY',hex(key),repr(txt)

        mods = int(event.modifiers())

        keytxt = ''
        if key < 255:

            keytxt = chr(key).lower()

            if mods & QMOD_SHIFT:
                keytxt = keytxt.upper()

            if mods & QMOD_CTRL:
                keytxt = 'ctrl+' + keytxt

        #print 'KEYTXT: %s' % keytxt

        handler = self._canv_hotkeys.get(keytxt)
        if handler == None:
            handler = self._canv_hotkeys.get(key)

        if handler != None:
            handler(self, key)
            event.accept()

        return QtWebKit.QWebView.keyPressEvent(self, event) 
Example #7
Source File: oauth_ui.py    From baiduyun with Apache License 2.0 5 votes vote down vote up
def __init__(self, oa_url, oa_result_base, args):
        super(OAuth2Application, self).__init__(args)
        self.oa_result_base = oa_result_base
        self.oa_result = oa_result_base
        self.browser = QWebView()
        self.browser.loadFinished.connect(self.__result_available)
        self.browser.load(QUrl(oa_url))
        self.browser.show()
        self.exec_() 
Example #8
Source File: viz_graph.py    From ibeis with Apache License 2.0 5 votes vote down vote up
def tryout_with_qt():
    import sys
    from PyQt4 import QtCore, QtWebKit, QtWidgets
    from os.path import join, dirname
    import ibeis.viz

    class Browser(QtWebKit.QWebView):

        def __init__(self):
            super(Browser, self).__init__()
            self.loadFinished.connect(self._result_available)

        def _result_available(self, ok):
            pass
            #frame = self.page().mainFrame()
            #print(unicode(frame.toHtml()).encode('utf-8'))

    app = QtWidgets.QApplication(sys.argv)

    view = Browser()
    view.show()
    path = join(dirname(ibeis.viz.__file__), 'd3_example.html')
    view.load(QtCore.QUrl(path))
    view.page().settings().setAttribute(
        QtWebKit.QWebSettings.DeveloperExtrasEnabled, True
    )

    insp = QtWebKit.QWebInspector()
    insp.setPage(view.page())
    insp.show()

    app.exec_() 
Example #9
Source File: web_browser.py    From PyIntroduction with MIT License 5 votes vote down vote up
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_())


## PyQt5でのWebブラウザー作成. 
Example #10
Source File: helpwindow.py    From segyviewer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        QWidget.__init__(self, parent, Qt.WindowStaysOnTopHint | Qt.Window)
        self.setVisible(False)

        self._view_help = QWebView(self)
        self._view_help.load(resource_html("helppage.html"))
        self._view_help.show()

        f_layout = QHBoxLayout()
        f_layout.addWidget(self._view_help)

        self.setLayout(f_layout) 
Example #11
Source File: run.py    From Open-Browser with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        QtWebKit.QWebView.__init__(self)
        self.installEventFilter(self) 
Example #12
Source File: run.py    From Open-Browser with GNU General Public License v3.0 5 votes vote down vote up
def loadUrl(self, url):
        view = QtWebKit.QWebView()
        view.connect(view, QtCore.SIGNAL('loadFinished(bool)'), self.loadFinished)
        view.connect(view, QtCore.SIGNAL('linkClicked(const QUrl&)'), self.linkClicked)
        view.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        self.dbx_tabWidget.setCurrentIndex(self.dbx_tabWidget.addTab(view, 'loading...'))
        view.load(url) 
Example #13
Source File: help.py    From wacom-gui with GNU General Public License v3.0 5 votes vote down vote up
def initUI(self):
        self.browser = QtWebKit.QWebView()
        file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "help.html"))
        local_url = QtCore.QUrl.fromLocalFile(file_path)
        self.browser.load(local_url)

        self.mainLayout = QtGui.QHBoxLayout()
        self.mainLayout.addWidget(self.browser)
        self.setLayout(self.mainLayout) 
Example #14
Source File: pandapower_gui.py    From pandapower_gui with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def show_docs(self):
        self.docs = QWebView()
        self.docs.load(QUrl("https://pandapower.readthedocs.io"))
        self.docs.setWindowTitle("pandapower Documentation")
        self.docs.show()