示例#1
0
def main():
    D.P("Program started")
    relayCommand.closeAll()
    setButtons()

    alarm = Alarm()
    myInterface = Interface(buttons, alarm)
    myInterface.start()

    relayCommand.close()
    D.P("Main ended")
示例#2
0
 def addButtons(self):
     D.P("Adding buttons to interface")
     for i in self.buttons:
         but = Button(self.win,
                      text=i.name,
                      font=self.myFont,
                      command=i.command,
                      bg=i.color,
                      activebackground=i.color)
         i.addReferences(self.win, but, self.alarm)
         self.blinkers.append(i.blinker)
         but.pack()
         but.place(x=i.x_poz, y=i.y_poz, height=i.height, width=i.width)
示例#3
0
def run():
	D.P("Draw rutine running")
	global win
	global status
	global buttons
	global alarm
	for i in buttons:
		i.run(status)
	if status == 1:
		status = 0
	else:
		status = 1
	alarm.run(status)
	win.after(TIME, run)
示例#4
0
 def __init__(self, buttons, alarm):
     D.P("Creating interface")
     self.win = Tk()
     self.myFont = tkFont.Font(family='Helvetica', size=10, weight='bold')
     self.win.title("First GUI")
     self.win.attributes('-fullscreen', True)
     #self.win.geometry('800x400')
     self.blinkers = []
     self.buttons = buttons
     self.alarm = alarm
     self.alarm.draw(self.win, self.myFont)
     self.addButtons()
     self.addDefaultButtons()
     self.addClock()
     Synchronizer.init(self.win, self.blinkers, alarm.blinker)
示例#5
0
def setButtons():

    D.P("Setting buttons")
    buttons.append(
        WinButton(id=5,
                  relayId=0,
                  name="DORMITOR 1",
                  width=120,
                  height=120,
                  x_poz=127,
                  y_poz=355,
                  color="green"))
    buttons.append(
        WinButton(id=6,
                  relayId=1,
                  name="DORMITOR 2",
                  width=120,
                  height=120,
                  x_poz=5,
                  y_poz=355,
                  color="green"))
    buttons.append(
        WinButton(id=12,
                  relayId=2,
                  name="BAIE 1",
                  width=80,
                  height=60,
                  x_poz=5,
                  y_poz=290,
                  color="green"))
    buttons.append(
        WinButton(id=13,
                  relayId=3,
                  name="BAIE D.3",
                  width=80,
                  height=60,
                  x_poz=5,
                  y_poz=225,
                  color="green"))
    buttons.append(
        WinButton(id=16,
                  relayId=3,
                  name="DORMITOR 3",
                  width=120,
                  height=90,
                  x_poz=5,
                  y_poz=135,
                  color="green"))
    buttons.append(
        WinButton(id=17,
                  relayId=4,
                  name="DORMITOR 4",
                  width=120,
                  height=120,
                  x_poz=127,
                  y_poz=60,
                  color="green"))
    buttons.append(
        WinButton(id=18,
                  relayId=5,
                  name="DORMITOR 5",
                  width=120,
                  height=120,
                  x_poz=248,
                  y_poz=60,
                  color="green"))
    buttons.append(
        WinButton(id=19,
                  relayId=6,
                  name="BAIE 2",
                  width=70,
                  height=70,
                  x_poz=150,
                  y_poz=220,
                  color="green"))
    buttons.append(
        WinButton(id=20,
                  relayId=7,
                  name="BAIE 3",
                  width=60,
                  height=80,
                  x_poz=370,
                  y_poz=100,
                  color="green"))
    buttons.append(
        WinButton(id=21,
                  relayId=8,
                  name="DORMITOR 6",
                  width=120,
                  height=120,
                  x_poz=432,
                  y_poz=60,
                  color="green"))
    buttons.append(
        WinButton(id=22,
                  relayId=9,
                  name="DORMITOR 7",
                  width=120,
                  height=120,
                  x_poz=553,
                  y_poz=60,
                  color="green"))
    buttons.append(
        WinButton(id=23,
                  relayId=10,
                  name="DORMITOR 8",
                  width=120,
                  height=90,
                  x_poz=675,
                  y_poz=135,
                  color="green"))
    buttons.append(
        WinButton(id=24,
                  relayId=10,
                  name="BAIE D.8",
                  width=80,
                  height=60,
                  x_poz=715,
                  y_poz=225,
                  color="green"))
    buttons.append(
        WinButton(id=25,
                  relayId=11,
                  name="BAIE 4",
                  width=80,
                  height=60,
                  x_poz=715,
                  y_poz=290,
                  color="green"))
    buttons.append(
        WinButton(id=26,
                  relayId=12,
                  name="DORMITOR 9",
                  width=120,
                  height=120,
                  x_poz=675,
                  y_poz=355,
                  color="green"))
    buttons.append(
        WinButton(id=27,
                  relayId=13,
                  name="DORMITOR 10",
                  width=120,
                  height=120,
                  x_poz=553,
                  y_poz=355,
                  color="green"))
    buttons.append(
        WinButton(id=28,
                  relayId=14,
                  name="BAIE 5",
                  width=70,
                  height=70,
                  x_poz=580,
                  y_poz=220,
                  color="green"))
示例#6
0
 def start(self):
     D.P("Starting win loop")
     self.win.mainloop()
示例#7
0
 def __del__(self):
     D.P("Deleting Interface")
     self.win.quit()
示例#8
0
def close():
    closeAll()
    D.P("Closing serial port")
    serPort.close()
示例#9
0
def closeAll():
    for id in range(0, 16):
        D.P("Closing relay " + str(id))
        unsetRelay(id)
示例#10
0
def unsetRelay(id):
    D.P("Setting relay " + str(id) + " OFF")
    msg = "relay off " + getId(id) + "\n\r"
    serPort.write(msg)
    D.P("Serial sent: " + msg)
示例#11
0
 def addEvent(self):
     D.P("Setting callback for button " + str(self.buttonID))
     GPIO.add_event_detect(self.buttonID,
                           GPIO.RISING,
                           callback=self.activateSwitch)
示例#12
0
 def activateSwitch(self, pinReaded):
     D.P("Button" + str(self.buttonID) + " activated")
     self.activationCallback()