1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
from Tkinter import *
import time
###############################################################################
# Global Variables #
###############################################################################
APP = Tk()
GREEN2PI = 20
PX = APP.winfo_screenwidth()
PY = APP.winfo_screenheight()
TIMECYCLE = 20 * 60
TIMENOW = time.time()
TIMELEFT = TIMECYCLE
###############################################################################
# Initialization #
###############################################################################
APP.title("Raspberry")
###############################################################################
# Methods #
###############################################################################
class Interface(Frame):
#Fenetre principale d'affichage
def __init__(self, parent):
Frame.__init__(self, parent, width = PX, height = PY)
self.parent = parent
self.initUI()
def initUI(self):
#Splits the Frame into two smaller frame and initialize them
tab = Frame(self, width=PX, height=30)
rpi = Frame(self, width=PX, height=PY-30)
self.createTab(tab)
self.windowRpi(rpi, 28)
tab.pack(side=TOP)
tab.pack(side=BOTTOM)
def windowRpi(self, rpi, temp):
#Initialize a window for Rpi
frameTemp = Frame(rpi, width = PX/2, height = PY-30, borderwidth = 10)
frameTime = Frame(rpi, width = PX/2, height = PY-30, borderwidth = 10)
minutes = str(int(TIMELEFT / 60))
sec = str(TIMELEFT%60)
strTemp = "Temperature : " + str(temp) + " degres."
strTime = "Temps restant : " + minutes + " minutes " + sec + " secondes."
labelTemp = Label(frameTemp, text = strTemp)
labelTime = Label(frameTime, text = strTime)
labelTime.grid(row = 2)
labelTemp.grid(row = 1)
frameTime.grid()
frameTemp.grid()
def createTab(self, tab):
#Initialize tab containing all Rpi
#space to adjust for screen
space = PX/13/GREEN2PI * " "
#Create a button for each Rpi
for i in range(GREEN2PI):
buttonRpi = Button(tab, text = space + str(i) +space)
buttonRpi.grid(column=i, row=0)
def main():
interface = Interface(APP)
APP.mainloop()
if __name__ == "__main__":
main() |
Partager