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


Python QtWebKitWidgets.QWebPage类代码示例

本文整理汇总了Python中PyQt5.QtWebKitWidgets.QWebPage的典型用法代码示例。如果您正苦于以下问题:Python QWebPage类的具体用法?Python QWebPage怎么用?Python QWebPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, opts, log):
        from calibre.gui2 import secure_web_page
        self.log = log
        QWebPage.__init__(self)
        settings = self.settings()
        secure_web_page(settings)
        settings.setFontSize(QWebSettings.DefaultFontSize,
                opts.pdf_default_font_size)
        settings.setFontSize(QWebSettings.DefaultFixedFontSize,
                opts.pdf_mono_font_size)
        settings.setFontSize(QWebSettings.MinimumLogicalFontSize, 8)
        settings.setFontSize(QWebSettings.MinimumFontSize, 8)

        std = {'serif':opts.pdf_serif_family, 'sans':opts.pdf_sans_family,
                'mono':opts.pdf_mono_family}.get(opts.pdf_standard_font,
                        opts.pdf_serif_family)
        if std:
            settings.setFontFamily(QWebSettings.StandardFont, std)
        if opts.pdf_serif_family:
            settings.setFontFamily(QWebSettings.SerifFont, opts.pdf_serif_family)
        if opts.pdf_sans_family:
            settings.setFontFamily(QWebSettings.SansSerifFont,
                    opts.pdf_sans_family)
        if opts.pdf_mono_family:
            settings.setFontFamily(QWebSettings.FixedFont, opts.pdf_mono_family)
开发者ID:rlugojr,项目名称:calibre,代码行数:25,代码来源:writer.py

示例2: webpage

def webpage(qnam):
    """Get a new QWebPage object."""
    from PyQt5.QtWebKitWidgets import QWebPage

    page = QWebPage()
    page.networkAccessManager().deleteLater()
    page.setNetworkAccessManager(qnam)
    return page
开发者ID:derlaft,项目名称:qutebrowser,代码行数:8,代码来源:conftest.py

示例3: __init__

 def __init__(self):
     self.log = default_log
     QWebPage.__init__(self)
     self.js = None
     self.evaljs = self.mainFrame().evaluateJavaScript
     self.bridge_value = None
     nam = self.networkAccessManager()
     nam.setNetworkAccessible(nam.NotAccessible)
     self.setLinkDelegationPolicy(self.DelegateAllLinks)
开发者ID:AtulKumar2,项目名称:calibre,代码行数:9,代码来源:location.py

示例4: __init__

 def __init__(self, log):
     self.log = log
     QWebPage.__init__(self)
     self.js = None
     self.evaljs = self.mainFrame().evaluateJavaScript
     self.bridge_value = None
     nam = self.networkAccessManager()
     nam.setNetworkAccessible(nam.NotAccessible)
     self.longjs_counter = 0
开发者ID:Aliminator666,项目名称:calibre,代码行数:9,代码来源:stats.py

示例5: webpage

def webpage():
    """Get a new QWebPage object."""
    from PyQt5.QtWebKitWidgets import QWebPage
    from PyQt5.QtNetwork import QNetworkAccessManager

    page = QWebPage()
    nam = page.networkAccessManager()
    nam.setNetworkAccessible(QNetworkAccessManager.NotAccessible)
    return page
开发者ID:baskervald,项目名称:qutebrowser,代码行数:9,代码来源:conftest.py

示例6: __init__

 def __init__(self, parent):
     QWebPage.__init__(self, parent)
     self.js_loader = None
     self._footnote_data = ''
     from calibre.gui2.viewer.documentview import apply_basic_settings
     settings = self.settings()
     apply_basic_settings(settings)
     settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, False)
     self.setLinkDelegationPolicy(self.DelegateAllLinks)
     self.mainFrame().javaScriptWindowObjectCleared.connect(self.add_window_objects)
     self.add_window_objects()
开发者ID:rlugojr,项目名称:calibre,代码行数:11,代码来源:footnote.py

示例7: Browser

class Browser(object):

    def __init__(self):
        self.network_manager = QNetworkAccessManager()
        self.network_manager.createRequest = self._create_request
        self.network_manager.finished.connect(self._request_finished)

        self.web_page = QWebPage()
        self.web_page.setNetworkAccessManager(self.network_manager)

        self.web_view = QWebView()
        self.web_view.setPage(self.web_page)

    def _create_request(self, operation, request, data):
        print(data.readAll())
        reply = QNetworkAccessManager.createRequest(self.network_manager,
                                                    operation,
                                                    request,
                                                    data)
        return reply

    def _request_finished(self, reply):
        if not reply.error() == QNetworkReply.NoError:
            # request probably failed
            print(reply.error())
            print(reply.errorString())

    def _make_request(self, url):
        request = QNetworkRequest()
        request.setUrl(QUrl(url))
        return request

    def _urlencode_post_data(self, post_data):
        post_params = QUrl()
        for (key, value) in post_data.items():
            post_params.addQueryItem(key, value)

        return post_params.encodedQuery()

    def perform(self, url, method='GET', post_data=dict()):
        request = self._make_request(url)

        if method == 'GET':
            self.web_view.load(request)
        else:
            encoded_data = self._urlencode_post_data(post_data)
            request.setRawHeader('Content-Type',
                                 QByteArray('application/x-www-form-urlencoded'))
            self.web_view.load(request,
                               QNetworkAccessManager.PostOperation,
                               encoded_data)
开发者ID:blropb,项目名称:qt-test,代码行数:51,代码来源:test.py

示例8: WebLoader

class WebLoader(QObject):
    
    _finished = pyqtSignal(str)
    
    def __init__(self, key):
        super(WebLoader, self).__init__()

