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


Python QWebView.setUrl方法代码示例

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


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

示例1: Event

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setUrl [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

示例2: HtmlFavoritePage

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setUrl [as 别名]
class HtmlFavoritePage():
    def __init__(self, page, layout, parent):
        self.page = page
        self.parent = parent
        
        container = QVBoxLayout()
        # actions section
        actionsContainer = QHBoxLayout()
        
        self.saveButton = QPushButton('Save')
        self.saveButton.clicked.connect(lambda: save_clicked(self))
                
        actionsContainer.addWidget(QLabel('Link: '))
        self.linkText = QLineEdit(page.url)
        
        label = QLabel('<a href="' + page.url + '">Open Externally</a>')
        label.setOpenExternalLinks(True)
        
        actionsContainer.addWidget(self.linkText)
        actionsContainer.addWidget(self.saveButton)
        actionsContainer.addWidget(label)
        container.addLayout(actionsContainer)
        
        # content 
        self.view = QWebView()
        self.view.setUrl(page.url)
        container.addWidget(self.view)
        layout.addLayout(container)        
开发者ID:cefolger,项目名称:favorites,代码行数:30,代码来源:pages.py

示例3: TestLoadFinished

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setUrl [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

示例4: UserAgentExample

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

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

        self.setWindowTitle('Custom User Agent Example')

        url = QUrl('http://getmyuseragent.com')
        page = CustomWebPage()

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

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

        self.setLayout(self.mainLayout)
开发者ID:lastkarrde,项目名称:QtWebKit-examples,代码行数:20,代码来源:useragent.py

示例5: Basic

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

    def __init__(self, parent=None):
        # call QWidget's __init__
        super(Basic, self).__init__(parent)

        self.setWindowTitle('Basic Application')

        url = QUrl('http://www.bitcoin.org/')

        # declare our QWebView and set the URL. The URL must be an instance of QUrl, not a string
        self.webView = QWebView()
        self.webView.setUrl(url)

        # set up our layout and add the instance of the QWebView
        self.mainLayout = QGridLayout()
        self.mainLayout.addWidget(self.webView)

        self.setLayout(self.mainLayout)
开发者ID:lastkarrde,项目名称:QtWebKit-examples,代码行数:21,代码来源:basic.py

示例6: Settings

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

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

        self.setWindowTitle('Settings, Debugger Application')

        url = QUrl('http://www.bitcoin.org/')

        settings = QWebSettings.globalSettings()
        settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)

        # more settings
        # http://pyside.org/docs/pyside/PySide/QtWebKit/QWebSettings.html#detailed-description

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

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

        self.setLayout(self.mainLayout)
开发者ID:lastkarrde,项目名称:QtWebKit-examples,代码行数:24,代码来源:settings.py

示例7: QWebView

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setUrl [as 别名]
from urllib import urlretrieve
from selenium import webdriver
import time
import sys

from albert_fixtures import url

from PySide import QtGui
from PySide import QtCore
from PySide.QtWebKit import QWebView, QWebSettings

app = QtGui.QApplication(sys.argv)

win = QWebView()

win.setUrl(QtCore.QUrl(url))

print "Getting frame..."
frame = win.page().mainFrame().documentElement()
print dir(win.page())

print "Getting button..."
button = frame.findFirst("#video_mode > label:nth-child(5)")
button.evaluateJavaScript("this.click()")

print "Getting image..."
image = frame.findFirst("#img1")

print "Done."
win.show()
app.exec_()
开发者ID:seuqaj114,项目名称:ANN,代码行数:33,代码来源:capture_test.py

示例8: PysideGui

# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setUrl [as 别名]
class PysideGui(generic.GenericGui):

    def __init__(self):
        generic.GenericGui.__init__(self)
        window = QWidget()
        window.setWindowTitle('quichem-pyside')

        self.compiler_view = QListWidget()
        self.compiler_view.currentRowChanged.connect(self.show_source)
        self.stacked_widget = QStackedWidget()
        self.stacked_widget.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        self.edit = QLineEdit()
        self.edit.setPlaceholderText('Type quichem input...')
        self.edit.textChanged.connect(self.change_value)
        self.view = QWebView()
        self.view.page().mainFrame().setScrollBarPolicy(Qt.Vertical,
                                                        Qt.ScrollBarAlwaysOff)
        self.view.page().action(QWebPage.Reload).setVisible(False)
        self.view.setMaximumHeight(0)
        self.view.setUrl('qrc:/web/page.html')
        self.view.setZoomFactor(2)
        self.view.page().mainFrame().contentsSizeChanged.connect(
            self._resize_view)
        # For debugging JS:
        ## from PySide.QtWebKit import QWebSettings
        ## QWebSettings.globalSettings().setAttribute(
        ##     QWebSettings.DeveloperExtrasEnabled, True)

        button_image = QPushButton('Copy as Image')
        button_image.clicked.connect(self.set_clipboard_image)
        button_image.setToolTip('Then paste into any graphics program')
        button_word = QPushButton('Copy as MS Word Equation')
        button_word.clicked.connect(self.set_clipboard_word)
        button_html = QPushButton('Copy as Formatted Text')
        button_html.clicked.connect(self.set_clipboard_html)
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        button_layout = QHBoxLayout()
        button_layout.addStretch()
        button_layout.addWidget(button_image)
        button_layout.addWidget(button_word)
        button_layout.addWidget(button_html)
        source_layout = QHBoxLayout()
        source_layout.addWidget(self.compiler_view)
        source_layout.addWidget(self.stacked_widget, 1)
        QVBoxLayout(window)
        window.layout().addWidget(self.edit)
        window.layout().addWidget(self.view)
        window.layout().addLayout(button_layout)
        window.layout().addWidget(line)
        window.layout().addLayout(source_layout, 1)

        window.show()
        window.resize(window.minimumWidth(), window.height())
        # To prevent garbage collection of internal Qt object.
        self._window = window

    def show_source(self, index):
        if not self.sources:
            return
        self.stacked_widget.setCurrentIndex(index)
        self.change_value(self.edit.text())

    def _resize_view(self):
        """Set the QWebView's minimum height based on its current
        contents.

        """
        div = self.view.page().mainFrame().findFirstElement('.output')
        scrollbar_width = QApplication.style().pixelMetric(
            QStyle.PM_ScrollBarExtent)
        self.view.setMaximumHeight(
            div.geometry().height() + scrollbar_width + 16)

    def make_source(self, name):
        self.compiler_view.addItem(name)
        self.compiler_view.setCurrentRow(0)
        scrollbar_width = QApplication.style().pixelMetric(
            QStyle.PM_ScrollBarExtent)
        self.compiler_view.setMaximumWidth(
            self.compiler_view.sizeHintForColumn(0) + scrollbar_width + 16)
        page = QWidget()
        QHBoxLayout(page)
        page.layout().setContentsMargins(*(0,) * 4)
        source = QTextEdit()
        source.setStyleSheet('min-width: 0; min-height: 0')
        source.setReadOnly(True)
        QVBoxLayout(source)
        button = QPushButton('Copy')
        button.clicked.connect(functools.partial(self.set_clipboard, source))
        page.layout().addWidget(source)
        source.layout().addWidget(button, 0, Qt.AlignRight | Qt.AlignBottom)
        self.stacked_widget.addWidget(page)
        return source

    def run_script(self, js):
        self.view.page().mainFrame().evaluateJavaScript(js)

#.........这里部分代码省略.........
开发者ID:spamalot,项目名称:quichem,代码行数:103,代码来源:pyside.py


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