Jump to content


Photo

hide spinner during plugin execution


  • Please log in to reply
1 reply to this topic

#1 keratos

  • Senior Member
  • 30 posts

0
Neutral

Posted 25 August 2017 - 08:55

from Screens.Screen import Screen
from Components.Label import Label
from Components.ProgressBar import ProgressBar
from Components.ActionMap import ActionMap
from Tools.Downloader import downloadWithProgress


class MyMetrixUpdater(Screen):
skin = """
   <screen position="center,center" size="840,160" flags="wfNoBorder" backgroundColor="background">
   <widget name="status" position="20,10" size="800,70" transparent="1" font="RegularLight;46" foregroundColor="foreground" backgroundColor="background" valign="center" halign="left" noWrap="1" />
   <widget name="progress" position="0,88" size="840,6" transparent="1" borderWidth="0" />
   <widget name="key_red" position="20,100" size="10,60" backgroundColor="red" />
   <widget name="key_green" position="20,100" size="10,60" backgroundColor="green" />
   </screen>
   """

def __init__(self, session):
   Screen.__init__(self, session)
   self["key_red"] = Label()
   self["key_red"].hide()
   self["key_green"] = Label()
   self["actions"] = ActionMap(["OkCancelActions","ColorActions"],
{
"ok": self.ok,
"cancel": self.exit,
"green": self.startUpdate,
"red": self.stopUpdate
}, -1)


self["key"] = Label(_("Start update"))
self["status"] = Label(_("Press green to start update!"))
self["progress"] = ProgressBar()
self["progress"].hide()


def ok(self):
self.close()


def exit(self):
self.close()


def startUpdate(self):
self["key"].setText(_("Abort"))
self["key_red"].show()
self["key_green"].hide()
self["status"].setText(_("Download files..."))
localurl = '/tmp/enigma2-plugin-skins-pvmc-skin_1.0_all.ipk'
sourceurl = 'http://metrixfullhd.w1.ms5.eu/dl-counter/download/enigma2-plugin-skins-pvmc-skin_1.0_all.ipk'
self.download = downloadWithProgress(sourceurl,localurl)
self.download.addProgress(self.downloadProgress)
self.download.start().addCallback(self.downloadFinished).addErrback(self.downloadFailed)


def stopUpdate(self):
self["status"].setText(_("Update is aborting..."))


def downloadFinished(self, string=""):
self["status"].setText(_("Download successfully!"))


def downloadFailed(self, failure_instance=None, error_message=""):
text = _("Error downloading files!")
if error_message == "" and failure_instance is not None:
error_message = failure_instance.getErrorMessage()
text += ": " + error_message
self["status"].setText(text)


def downloadProgress(self, recvbytes, totalbytes):
progress = int(100 * recvbytes / float(totalbytes))
self["progress"].setValue(int(progress))
self["progress"].show()

 



Re: hide spinner during plugin execution #2 littlesat

  • PLi® Core member
  • 57,212 posts

+700
Excellent

Posted 25 August 2017 - 09:17

Look what I did in FlashImage.py (on develop branch)


WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users