Your help would be very very apreciated.
My Current Code:
# -*- coding: utf-8 -*-
import time
from threading import Thread
from Components.ActionMap import ActionMap
from Components.config import config, ConfigInteger, ConfigSubsection, ConfigYesNo
from Components.MenuList import MenuList
from Plugins.Plugin import PluginDescriptor
from Screens.Screen import Screen
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
from twisted.web.client import downloadPage
from Screens.MessageBox import MessageBox
config.plugins.Satat = ConfigSubsection()
config.plugins.Satat.enabled = ConfigYesNo(default=True)
config.plugins.Satat.position_x = ConfigInteger(default=590)
config.plugins.Satat.position_y = ConfigInteger(default=590)
##############################################################################
SKIN = """
<screen position="0,0" size="300,300" zPosition="10" backgroundColor="#ff000000"
title="My Sat" flags="wfNoBorder">
<widget name="myPic" position="20,40" size="100,100" zPosition="1" />
</screen>
"""
##############################################################################
class SatatScreen(Screen):
def __init__(self, session, picPath = None):
picPath = "http://www.i-have-a-dreambox.com/images/ihad.jpg"
Screen.__init__(self, session)
self.skin = SKIN
self.session = session
downloaded_image = getPicfromUrl(session, picPath, "/tmp/myPic.tmp")
picPath = downloaded_image.path
self.picPath = picPath
self.Scale = AVSwitch().getFramebufferScale()
self.PicLoad = ePicLoad()
self["myPic"] = Pixmap()
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 editMyImage(self, path):
downloaded_image = getPicfromUrl(self.session, path, "/tmp/myPic.tmp")
picPath = downloaded_image.path
self.picPath = picPath
self.PicLoad.PictureData.get().append(self.DecodePicture)
##############################################################################
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
def downloadDone(self,raw):
print "[e2Fetcher.fetchPage]: download done", raw
##############################################################################
def print_sat(my_sat):
global COUNTER
while not my_sat.stop:
my_sat.dialog.show()
time.sleep(5)
my_sat.dialog.hide()
time.sleep(1)
my_sat.dialog.editMyImage("http://www.python-course.eu/images/arrow.png")
class Satat:
def __init__(self):
self.dialog = None
self.stop = False
def got_session(self, session):
self.dialog = session.instantiateDialog(SatatScreen)
self.show_hide()
def change_visibility(self):
if config.plugins.Satat.enabled.value:
config.plugins.Satat.enabled.value = False
else:
config.plugins.Satat.enabled.value = True
config.plugins.Satat.enabled.save()
self.show_hide()
def show_hide(self):
if config.plugins.Satat.enabled.value:
self.stop = False
sat_thread = Thread(target=print_sat, args=(self,))
sat_thread.start()
else:
self.stop = True
self.dialog.hide()
satat = Satat()
##############################################################################
class SatatMenu(Screen):
skin = """
<screen position="center,center" size="420,105" title="Satat">
<widget name="list" position="10,10" size="400,85" />
</screen>
"""
def __init__(self, session):
Screen.__init__(self, session)
self.session = session
self["list"] = MenuList([])
self["actions"] = ActionMap(["OkCancelActions"], {"ok": self.ok_clicked, "cancel": self.close}, -1)
self.onLayoutFinish.append(self.show_menu)
def show_menu(self):
my_list = []
if config.plugins.Satat.enabled.value:
my_list.append("Deactivate Satat")
else:
my_list.append("Activate Satat")
self["list"].setList(my_list)
def ok_clicked(self):
sel = self["list"].getCurrent()
if Satat.dialog is None:
Satat.got_session(self.session)
if sel == "Deactivate Satat" or sel == "Activate Satat":
satat.change_visibility()
self.show_menu()
##############################################################################
def session_start(reason, **kwargs):
if reason == 0:
satat.got_session(kwargs["session"])
def start_config(session, **kwargs):
session.open(SatatMenu)
def main(menu_id):
if menu_id != "system":
return []
return [("Sat", start_config, "sat", None)]
##############################################################################
def Plugins(**kwargs):
return [
PluginDescriptor(
where=[PluginDescriptor.WHERE_SESSIONSTART],
fnc=session_start
),
PluginDescriptor(
name="Sat",
description="Sat screen",
where=PluginDescriptor.WHERE_MENU,
fnc=main
),
]