Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import os
- from PyQt4 import QtWebKit
- from PyQt4.QtCore import *
- from PyQt4.QtGui import *
- from PyKDE4.plasma import Plasma
- from PyKDE4 import plasmascript
- from PyKDE4.kdecore import KUrl
- class RdioApplet(plasmascript.Applet):
- def __init__(self,parent,args=None):
- plasmascript.Applet.__init__(self,parent)
- def init(self):
- self.setHasConfigurationInterface(False)
- self.theme = Plasma.Svg(self)
- self.theme.setImagePath("widgets/background")
- self.setHasConfigurationInterface(False)
- self.setBackgroundHints(Plasma.Applet.DefaultBackground)
- self.setAspectRatioMode(Plasma.Square)
- self.resize(300,50)
- self.refreshPage()
- def refreshPage(self):
- self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
- # 1 - trying to set a custom height for the QGraphicsLinearLayout
- self.layout.setMaximumHeight(50)
- self.webView = Plasma.WebView(self.applet)
- self.webView.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
- # 2 - tryging to set a custom geometry for the Plasma.WebView
- self.webView.setGeometry(QRectF(0, 0, 300, 50))
- self.page = FAgent()
- # 3 - trying to set a custom viewport size for the QWebPage
- self.page.setViewportSize(QSize(300, 50))
- # 4 - also, trying to set a prefered contents size for the QWebPage
- self.page.setPreferredContentsSize(QSize(300, 50))
- self.webView.setPage(self.page)
- self.webView.setUrl(KUrl("https://www.google.com"))
- self.layout.addItem(self.webView)
- self.setLayout(self.layout)
- self.update()
- class FAgent(QtWebKit.QWebPage):
- def __init__(self):
- QtWebKit.QWebPage.__init__(self)
- self.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True)
- def javaScriptConsoleMessage(self, message, lineNumber, sourceId):
- print message, lineNumber, sourceId
- def CreateApplet(parent):
- return RdioApplet(parent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement