From kde-panel-devel Tue Jun 26 09:36:06 2012 From: Shantanu Tushar Jha Date: Tue, 26 Jun 2012 09:36:06 +0000 To: kde-panel-devel Subject: Re: fixing little issues on my QML/Python program Message-Id: X-MARC-Message: https://marc.info/?l=kde-panel-devel&m=134070286905795 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============8439240439927616355==" --===============8439240439927616355== Content-Type: multipart/alternative; boundary=f46d04428d9cffe06e04c35ca81c --f46d04428d9cffe06e04c35ca81c Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jun 26, 2012 at 2:46 PM, Viranch Mehta wrote: > On Tue, Jun 26, 2012 at 8:31 AM, Eric Mesa wrote: > >> Thanks to everyone who's helped me over the last year or so with my >> program. I have one more thing to fix on my engine and then it will be >> "perfect". The recent help I got helped me finally perfect the GUI. So my >> data engine's running a function over and over with different arguments to >> populate the sources. Here's what it looks like: >> > > Please always use pastebin.com or paste.kde.org to show your codes instead > of putting them in emails. > I think its ok to paste in a mail if its a snippet not too long, because it helps other people who will later read the ML archives, as pastebins may expire. > > Viranch > > >> >> 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() >> >> #adding this back in 24 jan to see if it helps >> def sources(self): >> sources = ["25", "50", "75", "100", "200", "300", "400", "500", >> "600", "700", "800", "900", "1000", "1250", "1500", "1750", "2000","3000", >> "4000", "5000", "10000"] >> return sources >> >> def sourceRequestEvent(self, name): >> #print "source request event" #debugging >> return self.updateSourceEvent(name) >> >> def updateSourceEvent(self,group): >> print "updateSourceEvent" >> #grouplist = [] >> if group == "25": >> grouplist = views.analyzeviews(views.views25, views.views50) >> self.setData("25", "Group 25", grouplist) >> elif group == "50": >> grouplist = views.analyzeviews(views.views50, views.views75) >> self.setData("50","Group 50", grouplist) >> elif group == "75": >> grouplist = views.analyzeviews(views.views75,views.views100) >> self.setData("75","Group 75", grouplist) >> elif group == "100": >> print "i'm @ 100" #debug >> grouplist = views.analyzeviews(views.views100,views.views200) >> self.setData("100","Group 100", grouplist) >> elif group == "200": >> print "i'm @ 200" #debug >> grouplist = views.analyzeviews(views.views200, views.views300) >> self.setData("200","Group 200", grouplist) >> *... (cut a snippet out - I think you get the point)* >> elif group == "10000": >> print "i'm @ 10000" #debug >> grouplist = views.analyzeviews(views.views10000, views.views10000) >> self.setData("10000","Group 10000", grouplist) >> return True >> >> def CreateDataEngine(parent): >> return PyFlickrEngine(parent) >> >> So that function it's calling, views.analyzeviews(arg, arg) is calling a >> web API and sometimes that API fails. The cool thing about data engines vs >> when I used to do this on the commandline is that if it fails at 25, it >> doesn't crash the whole program. It just moves on to 50. So I can end up >> in the end where when I click on 25 it tells me that there's nothing in the >> source and then I click on 50 and I can use the data from that source. So, >> right now if I want the data from 25, the only way I know how to do that is >> by re-running the program and hoping the API doesn't fail that time >> around. Is there a way for me to tell the data engine to update group 25 >> again from within the QML gui? >> >> Thanks! >> -- >> Eric Mesa >> http://about.me/ericmesa >> http://www.ericsbinaryworld.com >> >> >> _______________________________________________ >> Plasma-devel mailing list >> Plasma-devel@kde.org >> https://mail.kde.org/mailman/listinfo/plasma-devel >> >> > > _______________________________________________ > Plasma-devel mailing list > Plasma-devel@kde.org > https://mail.kde.org/mailman/listinfo/plasma-devel > > -- Shantanu Tushar (UTC +0530) http://www.shantanutushar.com --f46d04428d9cffe06e04c35ca81c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Tue, Jun 26, 2012 at 2:46 PM, Viranch Meh= ta <viranch.mehta@gmail.com> wrote:
On Tue, Jun 26, 2012 at 8:31 AM, Eric Mesa <eri= csbinaryworld@gmail.com> wrote:
Thanks to everyone who's helped me over the last year or so with my pro= gram.=A0 I have one more thing to fix on my engine and then it will be &quo= t;perfect".=A0 The recent help I got helped me finally perfect the GUI= .=A0 So my data engine's running a function over and over with differen= t arguments to populate the sources.=A0 Here's what it looks like:

Please always use pastebin.com or paste.kde.org to show your codes instead
of putting them in emails.

I think it= s ok to paste in a mail if its a snippet not too long, because it helps other people who will later read the ML archives, as pastebins may expire.
=A0

Viranch
=A0

from PyQt4.QtCore import *
from PyKDE4.kdecore import *
from PyKD= E4 import plasmascript
#for flickr
import views


class PyFl= ickrEngine(plasmascript.DataEngine):
=A0 def __init__(self,parent,args= =3DNone):
=A0=A0=A0 plasmascript.DataEngine.__init__(self,parent)
=A0=A0=A0
= =A0 def init(self):
=A0=A0=A0 self.setMinimumPollingInterval(333)
=A0= =A0=A0 #for flickr
=A0=A0=A0 views.initialize()
=A0
=A0 #adding t= his back in 24 jan to see if it helps
=A0 def sources(self):
=A0=A0=A0 sources =3D ["25", "50&q= uot;, "75", "100", "200", "300", &q= uot;400", "500", "600", "700", "800= ", "900", "1000", "1250", "1500&quo= t;, "1750", "2000","3000", "4000", = "5000", "10000"]
=A0=A0=A0 return sources
=A0=A0=A0
=A0 def sourceRequestEvent(self, = name):
=A0=A0=A0 #print "source request event" #debugging
= =A0=A0=A0 return self.updateSourceEvent(name)
=A0=A0=A0
=A0 def upda= teSourceEvent(self,group):
=A0=A0=A0 print "updateSourceEvent"
=A0=A0=A0 #grouplist =3D []
=A0=A0=A0 if group =3D=3D "25":=A0=A0=A0=A0=A0 grouplist =3D views.analyzeviews(views.views25, views.view= s50)
=A0=A0=A0=A0=A0 self.setData("25", "Group 25", = grouplist)
=A0=A0=A0 elif group =3D=3D "50":
=A0=A0=A0=A0=A0 grouplist =3D views.analyzeviews(views.views50, views.views= 75)
=A0=A0=A0=A0=A0 self.setData("50","Group 50", gr= ouplist)
=A0=A0=A0 elif group =3D=3D "75":
=A0=A0=A0=A0=A0 = grouplist =3D views.analyzeviews(views.views75,views.views100)
=A0=A0=A0=A0=A0 self.setData("75","Group 75", grouplist= )
=A0=A0=A0 elif group =3D=3D "100":
=A0=A0=A0=A0=A0 print = "i'm @ 100" #debug
=A0=A0=A0=A0=A0 grouplist =3D views.ana= lyzeviews(views.views100,views.views200)
=A0=A0=A0=A0=A0 self.setData("100","Group 100", groupli= st)
=A0=A0=A0 elif group =3D=3D "200":
=A0=A0=A0=A0=A0 prin= t "i'm @ 200" #debug
=A0=A0=A0=A0=A0 grouplist =3D views.a= nalyzeviews(views.views200, views.views300)
=A0=A0=A0=A0=A0 self.setData("200","Group 200", groupli= st)
... (cut a snippet out - I think you get the point)
=A0=A0= =A0 elif group =3D=3D "10000":
=A0=A0=A0=A0=A0 print "i&#= 39;m @ 10000" #debug
=A0=A0=A0=A0=A0 grouplist =3D views.analyzeviews(views.views10000, views.vi= ews10000)
=A0=A0=A0=A0=A0 self.setData("10000","Group 100= 00", grouplist)
=A0=A0=A0 return True
=A0=A0=A0
def CreateDa= taEngine(parent):
=A0 return PyFlickrEngine(parent)

So that function it's calling, views.analyzeviews(arg, arg) is call= ing a web API and sometimes that API fails.=A0 The cool thing about data en= gines vs when I used to do this on the commandline is that if it fails at 2= 5, it doesn't crash the whole program.=A0 It just moves on to 50.=A0 So= I can end up in the end where when I click on 25 it tells me that there= 9;s nothing in the source and then I click on 50 and I can use the data fro= m that source.=A0 So, right now if I want the data from 25, the only way I = know how to do that is by re-running the program and hoping the API doesn&#= 39;t fail that time around.=A0 Is there a way for me to tell the data engin= e to update group 25 again from within the QML gui?

Thanks!
--
Eric Mesa

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.= org
https://mail.kde.org/mailman/listinfo/plasma-devel



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel




--
Shantanu Tushar=A0 = =A0 (UTC +0530)
http://www.shantanutushar.com
--f46d04428d9cffe06e04c35ca81c-- --===============8439240439927616355== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel --===============8439240439927616355==--