Data Engine/QML/Python Guidance Needed

Eric Mesa ericsbinaryworld at gmail.com
Sat Aug 13 21:07:31 UTC 2011


Hello Plasma-Devel List!

I have a Python script that I'm trying to turn into a Plasmoid.  On a scale of 
1-10 where 10 is the most proficient hacker, I am about a 1 or a 0.5 when it 
comes to GUI stuff.  On top of that, there's the concept of data engines.  

I based my data engine off of the Python Data engine tutorial:

(begin code)
from PyQt4.QtCore import *
from PyKDE4.kdecore import *
from PyKDE4 import plasmascript
#for flickr
import views


class PyFlickrEngine(plasmascript.DataEngine):
  def __init__(self,parent,args=None):
    plasmascript.DataEngine.__init__(self,parent)
    
  def init(self):
    self.setMinimumPollingInterval(333)
    #for flickr
    views.initialize()
    
  
  def sourceRequestEvent(self, name):
    print "source request event" #debugging
    return self.updateSourceEvent(name)
    
  def updateSourceEvent(self,group):
    print "updateSourceEvent"
    #grouplist = []
    if group == "25":
      print "i'm here"
      grouplist = views.analyzeviews(views.views25)
      #self.setData(grouplist, "Group List", QVariant.List) #original line
      self.setData("25", "Group 25", grouplist)
    elif group == "50":
      grouplist = views.analyzeviews(views.views50)
      self.setData("50","Group 50", grouplist)
    elif group == "75":
      grouplist = views.analyzeviews(views.views75)
      self.setData("75","Group 75", grouplist)
    return True
    
def CreateDataEngine(parent):
  return PyFlickrEngine(parent)

(end code)

When I look at this in the Plasma Engine Explorer I see the following:

Datasource  key              Value                    Type
25
|_               Group List   Not displayable    PyQT_PyObject


Now, views.py, the program script it's calling is returning a tuple with the 
first entry being an XML object and the second being a list.  

So, first of all, it it right that the type on the data engine query is 
"PyQT_PyObject"?  

Second, how could I cobble together a quick script to grab from that 
dataengine to be able to test the data coming out of there?

Third, is there a way to make the dataengine grab the data automatically? 
Right now, when I use the Plasma Engine Explorer and type 25, 50, or 75, it 
grabs the data.  But this process takes a long time 5+ minutes or more.  So 
I'd like it to happen when the plasmoid starts, I guess.  And I'd want it to 
update all of them.  So info on how to do that would be great as well.

Thanks in advance for the help.


-- 
Eric Mesa

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20110813/2ed4c871/attachment.sig>


More information about the Plasma-devel mailing list