Python - Refresh Bild download

  • Hi Zusammen,


    ich habe mich gerade an das Tutorial von "Ihad" gemacht... Echt super !!! :thumbs_up:


    Ich habe allerdings eine Frage...


    Wie kann ich den eine aktialisierung des Bildes erreichen... in meinem
    Fall möchte ich eine WebCam alle x Sekunden anfragen...




    Habe schon an einigen stellen eine Schleife probiert.. leider ohne
    erfolgt


    # x=1


    # while x <=10:


    # x = x + 1


    # time.sleep(2)




    Gibt es eine Refresh Funktion?




    ############################################################################


    from Screens.Screen import Screen


    from Components.Label import Label


    from Components.Pixmap import Pixmap


    from Components.AVSwitch import AVSwitch


    from Components.ActionMap import ActionMap


    from enigma import ePicLoad




    import time


    from twisted.web.client import downloadPage


    from Screens.MessageBox import MessageBox


    from Plugins.Plugin import PluginDescriptor




    ###########################################################################


    class PictureScreen(Screen):




    skin="""


    <screen name="PictureScreen" position="50,150" size="720,576"
    title="Titel - Picture Screen" backgroundColor="#002C2C39">


    <widget name="myPic" position="0,0" size="720,600"
    zPosition="1" alphatest="on" />


    </screen>"""




    def __init__(self, session, picPath = None):


    Screen.__init__(self, session)


    print "[PictureScreen] __init__\n"


    self.picPath = picPath


    self.Scale = AVSwitch().getFramebufferScale()


    self.PicLoad = ePicLoad()


    self["myPic"] = Pixmap()


    self["myActionMap"] = ActionMap(["SetupActions"],


    {


    "ok": self.cancel,


    "cancel": self.cancel


    }, -1)




    self.PicLoad.PictureData.get().append(self.DecodePicture)


    self.onLayoutFinish.append(self.ShowPicture)




    def ShowPicture(self):


    if self.picPath is not None:


    self.PicLoad.setPara([


    self["myPic"].instance.size().width(),


    self["myPic"].instance.size().height(),


    self.Scale[0],


    self.Scale[1],


    0,


    1,


    "#002C2C39"])




    self.PicLoad.startDecode(self.picPath)




    def DecodePicture(self, PicInfo = ""):


    if self.picPath is not None:


    ptr = self.PicLoad.getData()


    self["myPic"].instance.setPixmap(ptr)






    def cancel(self):


    print "[PictureScreen] - cancel\n"


    self.close(None)




    ###########################################################################




    class getPicfromUrl(object):


    def __init__(self, session, url=None, path=None):


    self.path = path


    self.session = session


    self.download(url, path)




    def download(self, url, path):


    downloadPage(url,
    path).addCallback(self.downloadDone).addErrback(self.downloadError)




    def downloadError(self, raw):


    print "[e2Fetcher.fetchPage]: download Error", raw


    self.session.open(MessageBox, text = _("Error downloading: ") +
    self.path, type = MessageBox.TYPE_ERROR)




    def downloadDone(self,raw):


    print "[e2Fetcher.fetchPage]: download done", raw


    self.session.open(PictureScreen, picPath = self.path)




    ###########################################################################




    def main(session, **kwargs):




    getPicfromUrl(session,"Link zu CAM",
    "/tmp/myPic.tmp")






    ###########################################################################




    def Plugins(**kwargs):


    return PluginDescriptor(


    name="08 Download a picture",


    description="lesson 8 - Ihad.tv e2-tutorial",


    where = PluginDescriptor.WHERE_PLUGINMENU,


    icon="../ihad_tut.png",


    fnc=main)

  • Funktion zum Setzen des neuen Bildes mittels eTimer in bestimmten Intervallen aufrufen.


    Code-Tags machen den Code besser lesbar.

    Gruss
    Dre


    Boxen (im Einsatz): DM920, DM900, DMOne
    Developer Project Merlin - we are OpenSource

  • Muss ich vorher ncht das aktuelle Bild neu holen?


    "getPicfromUrl" holt das Bild
    " PictureScreen" gibt es dann aus


    Wo muss ich den jetzt die schleife ansetzten?

  • nix Schleife , so wie dre sagt, eTimer... so in etwa alle 1s : Such dir was raus, habe es auch nur schnell rauskopiert ohne Garantie auf Vollständig-/Richtigkeit.


  • und der Download sollte innerhalb der class PictureScreen erfolgen. Sonst rufst du mit jedem neuen Bild den PictureScreen wieder auf.

    Gruss
    Dre


    Boxen (im Einsatz): DM920, DM900, DMOne
    Developer Project Merlin - we are OpenSource

  • Hi Zusammen,
    wie bekomme ich den einen screen gestartet nach dem Boot?
    Eine Benachrichtigung geht, aber kein Screen?!?!
    Wie rufe ich den hier die screen - class auf?


    def f_autostart(reason, **kwargs):
    Notifications.AddNotification(MessageBox, _("Test TEXT Meldnug"), type=MessageBox.TYPE_INFO)


    def Plugins(**kwargs):
    return [
    PluginDescriptor(name="A - Sascha - 0 - PopUp", description=_("Sascha01"), where = [PluginDescriptor.WHERE_PLUGINMENU], fnc=f_menu),
    PluginDescriptor(name="A - Sascha - 0 - PopUp", description=_("Sascha01"), where = [PluginDescriptor.WHERE_AUTOSTART] , fnc=f_autostart)
    ]

    Einmal editiert, zuletzt von Maverick00 ()