def exit(): root.destroy() isec.hw_close()
root = Tk() root.title('Light Control System') root.geometry('1100x500') isec.hw_init() isec.simulate_hardware = True #Turns on simulation software. isec.sensor_value_from_user = False #Allows user to enter sensor data. HI1 = Lights(1, root) HI2 = Lights(2, root) HI3 = Lights(3, root) HI4 = Lights(4, root) HI5 = Lights(5, root) OBJECTS = [HI1, HI2, HI3, HI4, HI5] thread.start_new(HI1.statecycle2, ()) thread.start_new(HI2.statecycle2, ()) thread.start_new(HI3.statecycle2, ()) thread.start_new(HI4.statecycle2, ()) thread.start_new(HI5.statecycle2, ()) Button(text=('Auto On/Off'), command=Startauto).grid(row=1, column=3) Button(text=('Exit'), width='10', command=exit, bg='red', font=('helvetica', 15, 'underline italic')).grid(row=3, column=3) Button(text=('Stop Signs'), command=signs).grid(row=2, column=3) autovar = StringVar() autodisplay = Label(root, textvariable=autovar, fg='White', bg='black').grid(row=1, column=4) autovar.set('Auto is OFF') root.mainloop() isec.hw_close()
def statecycle(self): self.cs = STATE [self.cs] [1] [1] self.chlt() self.chcv() #isec.hw_init(simulate_hardware = False, use_one_intersection = False) # Initializes the software. root = Tk() root.title ('Light Control System') root.geometry ('750x700') isec.hw_init() isec.simulate_hardware = True #Turns on simulation software. isec.sensor_value_from_user = False #Allows user to enter sensor data. HI1 = Lights(root,3,3,1) HI2 = Lights(root,1,3,2) HI3 = Lights(root,3,5,3) HI4 = Lights(root,5,3,4) HI5 = Lights(root,3,1,5) OBJECTS = [HI1,HI2,HI3,HI4,HI5] thread.start_new(HI1.statecycle2, ()) thread.start_new(HI2.statecycle2, ()) thread.start_new(HI3.statecycle2, ()) thread.start_new(HI4.statecycle2, ()) thread.start_new(HI5.statecycle2, ()) Button(text = ('Auto On/Off'), command = Startauto).grid(row = 6, column=3) Button(text = ('Exit'), width = '10', command = exit, bg = 'red',font=('helvetica', 15, 'underline italic')).grid(row = 7, column=3) autovar = StringVar() autodisplay = Label(root, textvariable= autovar, fg = 'White', bg = 'black').grid(row=6,column=5) autovar.set('Auto is OFF') root.mainloop() isec.hw_close()