This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Plasmoid scripting problem

Tags: None
(comma "," separated)
User avatar
BartOtten
Moderator
Posts
33
Karma
0
OS
Could somebody help me fix this error? I try to script an python plasmoid, here is the code:

Code: Select all
# -*- coding: utf-8 -*-

import sys, os, shutil, commands
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
from PyKDE4.kdecore import KUrl, i18n, KComponentData, KGlobal
from urllib import urlencode
from PyKDE4.kdeui import KNotification
from PyKDE4.kio import KIO
from PyKDE4.solid import *


# Refreshing widget every 2 minutes:
refreshTime = 30000

class HyvesApplet(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.setBackgroundHints(Plasma.Applet.DefaultBackground)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
        self.resize(300,400)
       
        self.setup_network()
       
        #if self.is_connected:
        #self.setBusy(False)

        self.timer = QTimer()
        self.connect(self.timer,SIGNAL("timeout()"),self.refreshPage)
        self.timer.start(refreshTime)

        # First time we will refresh manually before timer to load widget immediately
        # in case Network connection is already present:
        self.refreshPage()
       
       
    def setup_network(self):
        self.is_connected = (Solid.Networking.status() == Solid.Networking.Connected) == True
        print "setup_network: %i" % self.is_connected
        if not self.is_connected:
            self.do_notify("waiting-for-network", i18n("Waiting for network connection"))

     
     def refreshPage(self):

        # Checking Network status If there is no Network... do nothing (just keep querying):
        if (self.is_connected != True):
            return
       
        print "Presenting Hyves on widget..."
        layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
        webView = Plasma.WebView(self.applet)
        webView.setUrl(KUrl("http://www.hyves.nl/mini"))
        layout.addItem(webView)
        self.setLayout(layout)
        self.update()

        # We no longer need the timer so stopping it:
        print "Stopping timer..."
        self.timer.stop()

def CreateApplet(parent):
    return HyvesApplet(parent)


The output is:
Code: Select all
plasmate(8630)/libplasma Plasma::FrameSvg::resizeFrame: Invalid size QSizeF(0, 0)
plasmate(8630)/libplasma Plasma::FrameSvg::resizeFrame: Invalid size QSizeF(0, 0)
Traceback (most recent call last):
  File "/usr/share/kde4/apps/plasma_scriptengine_python/pyappletscript.py", line 65, in init
    self.pyapplet = self.module.__dict__[basename].CreateApplet(None)
AttributeError: 'module' object has no attribute 'CreateApplet'


Seems to me everything should just work fine...But is does not. I can't find a fix for it (using Google).

Any help is appreciated!


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]