def displayNumbers(self): screen = Tk() screen.geometry("900x125+510+50") screen.title( "These are your numbers! You need to try and get as close as possible to the number on the very right!" ) screen.resizable(False, False) pos = 0 for i in self.unchangedNumberList: Label(screen, text=i, bg="black", foreground="white", font=("Comic Sans", 12, "bold")).place(x=pos * 100, y=0, width=100, height=125) pos += 1 Label(screen, text=self.total, bg="white", foreground="red", font=("Comic Sans", 16, "bold")).place(x=600, y=0, width=300, height=125) clock = Clock.Clock() #display the clock self.numbers_screen.destroy() self.numbers_screen.after( 30000, lambda: [self.timesUp(clock), screen.destroy()])
def __init__(self): self.coord_x = -10 # x coordinate self.coord_y = -10 # y coordinate self.age = 0 # возраст куска травы self.state = Fruit.st_growing self.color = Light_green # цвет куска травы, зависит от возраста self.health = 100 # прочность травы, в общем то, требуемое время на её поедание self.saturability = 100 # насыщаемость, как сильно животное наедается куском травы self.size = 0 # коэф размера куска травы self.id = canv.create_rectangle(self.coord_x - 2 * self.size, self.coord_y + 2 * self.size, self.coord_x + 2 * self.size, self.coord_y + 2 * self.size, fill=self.color, outline="#5c1841") self.clock = Clock()
def __init__(self): Animal.__init__(self) self.color = 'red' self.notice_radius = 300 # radius where predator notices objects self.state = Predator.st_idle # basic state is wandering around self.kills = 0 self.nearest_cattle = None self.nearest_predator = None self.health = 40000 self.velocity = 50 # predator basic speed self.id = canv.create_oval(self.coord_x - self.radius, self.coord_y - self.radius, self.coord_x + self.radius, self.coord_y + self.radius, fill=self.color) self.clock = Clock()
def displaySelected(self): screen = Tk() screen.geometry("900x125+510+50") for i in range(0, 9): Label(screen, text=self.letterList[i], bg="black", foreground="white", font=("Comic Sans", 12, "bold")).place(x=i * 100, y=0, width=100, height=125) clock = Clock.Clock() #display the clock self.letters_screen.destroy() self.letters_screen.after( 30000, lambda: [self.timesUp(clock), screen.destroy()])
def main(): """Main function to get information for Bar 4. """ getter_battery = Battery.Battery() getter_clock = Clock.Clock() getter_keyboard = Keyboard.Keyboard() getter_os = Os.Os() getter_battery.show_info() sys.stdout.write(" | ") getter_clock.get_uptime() sys.stdout.write(" | ") getter_clock.get_time() sys.stdout.write(" ") getter_clock.get_date() sys.stdout.write(" | ") getter_keyboard.get_layout() getter_keyboard.show_locks() sys.stdout.write(" | ") getter_os.get_os()
def __init__(self): Animal.__init__(self) self.anxiety = 0 # represents how anxious the animal is self.state = Cattle.st_idle self.nearest_predator = None # if cattle could identify predator near it self.nearest_fruit = None # if cattle could identify predator near it self.nearest_cattle = None self.velocity = 35 # cattle basic speed self.color = 'green' self.birfability = 0 self.eaten = 0 self.count = 0 self.under_attack = False self.notice_radius = 80 # radius where cattle notices objects self.id = canv.create_oval(self.coord_x - self.radius, self.coord_y - self.radius, self.coord_x + self.radius, self.coord_y + self.radius, fill=self.color) self.clock = Clock()
print(mess) break except: print("unsuccessful, retry") sleep(5) sys.exit() debug = True wtab = wt.WeekTable() # The template for planner jnal = jn.Journal() # The Journal plan = pl.Plan() # The planner time = tm.Time() # Lazy time tracker tenw = tw.TenWeek() # The long run print('wtab, jnal, plan, time, tenw: On') tick = cl.Clock(debug) # The loop print('tick: On' + int(debug) * ' (debug mode)') while not tick.exit: # Mail receive a special treatment since it needs # to be destruct and re-construct when there is connection fault # thus it is initiate inside the scope of tick.run tick.run(ml, time, tenw, wtab, jnal, plan) if tick.update: # TODO: Run git synchorise here mess = str() while True: try: print(">> git pull") mess = puller.pull() print(mess)
instruc = CU.read_instructions('ins4.code') CU.orchestra(instruc, clock_speed[1], REM.RAM) x = input('Continue with file No. 5? (y/n)\n') if x == 'n' or x == 'N': ALU.HALT() else: pass print('\n---------- Executing file No. 5 ----------') instruc = CU.read_instructions('ins5.code') CU.orchestra(instruc, clock_speed[1], REM.RAM) print('\n ---------- End Program ---------- \n') if __name__ == "__main__": REG = Registers(4) REM = RAM(16) read = CU() clock = Clock('clock', 'i5', 'Intel') CU.turn_on(CU, 'bios.yml', 'instructions.code', REM.RAM) # Imprime los valores de la ram en decima clock_speed = (CU.read_instructions('bios.yml')) Brain() #instruc = CU.read_instructions('instructions.code') # Instruc es el arreglo de instrucciones #CU.orchestra(instruc, clock_speed[1], REM.RAM)
# Zach Taylor - CINF308 Programming for Informatics import tkinter as tk import Clock clock = Clock.Clock() # Instantiates a clock object screen = tk.Tk() # Instantiates a tkinter object screen.title("Clock") # Window title is 'Clock' screen.geometry("850x550") # Window size is 850x550 screen.configure(bg="steelblue1") # Sets window background color def increaseDay(): # Defines the increaseDay command clock.increaseDay() # Calls the increaseDay function from the Clock class label2.place( relx=.34, rely=.15) # Resets the time label because setClock changes it if error label2.config(text=clock.__str__()) # Displays clock.__str__ in label 2 def decreaseDay(): clock.decreaseDay() # Calls the decreaseDay function from the Clock class label2.place(relx=.34, rely=.15) label2.config(text=clock.__str__()) def increaseSecond(): clock.increaseSecond( ) # Calls the increaseSecond function from the Clock class label2.place(relx=.34, rely=.15) label2.config(text=clock.__str__())
print("Starting market") marketProcess.start() weatherProcess = Weather.Weather(weather, clocker, day) print("Starting weather") weatherProcess.start() houses = [ House.House(i, clocker, weather, lockHouse, houses_pipes[i][1]) for i in range(numberOfHouses) ] print("Starting every Houses") for k in houses: k.start() tickProcess = Clock.Clock(clocker) print("Starting the clock") tickProcess.start() firstTime = True #Used for the first day (the market isn't up) # For the graph dayG = [] priceG = [] communityG = [] while True: if clocker.value == 0: print("--NIGHT--")
for i in range(A.shape[0]): if isclose(B[i, i], 0): ans[i, 0] = 0.0 else: ans[i, 0] = A[i, 0] / B[i, i] return ans def K_effective(newmark, mass, stiffness): b1 = newmark.b1 K = b1 * mass + stiffness return K dt = 0.01 clock = Clock(dt, [0, 2]) newmark = Newmark(dt) assembly = Assembly(newmark) ReadData(assembly, '1FL.xlsx') neq = assembly.eq_number output_check(assembly, 'formal_1FL_check.txt') with open('formal_1FL.txt', 'w') as p: p.write('%8s %7s %12s' % ('time', 'iter', 'ux_top')) tol = 1e-4 # f = TimeSeries(0, 1, [0, 100, 100]) seismic = assembly.seismics[0] # ef = dok_matrix([[f.at(clock.current_time)/2], [0], [0], [0], [0], [0]])
# Create window and frame window = tkinter.Tk() window.configure(background='white') ## window.attributes('-fullscreen', True) mainframe = tkinter.Frame(width=1280, height=800, background="#292b5d") mainframe.pack(fill="both", expand=True, padx=20, pady=20) clock_frame = tkinter.Frame(window, width=1280, height=800) clock_frame.place(in_=mainframe, anchor="c", relx=.5, rely=.5) # Add the frame elements, including the clock like any other element # top blank line # time # bottom blank line top_blank_label = tkinter.Label(clock_frame, text=" ").pack() clock1 = clock.Clock(clock_frame) clock1.pack() clock1.configure(bg='#292b5d', fg='silver', font=("alfie", 200)) bottom_blank_label = tkinter.Label(clock_frame, text=" ").pack() # tkinter.Label(clock_frame, text="Have a nice day.",fg='white',bg='#292b5d').pack() leftcol = 1 / 12.0 midcol = 0.5 rightcol = 11 / 12.0 ## outside temperature outside_temperature = frames.Outside_Temperature(window) outside_temperature.place(in_=mainframe, anchor="w", relx=leftcol, rely=.2) ## outside_pressure outside_pressure = frames.Outside_Pressure(window)
def __init__(self): tk.Tk.__init__(self) #Settin Layout and using self because superclass is tk self.geometry("600x600") self.title("Python eindopdracht") menu = tk.Menu(self) self.config(menu=menu) # Menu with commands file_menu = tk.Menu(menu) menu.add_cascade(label="Bestand", menu=file_menu) file_menu.add_command(label="Print tekstbestand", command=lambda: display_output()) file_menu.add_command(label="Opslaan in tekstbestand", command=lambda: save_book()) file_menu.add_separator() file_menu.add_command(label="Start Server", command=lambda: start_server()) file_menu.add_command(label="Download tekstbestand", command=lambda: start_client()) file_menu.add_command(label="Totaal contacten", command=lambda: show_total()) file_menu.add_separator() file_menu.add_command(label="Afsluiten", command=lambda: exit()) heading = tk.Label(text="Telefoonboek Novi Medewerkers", bg="grey", fg="white", width="500") heading.pack() #Labels and placing first_name_label = tk.Label(text="Voornaam") last_name_label = tk.Label(text="Achternaam") street_label = tk.Label(text="Straat") postcode_label = tk.Label(text="Postcode") city_label = tk.Label(text="Woonplaats") tel_label = tk.Label(text="Telefoonnummer") first_name_label.place(x=20, y=50) last_name_label.place(x=20, y=80) street_label.place(x=20, y=110) postcode_label.place(x=20, y=140) city_label.place(x=20, y=170) tel_label.place(x=20, y=200) self.output = tk.Text(self, height=15, width=68) self.output.pack() self.output.place(x=20, y=300) #A Status bar at the bottom of the screen to show to clock using a Thread and Whili loop time_label = tk.Label(self, bd=1, relief=tk.SUNKEN, anchor=tk.W) time_label.pack(side=tk.BOTTOM, fill=tk.X) fname = tk.StringVar() lname = tk.StringVar() street = tk.StringVar() postcode = tk.StringVar() city = tk.StringVar() telnr = tk.StringVar() search = tk.StringVar() display = tk.StringVar() self.display_label = tk.Label(self, textvariable=display) fname_input = tk.Entry(textvariable=fname) lname_input = tk.Entry(textvariable=lname) street_input = tk.Entry(textvariable=street) postcode__input = tk.Entry(textvariable=postcode) city_input = tk.Entry(textvariable=city) telnr_input = tk.Entry(textvariable=telnr) search_input = tk.Entry(textvariable=search) fname_input.place(x=120, y=50) lname_input.place(x=120, y=80) street_input.place(x=120, y=110) postcode__input.place(x=120, y=140) city_input.place(x=120, y=170) telnr_input.place(x=120, y=200) search_input.place(x=280, y=50) self.display_label.place(x=20, y=25) submit_button = tk.Button(text="Toevoegen", command=lambda: submit_contact()) submit_button.place(x=20, y=240) clear_button = tk.Button(text="Wis Velden", command=lambda: erase_fields()) clear_button.place(x=100, y=240) search_button = tk.Button(text="Zoek op naam", command=lambda: start_search(search.get())) search_button.place(x=280, y=80) save_button = tk.Button(text="Opslaan in Geheugen", command=lambda: pickle_book()) save_button.place(x=350, y=240) clearall_button = tk.Button(text="Wis geheugen", command=lambda: clear_phonebook()) clearall_button.place(x=480, y=240) #Stops While loop before destroying mainloop to exit the app def exit(): klok.turn_off() self.destroy() #Search by name using a Search instance def start_search(name): start_search = Search(Phone_book) output = start_search.start(name) self.output.delete('1.0', tk.END) self.output.insert(tk.INSERT, 'u zocht op %s \n\n' % name) self.output.insert(tk.INSERT, output) #Delete txt file, PhoneBook Dictionary and repickle it def clear_phonebook(): Phone_book.clear_phonebook() FileSaver.clear_phonebook() pickle_book() self.output.delete('1.0', tk.END) self.output.insert(tk.INSERT, "Alles gewist") #Pickle PhoneBook instance def pickle_book(): Pickler.start_pickle(Phone_book) self.output.delete('1.0', tk.END) self.output.insert(tk.INSERT, "Object opgeslagen") #Start a client socket, for downloading the txt file def start_client(): Client.startclient() #Start server using Thread otherwise the program freezes def start_server(): t2 = threading.Thread(target=Server.startserver, args=()) t2.setDaemon(True) t2.start() #Erase all input fields def erase_fields(): fname.set("") lname.set("") street.set("") postcode.set("") city.set("") telnr.set("") search.set("") #Open the saved txt file and display it in output textfield def display_output(): OpenFile = FileOpener() file = OpenFile.open_file() self.output.delete('1.0', tk.END) self.output.insert(tk.INSERT, file.read()) #Save the print_book() output to phonebook.txt def save_book(): SaveFile = FileSaver() SaveFile.write_new_file(Phone_book.print_book()) #Dialog for total Dictionary keys def show_total(): messagebox.showinfo("Totaal aantal contacten", Phone_book.get_total()) #Gets called after users presses "toevoegen", depending on if key exists it adds a new key or updates the existing value and displays output def submit_contact(): if fname.get() != "" and lname.get() != "": if (Phone_book.add_to_book(fname.get(), lname.get())) is True: display.set("Bestaand contact bijgewerkt") Phone_book.replace_contact(street.get(), postcode.get(), city.get(), telnr.get()) else: Phone_book.add_new_contact(street.get(), postcode.get(), city.get(), telnr.get()) display.set("Nieuw contact aangemaakt") else: display.set("Geen volledige naam ingevuld") #Protocol rule for closing the tkinter window, so it calls the exit function the stop the loop otherwise it generates an error self.protocol("WM_DELETE_WINDOW", lambda: exit()) #Start new thread for clock instance and give the tkinter time_label as parameter klok = Clock() t = threading.Thread(target=klok.startclock, name="Klok", args=(time_label, )) t.setDaemon(True) t.start()
def isRunning(): global running return running #CPU_GUI = threading.Thread(target=GUI.GUI).start() # Global configurations from .env file and extract global values global CONFIG CONFIG = dotenv.dotenv_values(".env") # Extract values from config file FREQ = int(CONFIG["CLOCK_FREQ"]) # Initialize clock clk = Clock.Clock(FREQ) cu1 = ControlUnit.ControlUnit(clk, FREQ, 0) cu2 = ControlUnit.ControlUnit(clk, FREQ, 1) cu3 = ControlUnit.ControlUnit(clk, FREQ, 2) cu4 = ControlUnit.ControlUnit(clk, FREQ, 3) threading.Thread(target=cu1.run).start() threading.Thread(target=cu2.run).start() threading.Thread(target=cu3.run).start() threading.Thread(target=cu4.run).start() clk.changeMode() threading.Thread(target=clk.run).start() threading.Thread(target=clk.printClock).start()
from Clock import * c1 = Clock(1928675) print(c1) c2 = Clock() print(c2) c3 = Clock('1:02:05') print(c3) print('{} + {} = {}'.format(c1, c3, c1 + c3))
def run(self): while globals.running.is_set(): if globals.ClockMode == 1: try: BTTF_Clock() except (KeyboardInterrupt, SystemExit): clear_display16() cleanupButtons() globals.running.clear() sys.exit() elif globals.ClockMode == 2: Clock_temp_humid() elif globals.ClockMode == 3: current_weather(globals.AirportCode) elif globals.ClockMode == 4: weather_forecast(globals.CityCode, 4) elif globals.ClockMode == 5: TimeSinceDate(globals.FromDate) elif globals.ClockMode == 6: TimeToDeadline(globals.Deadline) elif globals.ClockMode == 7: WorldClock() elif globals.ClockMode == 8: initMP3() init_MP3_playlist() try: play_mp3() # local files time.sleep(0.2) except (KeyboardInterrupt, SystemExit): mpc.stop() mpc.clear() clear_display16() globals.running.clear() sys.exit() elif globals.ClockMode == 9: initMP3() init_MP3_playlist(1) try: play_mp3(1) # Internet radio time.sleep(0.2) except (KeyboardInterrupt, SystemExit): mpc.stop() mpc.clear() clear_display16() globals.running.clear() sys.exit() elif globals.ClockMode == 10: Clock() elif globals.ClockMode == 11: Now_Milliseconds() elif globals.ClockMode == 12: Chrono() # milliseconds chronometer elif globals.ClockMode == 13: Chrono(1) # seconds chronometer elif globals.ClockMode == 14: setAlarm() elif globals.ClockMode == 15: Timer() elif globals.ClockMode == 16: ChessClock() elif globals.ClockMode == 17: # display the device's IP address showIP() else: globals.ClockMode = 1 time.sleep(0.01)
cameraTargetDistance = 13.0 cameraTargetOffset = cgtypes.vec3(0.0, cameraTargetDistance, 0.0) ########## SteerTest phase phaseStack = [0, 0, 0, 0, 0] phaseStackSize = 5 phaseStackIndex = 0 # list of floats phaseTimers = [0.0, 0.0, 0.0, 0.0] # list of floats phaseTimerBase = 0.0 # keeps track of both "real time" and "simulation time" clock = Clock() # camera automatically tracks selected vehicle camera = Camera() # currently selected plug-in (user can choose or cycle through them) selectedPlugIn = None # currently selected vehicle. Generally the one the camera follows and # for which additional information may be displayed. Clicking the mouse # near a vehicle causes it to become the Selected Vehicle. selectedVehicle = None phase = OVERHEADPHASE enableAnnotation = True gDelayedResetPlugInXXX = False
import Battery import time # Initial/default Pump configuration parameters to store in db first_name = 'Joe' last_name = 'Doe' capacity_insulin = 100.0 drip_rate = 1.0 safe_min = 6.0 safe_max = 14.0 max_daily_dose = 25.0 max_single_dose = 4.0 minimum_dose = 1.0 bg_sensor = BloodGlucose.BloodGlucose() clock = Clock.Clock() clock_time = clock.getTime() battery = Battery.Battery() sqlite_file = 'insulin_pump.sqlite' # name of the sqlite database file def get_db(table_name, column_name): try: conn = sqlite3.connect(sqlite_file) c = conn.cursor() except Error as e: print(e) else: c.execute('SELECT ' + column_name + ' FROM ' + table_name) data = c.fetchone()
def __init__(self, aKernel): self.quantum = aKernel.shortScheduler.quamtum() self.currentQuantum = self.quantum self.clock = Clock(self) self.kernel = aKernel