#         if platform.python_version() < '3.0.0':
#             self._key = unicode(key)
  
        self._key = key
        self._percent = 0
        self._page = QWebPage()
        self._page.mainFrame().setScrollBarPolicy(Qt.Vertical,  Qt.ScrollBarAlwaysOff)
        self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
        self._page.loadProgress.connect(self.printProgress)
        
        
    def printProgress(self, percent):
        if self._percent >= percent:
            cout("\n")
            return
        else:
            cout('#' * (percent - self._percent))
            self._percent = percent
            
    def load(self, url):
        self._percent = 0
        self._url = QUrl.fromUserInput(url)
        self._page.mainFrame().load(self._url)
        self._page.setViewportSize(QSize(1920, 10000))  
        print("Loading... %s" % url)
开发者ID:luckywqf,项目名称:wordpress_blog_to_pdf,代码行数:32,代码来源:blogtopdf.py

示例9: __init__

 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent reference to the parent object (QObject)
     """
     super(PageThumbnailer, self).__init__(parent)
     
     self.__page = QWebPage(self)
     self.__size = QSize(231, 130)
     self.__loadTitle = False
     self.__title = ""
     self.__url = QUrl()
     
     self.__proxy = NetworkAccessManagerProxy(self)
     import Helpviewer.HelpWindow
     self.__proxy.setPrimaryNetworkAccessManager(
         Helpviewer.HelpWindow.HelpWindow.networkAccessManager())
     self.__page.setNetworkAccessManager(self.__proxy)
     
     self.__page.mainFrame().setScrollBarPolicy(
         Qt.Horizontal, Qt.ScrollBarAlwaysOff)
     self.__page.mainFrame().setScrollBarPolicy(
         Qt.Vertical, Qt.ScrollBarAlwaysOff)
     
     # Full HD
     # Every page should fit in this resolution
     self.__page.setViewportSize(QSize(1920, 1080))
开发者ID:pycom,项目名称:EricShort,代码行数:28,代码来源:PageThumbnailer.py

示例10: acceptNavigationRequest

 def acceptNavigationRequest(self, frame, request, type):
     if(type == QWebPage.NavigationTypeLinkClicked):
         if(frame == self.mainFrame()):
             self.view().link_clicked(request.url())
         else:
             call_method("open-url", [request.url().toString()])
             return False
         
     return QWebPage.acceptNavigationRequest(self, frame, request, type)            
开发者ID:Jell,项目名称:emacs-webkit,代码行数:9,代码来源:browser.py

示例11: userAgentForUrl

    def userAgentForUrl(self, url):
        """Handle reqests for the browser's user agent

        Overridden from QWebPage so we can force a user agent from the config.
        """
        return (
            self.config.get("user_agent")
            or QWebPage.userAgentForUrl(self, url)
        )
开发者ID:Daguerreo,项目名称:wcgbrowser,代码行数:9,代码来源:browser.py

示例12: __init__

    def __init__(self):
        self.network_manager = QNetworkAccessManager()
        self.network_manager.createRequest = self._create_request
        self.network_manager.finished.connect(self._request_finished)

        self.web_page = QWebPage()
        self.web_page.setNetworkAccessManager(self.network_manager)

        self.web_view = QWebView()
        self.web_view.setPage(self.web_page)
开发者ID:blropb,项目名称:qt-test,代码行数:10,代码来源:test.py

示例13: __init__

    def __init__(self, parent):
        QWebPage.__init__(self, parent)
        settings = self.settings()
        apply_settings(settings, config().parse())
        settings.setMaximumPagesInCache(0)
        secure_web_page(settings)
        settings.setAttribute(settings.PrivateBrowsingEnabled, True)
        settings.setAttribute(settings.LinksIncludedInFocusChain, False)
        settings.setAttribute(settings.DeveloperExtrasEnabled, True)
        settings.setDefaultTextEncoding('utf-8')
        data = 'data:text/css;charset=utf-8;base64,'
        css = '[data-in-split-mode="1"] [data-is-block="1"]:hover { cursor: pointer !important; border-top: solid 5px green !important }'
        data += b64encode(css.encode('utf-8'))
        settings.setUserStyleSheetUrl(QUrl(data))

        self.setNetworkAccessManager(NetworkAccessManager(self))
        self.setLinkDelegationPolicy(self.DelegateAllLinks)
        self.mainFrame().javaScriptWindowObjectCleared.connect(self.init_javascript)
        self.init_javascript()
开发者ID:rlugojr,项目名称:calibre,代码行数:19,代码来源:preview.py

示例14: acceptNavigationRequest

	def acceptNavigationRequest(self, frame, request, type):
		if(type == QWebPage.NavigationTypeLinkClicked):
			url = request.url().toString()
			if(frame == self.mainFrame()):
				self.view().load(url)
				return False
			elif frame == None:
				# self.createWindow(QWebPage.WebBrowserWindow, url)
				webbrowser.open(request.url().toString())
				return False
		return QWebPage.acceptNavigationRequest(self, frame, request, type)
开发者ID:Fe-ver,项目名称:hae,代码行数:11,代码来源:webpage.py

示例15: __init__

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

        self._percent = 0
        self._page = QWebPage()
        self._page.mainFrame().setScrollBarPolicy(Qt.Vertical,
                Qt.ScrollBarAlwaysOff)
        self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal,
                Qt.ScrollBarAlwaysOff)
        self._page.loadProgress.connect(self.printProgress)
        self._page.loadFinished.connect(self.saveResult)
开发者ID:death-finger,项目名称:Scripts,代码行数:11,代码来源:framecapture.py


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