当前位置: 首页>>代码示例>>Python>>正文


Python QWebView.page方法代码示例

本文整理汇总了Python中PySide.QtWebKit.QWebView.page方法的典型用法代码示例。如果您正苦于以下问题:Python QWebView.page方法的具体用法?Python QWebView.page怎么用?Python QWebView.page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtWebKit.QWebView的用法示例。


在下文中一共展示了QWebView.page方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testBug899

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
    def testBug899(self):
        html = '''
        <html><body>
        <script type="text/javascript">
        document.write("<p>"+py_obj.list1+"</p>")
        document.write("<p>"+py_obj.list2+"</p>")
        </script>
        </body></html>
        '''

        class Obj(object):
            list1 = ['foo', 'bar', 'baz']
            list2 = ['fi', 'fo', 'fum']

        obj = Obj()

        wrapper_dict = {}
        for name in ('list1', 'list2'):
            getter = lambda arg=None, name=name: getattr(obj, name)
            wrapper_dict[name] = Property('QVariantList', getter)
        wrapper = type('PyObj', (QObject,), wrapper_dict)

        view = QWebView()
        view.page().mainFrame().addToJavaScriptWindowObject('py_obj', wrapper())
        view.setHtml(html)
开发者ID:Hasimir,项目名称:PySide,代码行数:27,代码来源:bug_899.py

示例2: TestJsCall

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
class TestJsCall(UsesQApplication):

    @classmethod
    def setUpClass(self):
        super(TestJsCall, self).setUpClass()

    def createInstance(self):
        global functionID
        self._view = QWebView()
        self._jsfuncs = JSFuncs()
        functionID = -1
        self._view.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", self._jsfuncs)
        self._view.loadFinished[bool].connect(self.onLoadFinished)
        self._view.load(PAGE_DATA % FUNCTIONS_LIST[self._functionID])
        self._view.show()

    def testJsCall(self):
        self._functionID = 0
        self.createInstance()
        self.app.exec_()

    def onLoadFinished(self, result):
        global functionID
        self.assertEqual(self._functionID, functionID)
        if self._functionID == (len(FUNCTIONS_LIST) - 1):
            QTimer.singleShot(300, self.app.quit)
        else:
            #new test
            self._functionID += 1
            self.createInstance()
开发者ID:Hasimir,项目名称:PySide,代码行数:32,代码来源:bug_959.py

示例3: Browser

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
class Browser(QObject):
	# pylint: disable=too-many-public-methods

	__execute_script_called = Signal(str)

	def __init__(self):
		super().__init__()

		self.app = QApplication([])

		self.webview = QWebView()
		self.webview.setAttribute(Qt.WA_DeleteOnClose)
		self.webview.destroyed.connect(self.app.quit)

		self.__execute_script_called.connect(self.__execute_script)

	def __execute_script(self, javascript_code: str):
		assert current_thread_is_main()
		self.webview.page().mainFrame().evaluateJavaScript(javascript_code)

	def execute_script(self, javascript_code: str):
		if current_thread_is_main():
			self.__execute_script(javascript_code)
		else:
			self.__execute_script_called.emit(javascript_code)

	def run(self, url):
		assert current_thread_is_main()
		self.webview.showFullScreen()
		self.webview.load(url)
		self.app.exec_()
开发者ID:SetSplin,项目名称:DigitalLibrary,代码行数:33,代码来源:client.py

示例4: WebMediaView

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
class WebMediaView(MediaView):
    def __init__(self, media, parent):
        super(WebMediaView, self).__init__(media, parent)
        self._widget = QWebView(parent)
        self._widget.setGeometry(media['_geometry'])
        self.set_default_widget_prop()
        self._widget.setDisabled(True)
        self._widget.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        self._widget.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)

    @Slot()
    def play(self):
        self._finished = 0
        path = "%s/%s_%s_%s.html" % (
            self._save_dir,
            self._layout_id, self._region_id, self._id
        )
        self._widget.load("about:blank")
        if 'webpage' == str(self._type) and 'native' == str(self._render):
            url = self._options['uri']
            self._widget.load(QUrl.fromPercentEncoding(url))
        else:
            self._widget.load('file://' + path)
        self._widget.show()
        self._widget.raise_()

        self._play_timer.setInterval(int(float(self._duration) * 1000))
        self._play_timer.start()
        self.started_signal.emit()
开发者ID:ajiwo,项目名称:xiboside,代码行数:31,代码来源:xlfview.py

示例5: createWebView

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
def createWebView( nIndex ):
    global functionID
    global currentWebView

    functionID = nIndex
    currentWebView = QWebView()
    currentWebView._jsfuncs = JSFuncs()
    currentWebView.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", currentWebView._jsfuncs)
    QObject.connect( currentWebView, QtCore.SIGNAL('loadFinished( bool )'), onLoadFinished )
    currentWebView.load(PAGE_DATA % FUNCTIONS_LIST[ nIndex ])
    currentWebView.show()
