# -*- 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, TextCalendar, month_name 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 myTextCalendar(TextCalendar): def formatmonthname(self, theyear, themonth, width, withyear=True): s = month_name[themonth] if withyear: s = "%s %r" % (s, theyear) return s class vCalendar(Screen): skin = """ <screen name="vCalendar" position="center,center" size="241,346" title="vCalendar"> <widget name="display" font="Console;20" position="0,110" size="241,183"/> <eLabel font="Regular;20" foregroundColor="#ff4A3C" position="0,321" size="120,25" text="Месяц -"/> <eLabel font="Regular;20" foregroundColor="#56C856" position="165,321" size="120,25" text="Месяц +"/> </screen>""" def __init__(self, session): self.myCal = myTextCalendar() Screen.__init__(self, session) self.session = session #self["stroke12345"] = 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["stroke12345"].setText((str(strftime("\n%d.%m.%Y\n%A\n\n")))+str(month(self.year,self.month))) jetzt = (self.myCal.formatmonth(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["stroke12345"].setText((str(strftime("\n%d.%m.%Y\n%A\n\n")))+str(self.myCal.formatmonth(self.calJahr, self.calMonat))) wann = (self.myCal.formatmonth(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["stroke12345"].setText((str(strftime("\n%d.%m.%Y\n%A\n\n")))+str(self.myCal.formatmonth(self.calJahr, self.calMonat))) wann = (self.myCal.formatmonth(self.calJahr, self.calMonat)) self["display"].setText(wann) |