def connect_to_server(): #Get port port = console_client.client.port #Set the port to whatever input we have try: port = int(core.get_value("port_input")) #Fails when port isn't an int except: pass #Get server server = core.get_value("server_selection") if server == "server_selection": server = "0" #Reset host and port console_client.client.host = console_client.client.host_list[int(server)] console_client.client.port = port #Change pages hide_server_selection() show_server_status() #Connect network_thread = threading.Thread(target = console_client.client.connect) network_thread.start()
def change_mp_percentage(self, sender, data): percentage = get_value('% MP') self.send_to_pipes(f'MP\\VAL\\{percentage / 100}') if get_value('Currently doing nothing on MP. Pick button.') != 'Currently doing nothing on MP. Pick button.': set_value('Currently doing nothing on MP. Pick button.', f'Taking MP on {get_value("% MP")}% by clicking on {self.current_mp_btn.split("#")[0]}.')
def change_list_callback(self, sender, data): if sender[0:len(self.type)] == self.type: self.neuronDataContainer.listOfLayerTypes[int( sender[-1])] = core.get_value(sender) if sender[0:len(self.activation)] == self.activation: self.neuronDataContainer.listOfActivations[int( sender[-1])] = core.get_value(sender)
def compose_workout(self): equipment_val = core.get_value("Equipment##widget") exercise_type_val = core.get_value("Exercise Type##widget") muscle_group_val = core.get_value("Muscle Group##widget") if not equipment_val or not exercise_type_val or not muscle_group_val: simple.show_item("Fill all the inputs, please.") else: simple.hide_item("workout_composition_group") self._composed_workout = workout_services.get_composed_workout( equipment_val, exercise_type_val, muscle_group_val) core.add_group(name="buttons", parent="workout_execution_group") core.add_table( "workout_table", ["Exercise", "Sets", "Reps", "Example"], parent="workout_execution_group", callback=self.toggle, ) for workout in self._composed_workout: core.add_row("workout_table", list(workout.values())) core.add_button("Cancel##widget", callback=self.cancel_workout, parent="buttons") core.add_button("Clear##widget", callback=self.clear_table, parent="buttons") core.add_button("Save##widget", callback=self.save_workout, parent="buttons")
def debug_get_window_pos(sender, data): """ Debug setup for getting location configs of windows """ log_info(sender, logger=data) window_name_to_search = get_value("Window Name##input") show_invisible = get_value("Print invisible") log_info(window_name_to_search, logger=data) log_info(show_invisible, logger=data) window_list = list() if window_name_to_search: log_debug(window_name_to_search, logger=data) for window_name in get_windows(): if window_name_to_search.lower() in window_name.lower(): window_list.append(window_name) else: window_list = get_windows() for window_name in window_list: config = get_item_configuration(window_name) if show_invisible is False: if config.get("show") is False: continue x_pos = config.get("x_pos", 0) y_pos = config.get("y_pos", 0) name = config.get("name") if len(name) > 6: name = name[:5] log_debug(f"{name} : {x_pos}, {y_pos}", logger=data)
def create_new_user_data(sender, data) -> None: initial_data = { "User Name": gg.get_value("##user_name"), "Start Balance": gg.get_value("##balance_input") } if not initial_data["User Name"].isalpha(): gg.add_label_text("Error", color=[255, 0, 0], before="##balance_input", label="Username must be alphabetical") gg.log_error("User-name must be only alphabets") return elif initial_data["User Name"] + ".db" in os.listdir(): gg.add_label_text("Error", color=[255, 0, 0], before="##balance_input",label="Username already exists!") gg.log_error("User-name must be unique") return if initial_data["Start Balance"] <= 0: gg.add_label_text("Error_start_balance", color=[255, 0, 0], before="Proceed",label="Balance must be greater than 0$") gg.log_error("Balance must be greater than 0$!") return create_database(initial_data["User Name"] + ".db", initial_data["Start Balance"]) gg.delete_item("Main") initial_screen()
def changes_detected(): """ Check if changes are detected and change the Color of Apply Configuration red. Set the global var iChanges to 1 in case someone tries to start without saving """ global iChanges core.set_item_color("Apply Configuration", mvGuiCol_Text, (255, 0, 0, 255)) iChanges = 1 set_false = 0 cnt = 0 acList = (core.get_value("Score##match"), core.get_value("Result (W/L)##match"), core.get_value("Map##match")) for x in acList: if x is False: cnt = cnt + 1 if cnt != 2: for x in acList: if x is False: core.set_value("Result (W/L)##match", False) core.set_value("Map##match", False) core.set_value("Score##match", False) set_false = 1 break if set_false == 0: core.set_value("Result (W/L)##match", True) core.set_value("Map##match", True) core.set_value("Score##match", True)
def __render(self): # check if something is set to "animate" # x = core.get_value("AngleAnimate") if not core.get_value("AngleAnimate"): return step = core.get_value("AngleStep") self.__fractal.dAngle += step self.__refresh(False)
def add_variable_gui(sender, data): args = argparse.Namespace(name=core.get_value(data[0]), content=core.get_value(data[1]), tag=None) for input in data: core.set_value(input, "") add_variable(args)
def cancel_login(self): if core.get_value("Please, fill all the inputs"): core.delete_item("Please, fill all the inputs") if core.get_value("Incorrect Password"): core.delete_item("Incorrect Password") core.delete_item("Username##login") core.delete_item("Password##login") core.delete_item("Log in") core.delete_item("Create an account")
def GetData(sender, data): sepLength = core.get_value("Sepal Length") sepWidth = core.get_value("Sepal Width") petLength = core.get_value("Petal Length") petWidth = core.get_value("Petal Width") core.set_value("sepLength", sepLength) core.set_value("sepWidth", sepWidth) core.set_value("petLength", petLength) core.set_value("petWidth", petWidth)
def save_or_update_db(sender, data): session = Session() name = core.get_value(data[0]) content = core.get_value(data[1]) args = argparse.Namespace(name=name, content=content, tag=None) db_var = session.query(Variable).filter(Variable.name == name).first() if db_var: update_variable(args) else: add_variable(args)
def update_win_loss(): day = core.get_value("Day##WinLoss") week = core.get_value("Week##WinLoss") data = (day, week) print('update') print(data) sqlite3db.TExecSql( DBNAME, """ UPDATE CFG_WIN_LOSS SET Day = ? , Week = ? """, data)
def save_web(): """ """ web_only = core.get_value("Open in Browser Only##Browser") web_app = core.get_value("Open in Browser and App##Browser") web_update = web_only, web_app sqlite3db.TExecSql(DBNAME, """ UPDATE CFG_WEB SET WEB_ONLY = ?, WEB_APP = ? """, web_update)
def cancel_workout(self): if core.does_item_exist("example_image"): core.delete_item("example_image") core.delete_item("buttons") core.delete_item("workout_table") simple.show_item("workout_composition_group") if core.get_value("Results successfully saved"): core.delete_item("Results successfully saved") if core.get_value("Error happened while saving the result"): core.delete_item("Results successfully saved")
def log_in(self): username = core.get_value("Username##login") password = core.get_value("Password##login") if not username or not password: simple.show_item("Please, fill all the inputs") return result = user_services.login_user(username, password) if result: self.logged_in_mode() else: simple.show_item("Incorrect Password")
def show_mapping(sender, data): """ Opens new window with a mapping. """ if core.get_value('device_type') == 0: architecture = gui.backend_dict[0] else: architecture = gui.backend_dict[core.get_value('architecture') + 1] old_dict = gui.projection_map new_dict = dict([(value, key) for key, value in old_dict.items()]) draw_graph(architecture, new_dict)
def sign_up(self): username = core.get_value("Username##signup") email = core.get_value("Email##signup") password = core.get_value("Password##signup") if not username or not email or not password: simple.show_item("Please, fill all the inputs") return result = user_services.signup_user(username, email, password) if result: self.cancel_signup() else: simple.show_item("Something went wrong")
def cancel_signup(self): if core.get_value("Please, fill all the inputs"): core.delete_item("Please, fill all the inputs") if core.get_value("Something went wrong"): core.delete_item("Something went wrong") core.delete_item("Username##signup") core.delete_item("Email##signup") core.delete_item("Password##signup") core.delete_item("Cancel") core.delete_item("Sign up") simple.show_item("login_els") self.add_login_els()
def predict_button(sender, data): sepLength = core.get_value("Sepal Length") sepWidth = core.get_value("Sepal Width") petLength = core.get_value("Petal Length") petWidth = core.get_value("Petal Width") features = [[ float(sepLength), float(sepWidth), float(petLength), float(petWidth) ]] result = model.predict(features) core.set_value("rs", result.title())
def save_new_row(self, sender, data): """ Appends data from Add Data Window to table data and closes window """ dev.log_debug("Adding new row -") self.table_data.append([ len(self.table_data), c.get_value(": x_val"), c.get_value(": y_val"), ]) self.update_data() c.delete_item("Add Data Window")
def win_los(sender): print(sender) if sender == "Day##WinLoss" and core.get_value("Day##WinLoss") is False: core.set_value("Day##WinLoss", False) if sender == "Day##WinLoss" and core.get_value("Day##WinLoss") is True: core.set_value("Day##WinLoss", True) core.set_value("Week#WinLoss", False) if sender == "Week##WinLoss" and core.get_value("Week##WinLoss") is False: core.set_value("Week##WinLoss", False) if sender == "Week##WinLoss" and core.get_value("Week##WinLoss") is True: core.set_value("Day##WinLoss", False) core.set_value("Week##WinLoss", True) update_win_loss()
def save_preferences(self, sender, data): prefs = { 'HP_perc': get_value('% HP'), 'MP_perc': get_value('% MP'), 'HP_button': self.current_hp_btn, 'MP_button': self.current_mp_btn, 'window': self.window_title } try: with open(PREF_FILE_NM, 'w') as fd: json.dump(prefs, fd) except: pass
def del_callback(sender, data): tFN = core.get_value("##fname") tSN = core.get_value("##sname") con = sqlite3.connect('addresses.db') cursor = con.cursor() sql_del_query = """DELETE from address_data where fname = ? AND sname = ?""" cursor.execute(sql_del_query, (tFN, tSN)) con.commit() con.close() clear_callback(1, 1) table_update()
def execute_algorithms(self, sender: str, selected_algorithms: List[str]): init_coords = core.get_value("init_coordinate") dest_coords = core.get_value("destination_coordinate") objective = {} for algorithm in selected_algorithms: init_node = self.algorithm_service.get_nearest_node_by_lat_long( float(init_coords[0]), float(init_coords[1])) dest_node = self.algorithm_service.get_nearest_node_by_lat_long( float(dest_coords[0]), float(dest_coords[1])) objective[algorithm] = [init_node, dest_node] self.pool.apply_async(self.algorithm_service.compute, args=[objective], callback=self._handle_result)
def _update_dynamic_textures(sender, data): global demo_dynamic_texture_1, demo_dynamic_texture_2 new_color = dpg.get_value(sender) new_color[0] = new_color[0] / 255 new_color[1] = new_color[1] / 255 new_color[2] = new_color[2] / 255 new_color[3] = new_color[3] / 255 if data == 1: texture_data = [] for i in range(0, 100 * 100): texture_data.append(new_color[0]) texture_data.append(new_color[1]) texture_data.append(new_color[2]) texture_data.append(new_color[3]) dpg.set_value(demo_dynamic_texture_1, texture_data) elif data == 2: texture_data = [] for i in range(0, 50 * 50): texture_data.append(new_color[0]) texture_data.append(new_color[1]) texture_data.append(new_color[2]) texture_data.append(new_color[3]) dpg.set_value(demo_dynamic_texture_2, texture_data)
def change_bpm(self): params.bpm = core.get_value('SliderBPM') # Update recorder bpm self.recorder = PatternRecorder(params.bpm, self.play) status.params_changed = True
def handle_metric(self): value = core.get_value("metrics") core.clear_plot("Metrics plot") bar_positions = [2 * idx + 1 for idx in range(len(self.alg_result))] if len(self.alg_result): elapsed_times = [ self.alg_result[idx]["elapsed_time"] for idx in range(len(self.alg_result)) ] expanded_nodes = [ algorithm["alg_result"]["expanded"] for algorithm in self.alg_result ] if value == 0: core.add_bar_series("Metrics plot", "Elapsed time", bar_positions, elapsed_times) core.set_plot_ylimits("Metrics plot", 0, max(elapsed_times) * 1.2) if value == 1: core.add_bar_series("Metrics plot", "Expanded nodes", bar_positions, expanded_nodes) core.set_plot_ylimits("Metrics plot", 0, max(expanded_nodes) * 1.2) x_ticks = [[alg, idx] for alg, idx in zip(self.selected_algorithms, bar_positions) ] core.reset_xticks("Metrics plot") core.set_xticks("Metrics plot", x_ticks)
def compose_workout(self): equipment_val = core.get_value("Equipment##widget") exercise_type_val = core.get_value("Exercise Type##widget") muscle_group_val = core.get_value("Muscle Group##widget") if not equipment_val or not exercise_type_val or not muscle_group_val: simple.show_item("Fill all the inputs, please.") else: self.composed_workout = get_composed_workout( equipment_val, exercise_type_val, muscle_group_val) simple.hide_item("workout_composition_group") core.add_table("Workout", ["Exercise", "Sets", "Reps", "Example"], callback=self.toggle) for el in self.composed_workout: core.add_row("Workout", list(el.values())) core.add_button("Cancel##widget") core.add_button("Save##widget")
def __imgChange(self, sender, data): data = core.get_item_configuration(sender) idx = core.get_value(sender) puzzle = self.__puzzles[data['items'][idx]] if puzzle != self.__puzzle: self.__puzzle = puzzle self.__clearBoard(self, self.__rows, True)