开发者ID:PySide,项目名称:PySide,代码行数:13,代码来源:bug_959.py

示例6: new_tab

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
    def new_tab(self):
        """Open new tab."""
        tasklist = QTreeView()
        tasklist.hide()
        tasklist.setObjectName('taskList')
        tasklist.setMinimumWidth(100)
        tasklist.setMaximumWidth(250)

        new_tab = QWebView()
        new_tab.setObjectName('webView')

        inspector = QWebInspector(self)
        inspector.setObjectName('webInspector')
        inspector.hide()

        page_layout = QVBoxLayout()
        page_layout.setSpacing(0)
        page_layout.setContentsMargins(0, 0, 0, 0)
        page_layout.addWidget(new_tab)
        page_layout.addWidget(inspector)
        page_widget = QFrame()
        page_widget.setObjectName('pageWidget')
        page_widget.setLayout(page_layout)

        complete_tab_layout = QHBoxLayout()
        complete_tab_layout.setSpacing(0)
        complete_tab_layout.setContentsMargins(0, 0, 0, 0)
        complete_tab_layout.addWidget(tasklist)
        complete_tab_layout.addWidget(page_widget)
        complete_tab_widget = QFrame()
        complete_tab_widget.setLayout(complete_tab_layout)

        new_tab.load(QUrl(self.startpage))
        self.tabs.setUpdatesEnabled(False)
        if self.new_tab_behavior == "insert":
            self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
                                    unicode(new_tab.title()))
        elif self.new_tab_behavior == "append":
            self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
        self.tabs.setCurrentWidget(complete_tab_widget)
        self.tabs.setTabText(self.tabs.currentIndex(),
                             unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title()))
        self.tabs.setUpdatesEnabled(True)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        new_tab.titleChanged.connect(self.change_tab)
        new_tab.urlChanged.connect(self.change_tab)
        new_tab.loadStarted.connect(self.load_start)
        new_tab.loadFinished.connect(self.load_finish)
        new_tab.loadProgress.connect(self.pbar.setValue)
        new_tab.page().linkHovered.connect(self.linkHover)
        inspector.setPage(new_tab.page())
开发者ID:eivind88,项目名称:raskolnikov-browser,代码行数:54,代码来源:main.py

示例7: testPlugin

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
    def testPlugin(self):
        view = QWebView()
        fac = PluginFactory()
        view.page().setPluginFactory(fac)
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)

        view.load(QUrl(os.path.join(os.path.abspath(os.path.dirname(__file__)), "qmlplugin", "index.html")))

        view.resize(840, 600)
        view.show()

        QTimer.singleShot(500, self.app.quit)

        self.app.exec_()
开发者ID:holmeschiu,项目名称:PySide,代码行数:16,代码来源:qml_plugin_test.py

示例8: main

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
def main():

    app = QApplication([])

    view = QWebView()
    fac = PluginFactory()
    view.page().setPluginFactory(fac)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)

    view.load(QUrl(sys.argv[1]))

    view.resize(840, 600)
    view.show()

    return app.exec_()
开发者ID:AmerGit,项目名称:Examples,代码行数:17,代码来源:main.py

示例9: Robot

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
class Robot(object):
    
    def __init__(self):
        self.view = QWebView() 
        self.page = self.view.page()
        
    def start(self):
        self.view.show()
        QtCore.QObject.connect(self.view, 
                               QtCore.SIGNAL("loadFinished(bool)"), 
                               self.loaded)                            
        self.view.load(QUrl('https://login.yahoo.com/config/login_verify2?&.src=ym'))
    
    def loaded(self):
        url = self.view.url().toString()
        self.view.show()
        print "Loading %s finished" % url
        
        frame = self.page.mainFrame()
        els = frame.findAllElements("a[id*='copyright']")
        for i in range(els.count()):
            print 'Plain Text [%s]' %  els.at(i).toPlainText().encode('utf8','ignore')
            print 'inner xml  %s' % els.at(i).toInnerXml()
            child_els = els.at(i).findAll('*')
            for j in range(child_els.count()):
                print 'childs inner xml [%s] ' % child_els.at(j).toInnerXml()
开发者ID:juanchitot,项目名称:jaimeboot,代码行数:28,代码来源:test_browser.py

示例10: webkit_download

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
def webkit_download(url):
    app = QApplication([])
    webview = QWebView()
    webview.loadFinished.connect(app.quit)
    webview.load(url)
    app.exec_() # delay here until download finished
    return webview.page().mainFrame().toHtml()
开发者ID:mk-z,项目名称:windbg,代码行数:9,代码来源:webkit_render.py

