Hi Zusammen,
ich habe mich gerade an das Tutorial von "Ihad" gemacht... Echt super !!!
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)