Fix crash when closing setup screen with prevously inactive KiddyTimer
[enigma2-plugins.git] / kiddytimer / src / KTglob.py
1 from __init__ import _
2 import time
3
4 PLUGIN_BASE = "KiddyTimer"
5 PLUGIN_VERSION = "0.8b"
6
7 DAYNAMES= (_("Sunday"),
8           _("Monday"),
9           _("Tuesday"),
10           _("Wednesday"),
11           _("Thursday"),
12           _("Friday"),
13           _("Saturday"),
14           )
15
16 ONEHOUR=3600
17 ONEMINUTE=60
18
19 MOVEPOSITIONSTEP = 10
20
21
22 #This is a hack to get the times in the current timezone to feed as default value for the ConfigClock
23 ONEOCLOCK=time.mktime([2000,1,1,1,0,0,5,1,time.timezone])
24 EIGHTOCLOCK=time.mktime([2000,1,1,8,0,0,5,1,time.timezone])
25 EIGHTOCLOCKNOON=time.mktime([2000,1,1,20,0,0,5,1,time.timezone])
26
27 plugin_path = ""
28
29 ##############################################################################
30
31 SKIN = """
32     <screen flags="wfNoBorder" position="0,0" size="82,104" title="Kiddy Timer" backgroundColor="#ff000000">
33         <ePixmap pixmap="~/img/Smiley-Background.png" position="0,0" zPosition="1" size="82,82" alphatest="blend" transparent="1"/>
34         <widget name="TimerSlider" pixmap="~/img/Smiley-Slider.png" zPosition="2" position="0,0" size="82,82" transparent="1" orientation="orBottomToTop" />
35         <widget name="TimerSliderText" zPosition="3" position="0,83" size="82,21" font="Regular;18" halign="center" valign="center" foregroundColor="#000000" backgroundColor="#aaffffff" />
36         <widget name="TimerGraph" pixmaps="~/img/Timer1000.png,~/img/Timer0950.png,~/img/Timer0900.png,~/img/Timer0850.png,~/img/Timer0800.png,~/img/Timer0750.png,~/img/Timer0700.png,~/img/Timer0650.png,~/img/Timer0600.png,~/img/Timer0550.png,~/img/Timer0500.png,~/img/Timer0450.png,~/img/Timer0400.png,~/img/Timer0350.png,~/img/Timer0300.png,~/img/Timer0250.png,~/img/Timer0200.png,~/img/Timer0150.png,~/img/Timer0100.png,~/img/Timer0050.png,~/img/Timer0000.png" position="0,0" zPosition="2" size="82,82" transparent="1" alphatest="on" />
37         <widget name="TimerText" zPosition="3" position="0,30" size="82,21" font="Regular;18" halign="center" valign="center" foregroundColor="#000000" transparent = "1" />
38     </screen>"""
39
40 ##############################################################################
41
42 def getSecondsFromClock(aClock):
43     iSeconds = 60*(int(aClock[0])*60 + int(aClock[1]))
44     return iSeconds
45
46 def getTimeFromSeconds(iSecondsLeft,bReturnSeconds):
47         iHours = int( iSecondsLeft // 3600 )
48         iHourRest = iSecondsLeft - ( iHours * 3600 )
49         iMinutes = int( iHourRest // 60 )
50         if bReturnSeconds == False:
51             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] )
52         else:
53             iSeconds = int( iHourRest - ( iMinutes * 60) )
54             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] + ":" + ("00"+str(iSeconds))[-2:] )
55
56