示例11: Event

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
class Event(QWidget):

    def __init__(self, parent=None):
        super(Event, self).__init__(parent)

        self.setWindowTitle('loadFinished Event')


        url = QUrl('https://www.torproject.org/')

        self.webView = QWebView()
        self.webView.setUrl(url)

        page = self.webView.page()
        frame = page.mainFrame()

        frame.loadFinished.connect(self.load_finished)
    

        self.mainLayout = QGridLayout()
        self.mainLayout.addWidget(self.webView)

        self.setLayout(self.mainLayout)


    def load_finished(self):
        print 'load has finished'
开发者ID:lastkarrde,项目名称:QtWebKit-examples,代码行数:29,代码来源:event.py

示例12: HTMLApplication

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
class HTMLApplication(object):

    def show(self):
        #It is IMPERATIVE that all forward slashes are scrubbed out, otherwise QTWebKit seems to be
        # easily confused
        kickOffHTML = join(dirname(__file__).replace('\\', '/'), "templates/index.html").replace('\\', '/')

        #This is basically a browser instance
        self.web = QWebView()

        #Unlikely to matter but prefer to be waiting for callback then try to catch
        # it in time.
        self.web.loadFinished.connect(self.onLoad)
        self.web.load(kickOffHTML)

        self.web.show()

    def onLoad(self):
        #This is the body of a web browser tab
        self.myPage = self.web.page()
        self.myPage.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
        #This is the actual context/frame a webpage is running in.
        # Other frames could include iframes or such.
        self.myFrame = self.myPage.mainFrame()
        # ATTENTION here's the magic that sets a bridge between Python to HTML
        self.myFrame.addToJavaScriptWindowObject("eth", self.ethclient)

        #Tell the HTML side, we are open for business
        self.myFrame.evaluateJavaScript("ApplicationIsReady()")
开发者ID:Bitcoinzie,项目名称:pyethereum,代码行数:31,代码来源:main.py

示例13: testQVariantListProperty

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
    def testQVariantListProperty(self):
        class Obj(object):
            list = ['foo', 'bar', 'baz']

        obj = Obj()

        wrapper_dict = {}
        for name in ['list']:
            getter = lambda arg=None, name=name: getattr(obj, name)
            wrapper_dict[name] = Property('QVariantList', getter)
        wrapper = type('PyObj', (QObject,), wrapper_dict)

        view = QWebView()
        frame = view.page().mainFrame()
        frame.addToJavaScriptWindowObject('py_obj', wrapper())

        html = '''
        <html><body>
        <script type="text/javascript">
        document.write(py_obj.list)
        </script>
        </body></html>
        '''
        view.setHtml(html)
        view.show()
        self.app.exec_()
开发者ID:Hasimir,项目名称:PySide,代码行数:28,代码来源:qvariantlist_property_test.py

示例14: main

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
def main():
    app = QApplication(sys.argv)
    view = QWebView()
    frame = view.page().mainFrame()
    printer = ConsolePrinter()

    view.setHtml(html)
    frame.addToJavaScriptWindowObject('printer', printer)
    frame = frame
    #frame.evaluateJavaScript("alert('Hello');")
    #frame.evaluateJavaScript("printer.text('Goooooooooo!');")
    view.show()
    app.processEvents()
    app.exec_()
开发者ID:zodman,项目名称:nekoplayer,代码行数:16,代码来源:small-webbrowser_old.py

示例15: TestLoadFinished

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import page [as 别名]
class TestLoadFinished(TimedQApplication):
    '''Test case for signal QWebView.loadFinished(bool)'''

    def setUp(self):
        #Acquire resources
        TimedQApplication.setUp(self, timeout=1000)
        self.view = QWebView()
        QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
                        self.load_finished)
        self.called = False

    def tearDown(self):
        #Release resources
        del self.view
        self.called = False
        TimedQApplication.tearDown(self)

    def testLoadFinishedFromFile(self):
        url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
        self.view.setUrl(url)
        self.app.exec_()

        self.assert_(self.called)

    def testSetPageAndGetPage(self):
        twp = testWebPage()
        self.view.setPage(twp)
        del twp
        p = self.view.page()
        self.assertEqual(p.sayMyName(), 'testWebPage')

        # Setting the same webpage should not incref the python obj
        refCount = sys.getrefcount(p)
        self.view.setPage(p)
        self.assertEquals(sys.getrefcount(p), refCount)

        # Changing the webpage obj should decref the old one
        twp2 = testWebPage()
        self.view.setPage(twp2)
        self.assertEquals(sys.getrefcount(p), refCount - 1)

    def load_finished(self, ok):
        #Callback to check if load was successful
        self.app.quit()
        if ok:
            self.called = True
开发者ID:Hasimir,项目名称:PySide,代码行数:48,代码来源:webview_test.py


注:本文中的PySide.QtWebKit.QWebView.page方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。