# -*- coding: utf-8 -*- ####################################################################### # # vCal Calendar for Enigma-2 # Vesion 0.1 # Coded by Vali (c)2010 # Support: www.dreambox-tools.info # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # ####################################################################### from Screens.Screen import Screen from Plugins.Plugin import PluginDescriptor from Components.ActionMap import ActionMap from Components.Label import Label from calendar import month from time import localtime, strftime def Plugins(**kwargs): return [PluginDescriptor(name=_("Календарь"), description=_("Show the 'Calendar' on the screen"), where=PluginDescriptor.WHERE_PLUGINMENU, icon = 'plugin.png', fnc=main)] def main(session, **kwargs): session.open(vCalendar) class vCalendar(Screen): skin = """ <screen name="vCalendar" position="center,center" size="321,367" title="vCalendar"> <widget name="stroke1234" font="Regular;20" foregroundColor="#ffffff" position="0,0" size="321,78" halign="center"/> <widget name="stroke5" font="Regular;20" foregroundColor="#ffffff" position="0,78" size="321,26" halign="center" zPosition="1"/> <widget name="stroke6" font="Regular;20" foregroundColor="#ffffff" position="0,104" size="321,26" zPosition="1"/> <widget name="display" font="Console;26" position="0,79" size="321,237" transparent="1"/> <eLabel font="Regular;20" foregroundColor="#ff4A3C" position="0,342" size="120,25" text="Месяц -"/> <eLabel font="Regular;20" foregroundColor="#56C856" position="245,342" size="120,25" text="Месяц +"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session self["stroke1234"] = Label (_ ( (str(strftime("%d.%m.%Y"))) + "\n" + (str(strftime("%A"))) + "\n" + "\n" ) ) self["stroke5"] = Label (_ ( "..." ) ) self['stroke6'] = Label (_ ( "Пнд Втр Срд Чтв Птн Сбт Вск" ) ) self["display"] = Label (_ ( "..." ) ) self.year=localtime()[0] self.calJahr=self.year self.month=localtime()[1] self.calMonat=self.month self.myTag=localtime()[2] self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "red": self.preview, "green": self.next, "cancel": self.ExitCal }, -1) self.onLayoutFinish.append(self.fillLabels) def fillLabels(self): self["stroke5"].setText( (str(month(self.year,self.month))) ) jetzt = (month(self.year,self.month)) self["display"].setText(jetzt) def ExitCal(self): self.close() def preview(self): if self.calMonat>1: self.calMonat-=1 else: self.calMonat=12 self.calJahr-=1 self["stroke5"].setText( (str(month(self.calJahr,self.calMonat))) ) wann = (month(self.calJahr,self.calMonat)) self["display"].setText(wann) def next(self): if self.calMonat<12: self.calMonat+=1 else: self.calMonat=1 self.calJahr+=1 self["stroke5"].setText( (str(month(self.calJahr,self.calMonat))) ) wann = (month(self.calJahr,self.calMonat)) self["display"].setText(wann) |