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.refreshPage()
- def refreshPage(self):
- self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
- # Using Qt's native "QtWebKit.QGraphicsWebView" implementation to avoid the limitation of minimum size ("128x128") caused by the "Plasma.WebView"
- self.webView = QtWebKit.QGraphicsWebView()
- self.page = FAgent()
- 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)
- 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