Advertisement
Guest User

Untitled

a guest
Jan 14th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import os
  4. from PyQt4 import QtWebKit
  5. from PyQt4.QtCore import *
  6. from PyQt4.QtGui import *
  7. from PyKDE4.plasma import Plasma
  8. from PyKDE4 import plasmascript
  9. from PyKDE4.kdecore import KUrl
  10.  
  11.  
  12. class RdioApplet(plasmascript.Applet):
  13.     def __init__(self, parent, args=None):
  14.         plasmascript.Applet.__init__(self, parent)
  15.  
  16.     def init(self):
  17.         self.setHasConfigurationInterface(False)
  18.  
  19.         self.theme = Plasma.Svg(self)
  20.         self.theme.setImagePath("widgets/background")
  21.         self.setHasConfigurationInterface(False)
  22.         self.setBackgroundHints(Plasma.Applet.DefaultBackground)
  23.         self.setAspectRatioMode(Plasma.Square)
  24.         self.refreshPage()
  25.  
  26.     def refreshPage(self):
  27.         self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
  28.        
  29.         # Using Qt's native "QtWebKit.QGraphicsWebView" implementation to avoid the limitation of minimum size ("128x128") caused by the "Plasma.WebView"
  30.         self.webView = QtWebKit.QGraphicsWebView()
  31.        
  32.         self.page = FAgent()
  33.         self.webView.setPage(self.page)
  34.         self.webView.setUrl(KUrl("https://www.google.com"))
  35.        
  36.         self.layout.addItem(self.webView)      
  37.         self.setLayout(self.layout)
  38.        
  39.         self.update()
  40.        
  41.        
  42. class FAgent(QtWebKit.QWebPage):
  43.     def __init__(self):
  44.         QtWebKit.QWebPage.__init__(self)
  45.        
  46.     def javaScriptConsoleMessage(self, message, lineNumber, sourceId):
  47.         print message, lineNumber, sourceId
  48.  
  49.  
  50. def CreateApplet(parent):
  51.     return RdioApplet(parent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement