def save(): file_name = "ani1.gif" imageio.mimsave( file_name, animation.images, format="gif",duration=0.5) info("save", "animation saved as {}".format(file_name))
def _sensor_add_note_button(self): """ Send the note to selected sensor. """ if self.textbox_current_note.value.strip() == "": guizero.warn("Empty Note", "Cannot add a blank Note") else: if self.checkbox_use_current_datetime.value: self._reset_datetime() try: user_datetime_var = self.adjust_datetime(self.textbox_note_date.value, self.current_config.datetime_offset * -1) except Exception as error: user_datetime_var = self.textbox_note_date.value app_logger.sensor_logger.error("Unable to convert user entered DateTime: " + str(error)) command = self.network_send_commands.put_sql_note network_timeout = self.current_config.network_timeout_data sensor_command = sensor_commands.CreateSensorNetworkCommand(self.selected_ip, network_timeout, command) sensor_command.command_data = user_datetime_var + \ self.network_send_commands.command_data_separator + \ self.sterilize_notes(self.textbox_current_note.value) sensor_commands.put_command(sensor_command) guizero.info("Note Inserted into Sensors " + self.selected_ip, "Inserted with DateTime: " + user_datetime_var) app_logger.sensor_logger.info("Inserted note into sensors " + str(self.selected_ip) + " with DateTime " + user_datetime_var) self._connect_to_sensor()
def start(): """ Function called when start buton is pressed It checks that a card has been inserted by looking for auto-mounted /dev/sda partitions """ found_sd = False for p in psutil.disk_partitions(): if p.device == "/dev/sda2" and p.mountpoint == "/media/pi/rootfs": logger.info("Found SD card - looks like Raspbian") found_sd = True elif p.device == "/dev/sda1" and p.mountpoint == "/media/pi/boot": logger.info("Found SD card- looks like Raspbian") found_sd = True elif p.device == "/dev/sda1" and p.fstype == "vfat": logger.info("Found SD card - looks like NOOBs") found_sd = True if found_sd: instructions.enable() image_selecter.enable() button_burn.enable( ) # do this now becuase users might want to go with the default text_start.disable() button_start.disable() info( "Success!", "SD card detected. Please choose your operating system and then press 'Burn'" ) else: error("Uh oh!", "No SD card detected - please remove it and try again")
def datetime_update(self): """ Sends the Date & Time update command to the Sensor Units IP, along with the computers Date & Time. """ app_logger.sensor_logger.debug("Updating Sensors DateTime") threads = [] network_timeout = self.current_config.network_timeout_data ip_list = self.ip_selection.get_verified_ip_list() if len(ip_list) > 0: command = network_commands.set_datetime for ip in ip_list: sensor_command = sensor_commands.CreateSensorNetworkCommand( ip, network_timeout, command) sensor_command.command_data = self.current_config.get_str_datetime_now( ) threads.append( Thread(target=sensor_commands.put_command, args=[sensor_command])) for thread in threads: thread.start() guizero.info( "Sensors DateTime Set", "Sensors Date & Time synchronized with local computer's") else: app_useful_functions.no_ip_selected_message()
def set_names(): global player_one global player_two global player_one_name global player_two_name global current_player player_one = player_one_name.value player_two = player_two_name.value random_player = randint(1, 2) if random_player == 1: current_player = player_one else: current_player = player_two player_name_window.hide() # displays player's turn info("Player Turn", current_player + "'s turn.") # sets up grids set_grids() # starts timer and sets round up timer.value = game_timer timer.repeat(1000, counter) setup_round()
def start_drain(): global valve1_pos global valve2_pos global valve3_pos global valve4_pos global valve5_pos global valve6_pos global pump2_pos global kettle_empty_lvl_sns drain_started = True if drain_started == True and kettle_empty_lvl_sns == False: valve1_pos = "Closed" valve2_pos = "Closed" valve3_pos = "Closed" valve4_pos = "Closed" valve5_pos = "Open" valve6_pos = "Open" pump2_pos = "Enabled" Drain_start_button.bg = "green" Drain_stop_button.bg = "gray" pump_status_update() valve_status_update() else: info("Warning!", "Ensure kettle is not empty!") stop_drain() stop()
def start_htl(): global htl_started global htl_temp global htl_temp_sp global htl_covered htl_started = True try: #HTL temp control if htl_started == True and htl_temp_sp == htl_temp and htl_covered == True: #and HTL_temp_probe = True HTL_temp_status.value = str(htl_temp) + " Celcius" HTL_ele_sns_status.value = "Heated" HTL_start_button.bg = "green" HTL_stop_button.bg = "gray" elif htl_started == True and htl_temp < htl_temp_sp and htl_covered == True: HTL_temp_status.value = str(htl_temp) + " Celcius" HTL_ele_sns_status.value = "Heating" HTL_start_button.bg = "green" HTL_stop_button.bg = "gray" else: stop() stop_htl() except NameError: info("Warning!", "You haven't defined a set point for the HTL!") stop_htl() htl_started = False
def start_vorlauf(): global valve1_pos global valve2_pos global valve3_pos global valve4_pos global valve5_pos global valve6_pos global pump1_pos global underback_lvl_sns vorlauf_started = True if vorlauf_started == True and underback_lvl_sns > 0: valve1_pos = "Closed" valve2_pos = "Open" valve3_pos = "Closed" valve4_pos = "Closed" valve5_pos = "Closed" valve6_pos = "Closed" pump1_pos = "Enabled" pump_status_update() valve_status_update() Vorlauf_start_button.bg = "green" Vorlauf_stop_button.bg = "gray" else: info("Warning!", "Ensure there is something in the underback") stop_vorlauf() stop()
def new_game(): global game_timer global rounds global correct_guesses global leaderboard # destroys and creates leaderboard window leaderboard.destroy() leaderboard = Window(app, title="High Scores") leaderboard.hide() # resets variable values timer.value = game_timer result.value = "" score.value = "0" correct_guesses = 0 game_timer = 20 score_bonus.value = "" # adds to round count rounds += 1 # displays player's turn info("Player Turn", current_player + "'s turn.") # restarts game setup_round() # starts new timer timer.repeat(1000, counter)
def onclick_nfc(): global main_box #popup box for nfc info( "NFC", "Please tap OK when ready, then tap your phone to the NFC box above.") del_main() nfc_subprocess.nfc_beam_recv() #get nfc code file = open("nfccode.txt", "r") nfc_code_get = file.read() print(nfc_code_get) #check if nfc code is valid r = requests.get('https://hizhh.me/api/unlock/1', auth=HTTPBasicAuth(nfc_code_get, 'sdf'), verify=False) if (r.text != "Unauthorized Access"): open_door() print("OPEN SESAME") time.sleep(5) servo.wait_for_lever() #time.sleep(20) close_door() file.close() file = open("nfccode.txt", "w+") file.close() main_box.destroy() nfc_subprocess.stop_stream() show_start()
def do_inst(): info("instructions-keyboard","Press s to save and quit\ Press n to quit without saving\ Press c to correct\ Press m to show message\ Press f to speak\ Press e to send email")
def trigger_reconhecimento(): global imagem, img_window if imagem == 0: gui.warn('Erro', 'Selecione uma imagem') return False else: gui.info('Resultado', rcgTrigger.execute(imagem="./assets/" + imagem))
def registrazione(): global username c = socket_client() if c != -1: r = ["SERVICE", "regUser", usernameReg.value, passwordReg.value] r_ser = pickle.dumps(r) c.send(r_ser) risposta = c.recv(1024) risposta_decod = pickle.loads(risposta) if risposta_decod != "": if risposta_decod == "INSERITO": interfaccia.enable() finestraReg.hide() info("Successo", "Registrazione avvenuta con successo") username = usernameReg.value labelUsername.value = "Benvenuto " + username utenti = richiedi_utenti() for utente in utenti: lista_utenti.append(utente) elif risposta_decod == "ESISTENTE": error("Errore", "Username già esistente, riprova.") c.close() elif c == -1: error( "Errore", "Errore di connessione, il server potrebbe non essere disponibile")
def hostname_change(self): """ Sends the host name change command to the Sensor Units IP, along with the new host name. """ app_logger.sensor_logger.debug("Change Sensor Hostname") threads = [] network_timeout = self.current_config.network_timeout_data ip_list = self.ip_selection.get_verified_ip_list() if len(ip_list) > 0: for ip in ip_list: new_hostname = simpledialog.askstring(ip, "New Hostname: ") app_logger.sensor_logger.debug("Sent Hostname: " + str(new_hostname)) validated_hostname = sensor_commands.get_validated_hostname( new_hostname) app_logger.sensor_logger.debug("Validated Hostname: " + validated_hostname) if validated_hostname is not "Cancelled": command = network_commands.set_host_name sensor_command = sensor_commands.CreateSensorNetworkCommand( ip, network_timeout, command) sensor_command.command_data = validated_hostname threads.append( Thread(target=sensor_commands.put_command, args=[sensor_command])) else: guizero.info(ip, "Hostname Cancelled or blank for " + ip) for thread in threads: thread.start() else: app_useful_functions.no_ip_selected_message()
def send_commands(self, command): """ Sends provided command to the Sensor Units IP's. """ threads = [] ip_list = self.ip_selection.get_verified_ip_list() network_timeout = self.current_config.network_timeout_data for ip in ip_list: sensor_command = sensor_commands.CreateSensorNetworkCommand( ip, network_timeout, command) threads.append( Thread(target=sensor_commands.send_command, args=[sensor_command])) for thread in threads: thread.daemon = True thread.start() if len(ip_list) > 0: message = command + " sent to " + str(len(ip_list)) if len(ip_list) is 1: message += " sensor" else: message += " sensors" guizero.info("Sensor Command Sent", message) else: app_useful_functions.no_ip_selected_message()
def save_settings(): #resp = ynbox('Are you sure?') with open('camera_settings.txt', 'w') as fp: buf = 'x={0:.2f}\ny={1:.2f}\nw={2:.2f}\nh={3:.2f}\n'.format( cx, cy, cw, ch) fp.write(buf) preview_hide() info('info', 'settings saved')
def selection_chosen(): selection.hide() if selection.value == "1": info("well done", "you chose wisely") goodbye() else: warn("arrrgh", "next time, choose wisely!") app.after(2000, show_the_selection)
def clicked(x, y): print(x, y) if xTarget == x and yTarget == y: info("Hit", "You hit the target") myWaffle.set_all("white") myWaffle.after(3000, pickPixel) else: myWaffle.set_all("red")
def save_settings(): with open(camera_settings_file, 'w') as fp: buf = 'x={0:.2f}\ny={1:.2f}\nw={2:.2f}\nh={3:.2f}\n'.format( cx, cy, cw, ch) buf += 'exposure={0}\nbright={1}\ncont={2}'.format(cex, cb, cc) fp.write(buf) preview_hide() info('info', 'settings saved')
def edit(self): if self.identity_card[self.directs.value]==1: self.option.text='Off' self.identity_card[self.directs.value]=0 guizero.info(title='Modification performed',text=[' Deactivated',self.directs.value,]) else: guizero.warn(title='Error modification',text=['It is impossible deactivated ',self.directs.value]) self.text_box.value = self.identity_card
def do_booking(): info("Booking", "Thank You For Booking") print(film_choice.value) if vip_seat.value == 1: print("Vip Seat") else: print("Normal Seat") print(row_choice.value)
def do_inst(): info( "instructions-keyboard", "Press s to save and quit\ Press n to quit without saving\ Press c to correct\ Press m to show message\ Press f to speak\ Press e to send email")
def clear_FDB(): clearDB = yesno("HEY!!!", "Are you sure?") if clearDB == True: clear() info("HEY!!", "Operation was successful") else: info("NOTE!!", "Going back to main window ") delete_menu_window.hide() app.show()
def show_fun(self): # 每天一句俏皮话/诗词/计算机 funs = [ "预测未来的最佳方式就是去创造它。 --Alan Curtis Kay", "What a computer is to me is it’s the most remarkable tool that we’ve ever come up with, and it’s the equivalent of a bicycle for our minds. --Young Steve Jobs", "学习编程能帮你组织、表达和分享你的想法,就像学习写作一样。 --Mitchel Resnick", "学习是必须亲力亲为的,教育则是外界加诸你身上的。 --Joi Ito" ] info("fun", choice(funs))
def results(): whDestination = wormholeEyeLocations[wormholeEyeSlider.value] whMassLimit = wormholeAuroraMeanings[wormholeAuroraSlider.value] guizero.info( "Type of wormhole: ", f"This wormhole leads to:\n{whDestination}\n\nThis wormhole can transport:\n{whMassLimit}", master=mainApp)
def walk(matrix, identity_cards): x, y = location('o', matrix) identity_cards[x, y]['possible'] = 3 xo, yo = x, y crossing = [] step = [] error = 0 old_steps = ['fermo'] crossing.append('fermo') xf, yf = location('v', matrix) tmatrix = copy.copy(matrix) while tmatrix[xf, yf] == 'v': action = 0 priority = set_priority(x, y, matrix) for i in range(4): # controlla priorita if identity_cards[x, y][priority[i]] == 1: xt, yt = direct(priority[i], x, y) # controlla casella libera if tmatrix[xt, yt] == ' ' or tmatrix[xt, yt] == 'v': tmatrix[xt, yt] = 'O' if identity_cards[x, y]['possible'] > 2: # salva coordinate e direzione degli incroci crossing.append({ 'coordinate': [x, y], 'direct': priority[i] }) # avanzamento x, y = xt, yt action += 1 step.append(priority[i]) break if action == 0: error += 1 tmatrix = copy.copy(matrix) x, y = xo, yo old_steps.append(step[:]) step.clear() # controllo possibilita risoluzzione if old_steps[-1] == old_steps[-2]: guizero.warn(title='error', text='It is impossible go forward') return ['impossible'] else: # prova modifica incrocio try: xt, yt = crossing[-1]['coordinate'][0], crossing[-1][ 'coordinate'][1] identity_cards[xt, yt][crossing[-1]['direct']] = 0 identity_cards[xt, yt]['possible'] -= 1 except TypeError: guizero.warn(title='Error', text='It is impossible go forward') return ['impossible'] guizero.info(title='', text=('Error number ', error)) return step
def do_instrucoes(): info("instrucões","Press middle to (.)\ Press down to (-)\ Press right to add space\ Press left to select a letter\ Press up to show the message\ Press up for over 2 sec to make raspberry speak\ Press right for over 2 sec to send email\ \ Press down for over 2 sec to go back to the menu")
def clear_meta(item): # ask for user choice before deleting metdata choice = guizero.yesno("Confirm", "Delete metadata?") if choice: guizero.info("Delete", "Deleting metadata") item.clear_exif() item.close() clear_all() else: app.error("Close", "Not deleted")
def clicked(x, y): print(x, y) if xTarget == x and yTarget == y: end = time.time() delay = end - start info("Hit", "You hit the target. It took %4.2f seconds " % delay) myWaffle.set_all("red") myWaffle.after(300, pickPixel) else: myWaffle.set_pixel(x, y, "white")
def save_prompt(): app.destroy() #close the main setup window if yesno("Save","Save generated drawing?"): pygame.image.save(canvas, fname + "." + ftype) info("Saved", "Saved drawing (app will be closed)") sys.exit(0) info("Close", "Press OK to close app") sys.exit(0)
def do_instrucoes(): info( "instrucões", "Press middle to (.)\ Press down to (-)\ Press right to add space\ Press left to select a letter\ Press up to show the message\ Press up for over 2 sec to make raspberry speak\ Press right for over 2 sec to send email\ \ Press down for over 2 sec to go back to the menu")
def do_instrucoes(): info("instructions-Morse","Press left to (.)\ Press rigth to (-)\ Press down to add space\ Press middle to select a letter\ Press up to show the message\ Press left for over 2 sec to make raspberry speak\ Press rigth for over 2 sec to send email\ \ Press down for over 2 sec to go back to the menu\ Press up for over 2 sec to clean the message")
def countdown(t): while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") print_time(timer) time.sleep(1) t -= 1 info(app, 'Fire in the hole!!')
def do_booking(): info("Booking", "Loading") print( measure_choice.get() ) print( map_option.get_value() ) print( graphic_option.get_value() ) if measure_choice.get()=="Humidity" and map_option.get_value()==True: Humidity_map() if measure_choice.get()=="Humidity" and graphic_option.get_value()==True: Humidity_graphic() if measure_choice.get()=="Temperature" and graphic_option.get_value()==True: Temperature_graphic() if measure_choice.get()=="Temperature" and map_option.get_value()==True: Temperature_map() if measure_choice.get()=="Pressure" and graphic_option.get_value()==True: Pressure_graphic() if measure_choice.get()=="Pressure" and map_option.get_value()==True: Pressure_map()
def escolha_receita(): global receita_1, receita_2, receita_3, receita_4, receita_escolhida, receita_decisao, preparacao print("entrei") s = "" if receita_decisao.get() == "A": receita_escolhida = receita_1 preparacao = preparacao_1 for a in range(len(receita_1)): s += receita_1[a][0] s += " - " s += receita_1[a][1] s += " \n" elif receita_decisao.get() == "B": receita_escolhida = receita_2 preparacao = preparacao_2 for b in range(len(receita_2)): s += receita_2[b][0] s += " - " s += receita_2[b][1] s += " \n" elif receita_decisao.get() == "C": receita_escolhida = receita_3 preparacao = preparacao_3 for c in range(len(receita_3)): s += receita_3[c][0] s += " - " s += receita_3[c][1] s += " \n" elif receita_decisao.get() == "D": receita_escolhida = receita_4 preparacao = preparacao_4 for d in range(len(receita_4)): s += receita_4[d][0] s += " - " s += receita_4[d][1] s += " \n" info("Receita Escolhida", s ) game() sense.clear() sense.show_message(" WE DID IT!!! ")
def do_booking(): info("Info",".- A\ ,-... B\ , -.-. C\ , -.. D\ , . E\ , ..-. F\ , --. G\ , .... H\ , .. I\ , .--- J\ , -.- K\ , .-.. L\ , -- M\ , -. N\ , --- O\ , .--. P\ , --.- Q\ , .-. R\ , ... S\ , - T\ , ..- U\ , ...- V\ , .-- W\ , -..- X\ , -.-- Y\ , --.. Z\ ,.---- 1\ ,..--- 2\ ,...-- 3\ ,....- 4\ ,..... 5\ ,-.... 6\ ,--... 7\ ,---.. 8\ ,----. 9\ ,-----0\ , .-.-.- (.)\ , --..-- (,)\ , ..--.. (?)\ ,.----.'\ , -.-.-- (!)\ , -..-. (/)\ , -.--. (\ , -.--.-)\ , .-... (&)\ , ---... (:)\ , -.-.-.(;)\ , -...- (=)\ , .-.-. (+)\ , -....-(-)\ , ..--.- (_)\ , .-..-. (\)\ , ...-..- ($)\ , .--.-. (@)\ , .-.- |AA|\ , .-.-.|AR|\ , .-... |AS|\ , -...- |BT|\ , -.-.-|CT|\ , -.--. |KN|\ , ...-.- |SK|\ , ...-.|SN|\ , ...---... |SOS|\ , --...-- happy face\ , -.....- normal face\ , -.---.- sad face")
def thanks(): global l,a,b,r,t,m, w, k, x, y, e, sense, elapsed l = start_choice.get() if str(l) == "START": sense = SenseHat() e = timedelta(seconds=45) elapsed = timedelta(seconds=0) sense.set_rotation(180) r = randint(0,7) t = randint(0,7) m = randint(0,7) w = randint(0,7) k = randint(0,7) y = 0 x = 0 a, b = 3, 4 def gyroscope(): global a, b x = sense.get_accelerometer_raw()['x'] y = sense.get_accelerometer_raw()['y'] x = round(x, 0) y = round(y, 0) if y == 1 and b > 0: b -= 1 sense.set_pixel(a, b, (0, 0, 0)) elif y == -1 and b < 7: b += 1 sense.set_pixel(a, b, (0, 0, 0)) elif x ==-1 and a < 7: a += 1 sense.set_pixel(a, b, (0, 0, 0)) elif x == 1 and a > 0: a -= 1 sense.set_pixel(a, b, (0, 0, 0)) def game_over_win(a,r,y,b,t,m,w,x,k): global time1, time2, elapsed, e, h time2= datetime.now() elapsed=time2 - time1 print ("Tempo que passou no jogo: ", str(elapsed.total_seconds())) if (a == r and y == b) or (t==a and y == b) or (m ==a and y == b) or (x ==a and w == b) or (x== a and b==k) : sense.set_rotation(180) sense.show_message("Game Over", scroll_speed=0.03, text_colour=[255,0,0]) sense.show_message(str(int(elapsed.total_seconds())), scroll_speed=0.06) print("Game Over") if int(elapsed.total_seconds()) > h: sense.show_message("New Highscore", scroll_speed=0.06) h = int(elapsed.total_seconds()) sense.set_pixels(imagecaveira) sleep(1) return 1 else: sense.set_pixels(imagecaveira) sleep(1) return 1 return 0 def move_up(event): global b if event.action == "pressed" and b < 7: b += 1 sense.set_pixel(a, b, [0,0,0]) def move_down(event): global b if event.action == "pressed" and b > 0: b -= 1 sense.set_pixel(a, b, [0,0,0]) def move_right(event): global a if event.action == "pressed" and a > 0: a -= 1 sense.set_pixel(a, b, [0,0,0]) def move_left(event): global a if event.action == "pressed" and a < 7: a += 1 sense.set_pixel(a, b, [0,0,0]) def draw_player(): global a, b sense.set_pixel(a, b, [255, 255, 0]) def draw_enemy(x, y): global r, t, m, w, k sense.set_pixel(r, y, [255, 0, 0]) sense.set_pixel(t, y, [255, 0, 0]) sense.set_pixel(m,y, [255, 0, 0]) sense.set_pixel(x,w, [255, 0, 0]) sense.set_pixel(x, k, [255,0,0]) test2 = game_over_win(a,r,y,b,t,m,w,x,k) return test2 def level_2(x,y): global elapsed, r, t, m, w, k, h while True: sense.clear(0, 0, 0) gyroscope() draw_player() test = draw_enemy(x, y) if test == 1: break; sleep(0.25) y = y+1 if y > 7: r = randint(0,7) t = randint(0,7) m = randint(0,7) y = 0 x = x+1 if x > 7: w = randint(0,7) k = randint(0,7) x = 0 def new_game(): global sense, a, b, r, t, m, w, k, y, x, h print("new_game ") #Sense hat reset sense.stick.direction_up = None sense.stick.direction_down = None sense.stick.direction_right = None sense.stick.direction_left = None sense.stick.direction_middle = None sense = SenseHat() sense.set_rotation(180) sense.clear() #Sense hat reset func sense.set_pixels(imagemenu) r = randint(0,4) t = randint(0,7) m = randint(4,7) w = randint(0,7) k = randint(2,6) y = 0 x = 0 a, b = (3, 4) sense.stick.get_events() def menu(): global sense, time1, time2, r, t, m, w, k, a, b, elapsed sense = SenseHat() sense.set_rotation(180) sense.clear() sense.set_pixels(imagemenu) sense.stick.get_events() while True: print (" new game1",a," ",b) y1 = sense.get_accelerometer_raw()['y'] y1 = round(y1, 0) if y1 == -1: sense.show_message("Highscore '%s'"% (h)) sense.set_pixels(imagemenu) for event in sense.stick.get_events(): if event.action == "pressed" and event.direction == "middle": elapsed = timedelta(seconds=0) sense.set_rotation(180) sense.stick.direction_up = move_up sense.stick.direction_down = move_down sense.stick.direction_right = move_right sense.stick.direction_left = move_left x=0 y=0 time1 = datetime.now() print(elapsed, " elapsed and e ", e) while elapsed < e: sense.clear() draw_player() test = draw_enemy(x, y) print("menu nivel1 ",test) if test == 1: new_game() break sleep(0.25) y = y+1 if y > 7: r = randint(0,7) t = randint(0,7) m = randint(0,7) y = 0 x = x+1 if x > 7: w = randint(0,7) k = randint(0,7) x = 0 if elapsed > e: sense.show_message("Next level", scroll_speed=0.05) sense.set_pixels(imagesmile) sleep(1) level_2(x,y) new_game() break if event.action == "pressed" and (event.direction == "up" or event.direction == "down" or event.direction == "left" or event.direction == "right"): return click = sense.show_message("Menu", scroll_speed=0.05) sense.clear() sense.set_pixels(imagemenu) menu() info(text="Obrigado por jogares ", title="FAQ") if str(l) == "Information": info(text="Pressiona o joystick para jogares", title="FAQ")
def do_booking(): info("Score", "{0}, your score was \n {1}".format(my_name.get(), score) )
def show_weather(): selected_value = weather_options.get() print(selected_value) result = [] if selected_value == "Air pressure": info("Weather",' '+str(int(round(a,0)))+str(' hPa')) elif selected_value == "Ambient Temperature": if b<= 15: warning= "Warning: Wear warm clothes" elif b< 30: warning= "Wear normal clothes" else: warning= "Warning: Use sunscreen" info("Weather",' '+str(int(round(b,0)))+str(' ºC' ) + "\n"+ warning) elif selected_value == "Ground Temperature": if c<= 15: warning= "Warning: Wear warm clothes" elif c< 30: warning= "Wear normal clothes" else: warning= "Warning: Use sunscreen" info("Weather"," "+str(int(round(c,0)))+str(' ºC') + "\n"+ warning) elif selected_value == "Humidity": info("Weather",' '+str(int(round(d,0)))+str(' %')) elif selected_value == "Rainfall": if e<= 1: warning= "Don't worry about the rain" elif e< 20: warning= "Warning: Be prepared for some rain today" else: warning= "Warning: Heavy rain! Be prepared" info("Weather",' '+str(int(round(e,0)))+str(' mm') + "\n"+ warning) elif selected_value == "Room Temperature": info("Weather",' '+str(int(round(f,0)))+str(' ºC')) elif selected_value == "Wind Speed": if g<=15 : warning= "Don't worry about the wind" elif g< 40: warning= "Warning: The wind is a bit strong" else: warning= "Warning: Don't fly away!" info("Weather",' '+str(int(round(g,0)))+str(' Km/H') + "\n"+ warning)
def admin_mainmenu_warn(): info("INFO!!", "Please provide authenication!")