def move_python_sitl_entries(): for i in range(4): fun.move_tk_object(conf_sitl_tab.entry_label[i+7], 7+i,0) fun.move_tk_object(conf_sitl_tab.entry[i+7], 7+i, 1)
def create_file_tab(notebook): file_tab.create_tab(notebook, "File") combobox_options = [files.get_save_names()] names_combobox = [""] file_tab.create_combobox(combobox_options, names_combobox, 1, 0, s="EW") names_entry = ["", ""] file_tab.create_entry(names_entry, 0, 0, s="EW", w=30) x = 45 for i in range(len(file_tab.entry)): file_tab.entry[i].grid(padx=x, pady=20) for i in range(len(file_tab.combobox)): file_tab.combobox[i].grid(padx=x, pady=5) def create_new_file_b(): global active_file_name name = file_tab.entry[0].get() if savefile.check_if_file_exists2overwrite(name) is True: savefile.create_file(name) file_tab.combobox[0]["values"] = files.get_save_names() file_tab.combobox[0].set(savefile.name) fun.Tab.update_active_file_label(savefile.name) param_file_tab.depopulate() param_file_tab.populate(savefile.get_parameters()) draw_rocket_tab.depopulate() draw_rocket_tab.populate(savefile.get_rocket_dim()) conf_3d_tab.depopulate() conf_3d_tab.change_state() sim_setup_tab.depopulate() read_file() else: print("File was not created") new_file_button = tk.Button(file_tab.tab, text="Create New File", command=create_new_file_b, width=30) new_file_button.grid(row=0, column=2, padx=10) def read_file(): global active_file_name if file_tab.combobox[0].get() != "": savefile.update_name(file_tab.combobox[0].get()) savefile.read_file() param_file_tab.depopulate() param_file_tab.populate(savefile.get_parameters()) draw_rocket_tab.depopulate() draw_rocket_tab.populate(savefile.get_rocket_dim()) fun.Tab.update_active_file_label(savefile.name) conf_3d_tab.depopulate() conf_3d_tab.populate(savefile.get_conf_3d()) conf_3d_tab.change_state() conf_sitl_tab.depopulate() conf_sitl_tab.populate(savefile.get_conf_sitl()) conf_sitl_tab.checkbox[0].invoke() conf_sitl_tab.checkbox[0].invoke() sim_setup_tab.depopulate() sim_setup_tab.populate(savefile.get_conf_controller()) run_sim_tab.depopulate() run_sim_tab.populate(savefile.get_conf_plots()) savefile.read_motor_data(param_file_tab.combobox[0].get()) else: print("Select valid file") open_file_button = tk.Button(file_tab.tab, text="Open Selected File", command=read_file, width=30) open_file_button.grid(row=1, column=2, pady=50) def save_as(): global active_file_name if file_tab.entry[1].get() != "": name = file_tab.entry[1].get() if savefile.check_if_file_exists2overwrite(name) is True: savefile.create_file_as(name) d = param_file_tab.get_configuration() savefile.set_parameters(d) d = draw_rocket_tab.get_configuration() savefile.set_rocket_dim(d) d = conf_3d_tab.get_configuration() savefile.set_conf_3d(d) d = conf_sitl_tab.get_configuration() savefile.set_conf_sitl(d) d = sim_setup_tab.get_configuration() savefile.set_conf_controller(d) d = run_sim_tab.get_configuration() savefile.set_conf_plots(d) file_tab.combobox[0]["values"] = files.get_save_names() file_tab.combobox[0].set(savefile.name) fun.Tab.update_active_file_label(savefile.name) savefile.save_all_configurations() else: print("File was not created") else: print("Select file") save_as_button = tk.Button(file_tab.tab, text="Save As", command=save_as, width=30) save_as_button.grid(row=2, column=2) fun.move_tk_object(file_tab.entry[1], 2, 1) file_tab.create_active_file_label(32, 0) file_tab.configure()
def move_sensor_noise_entries(): for i in range(5): fun.move_tk_object(conf_sitl_tab.entry_label[i+2], 12+i) fun.move_tk_object(conf_sitl_tab.entry[i+2], 12+i, 1)
def move_python_sitl_checkbox(): fun.move_tk_object(conf_sitl_tab.checkbox[2], 5, 0, 2)
def move_sensor_noise_checkbox(): fun.move_tk_object(conf_sitl_tab.checkbox[1], 11, 0, 2)
def move_sitl_checkbox(): fun.move_tk_object(conf_sitl_tab.checkbox[0], columnspan=2)
def create_draw_rocket_tab(notebook): r""" Rocket points go from the tip down to the tail Fin[n][x position (longitudinal), z position (span)] [0]|\ | \[1] | | [3]|_|[2] """ draw_rocket_tab.create_tab(notebook, "Set Rocket Body") draw_rocket_tab.create_canvas(250, 450) # Create checboxes checkboxes = ["Ogival Nosecone", "Use fins", "Fins Attached to Body", "Control Fins", "Control Fins Attached"] draw_rocket_tab.create_checkboxes(checkboxes, 0, 1, "W") draw_rocket_tab.checkbox[0].grid(columnspan=10) draw_rocket_tab.checkbox[0].config(command=draw_rocket_tab.draw_rocket) # Uses fins checkbox draw_rocket_tab.checkbox[1].config(command=draw_rocket_tab.change_state_fins) draw_rocket_tab.checkbox[3].config(command=draw_rocket_tab.change_state_control_fins) draw_rocket_tab.checkbox[4].config(command=draw_rocket_tab.draw_rocket) def hollow_fin_body(): # Draws a straight line to simulate # the cut in the body draw_rocket_tab.draw_rocket() draw_rocket_tab.checkbox[2].config(command=hollow_fin_body) # Moves the checkbox from where they were created to it's final # position a little bit lower for i in range(2): fun.move_tk_object(draw_rocket_tab.checkbox[i+1], r=8+i, c=1, columnspan=1) for i in range(2): fun.move_tk_object(draw_rocket_tab.checkbox[i+3], r=8+i, c=3, columnspan=1) # create combobox combobox_options = [["0,0"]] names_combobox = [""] draw_rocket_tab.create_combobox(combobox_options, names_combobox, 3, 0, s="EW") draw_rocket_tab.combobox[0].config(state="readonly") draw_rocket_tab.combobox_label[0].destroy() tk.Label(draw_rocket_tab.tab, text="Insert Point").grid(row=1, column=1, sticky="WE") # Creates the entry for the rocket body points entry_rocket = tk.Entry(draw_rocket_tab.tab, width=20) entry_rocket.grid(row=2, column=1, sticky="EW") # Entries for the fins names_entry = ["1", "2", "3", "4"] draw_rocket_tab.create_entry(names_entry, 14, 0, s="EW") for i in range(4): fun.move_tk_object(draw_rocket_tab.entry_label[i], 14+i, 2) def button_add_point(): draw_rocket_tab.add_point(0, entry_rocket.get()) draw_rocket_tab.draw_rocket() add_point_button = tk.Button(draw_rocket_tab.tab, text="Add Point", command=button_add_point, width=10, fg="white", bg="green") add_point_button.grid(row=2, column=3, sticky="N") def button_delete_point(): p = draw_rocket_tab.combobox[0].get() if p != "0,0": draw_rocket_tab.delete_point(0, p) else: print("Cannot Delete the Nosecone Tip") draw_rocket_tab.draw_rocket() delete_point_button = tk.Button(draw_rocket_tab.tab, text="Delete Point", command=button_delete_point, width=10, fg="white", bg="red") delete_point_button.grid(row=3, column=3, sticky="N") draw_rocket_tab.active_point = "0,0" def button_select_point(): draw_rocket_tab.active_point = draw_rocket_tab.combobox[0].get() if draw_rocket_tab.active_point == "0,0": print("Cannot Modify the Nosecone Tip") select_point_button.config(bg="yellow") select_point_button = tk.Button(draw_rocket_tab.tab, text="Select Point", command=button_select_point, width=10, fg="white", bg="blue") select_point_button.grid(row=4, column=1, sticky="N") def button_modify_point(): p = entry_rocket.get() if draw_rocket_tab.active_point != "0,0": draw_rocket_tab.delete_point(0 , draw_rocket_tab.active_point) draw_rocket_tab.combobox[0].set(p) button_add_point() select_point_button.config(bg="blue") draw_rocket_tab.active_point = "0,0" else: print("Please Select Point") modify_point_button = tk.Button(draw_rocket_tab.tab, text="Modify Point", command=button_modify_point, width=10, fg="white", bg="blue") modify_point_button.grid(row=4, column=3, sticky="N") def button_save(): d = draw_rocket_tab.get_configuration() savefile.set_rocket_dim(d) savefile.save_all_configurations() save_file_button = tk.Button(draw_rocket_tab.tab, text="Save", command=button_save, width=20) save_file_button.grid(row=24, column=3) ## Fins def load_fins_stabi(): # populates the entries with the fin data for i in range(len(draw_rocket_tab.entry)): draw_rocket_tab.entry[i].delete(0, 15) draw_rocket_tab.entry[i].insert(0, draw_rocket_tab.points[1][i]) draw_rocket_tab.draw_rocket() update_fins_stabi_button = tk.Button(draw_rocket_tab.tab, text="Load Stabilization Fins", command=load_fins_stabi, width=20, fg="white", bg="#12B200") update_fins_stabi_button.grid(row=10, column=1, sticky="N", columnspan=1) def update_fins_stabi(): # updates the fin data with the entries for i in range(len(draw_rocket_tab.entry)): draw_rocket_tab.points[1][i] = draw_rocket_tab.entry[i].get() draw_rocket_tab.draw_rocket() update_fins_stabi_button = tk.Button(draw_rocket_tab.tab, text="Update Stabilization Fins", command=update_fins_stabi, width=20, fg="black", bg = "#C8FFC4") update_fins_stabi_button.grid(row=12, column=1, sticky="N", columnspan=1) def load_fins_control(): # Same as prev for i in range(len(draw_rocket_tab.entry)): draw_rocket_tab.entry[i].delete(0, 15) draw_rocket_tab.entry[i].insert(0, draw_rocket_tab.points[2][i]) draw_rocket_tab.draw_rocket() update_fins_stabi_button = tk.Button(draw_rocket_tab.tab, text="Load Control Fins", command=load_fins_control, width=20, fg="white", bg = "#B20000") update_fins_stabi_button.grid(row=10, column=3, sticky="N") def update_fins_control(): # Same as prev for i in range(len(draw_rocket_tab.entry)): draw_rocket_tab.points[2][i] = draw_rocket_tab.entry[i].get() draw_rocket_tab.draw_rocket() update_fins_control_button = tk.Button(draw_rocket_tab.tab, text="Update Control Fins", command=update_fins_control, width=20, fg="black", bg = "#FFACAC") update_fins_control_button.grid(row=12, column=3, sticky="N") def reset_fin(): # Populates the entries with a "0" area fin for i in range(len(draw_rocket_tab.entry)): draw_rocket_tab.entry[i].delete(0,15) zero_fin = ["0.0001,0.0","0.0001,0.0001","0.0002,0.0001","0.0002,0.0"] draw_rocket_tab.entry[i].insert(0, zero_fin[i]) draw_rocket_tab.draw_rocket() update_fins_control_button = tk.Button(draw_rocket_tab.tab, text="Reset Fin", command=reset_fin, width=12, fg="black", bg = "yellow") update_fins_control_button.grid(row=18, column=1, sticky="S") draw_rocket_tab.create_sliders() draw_rocket_tab.create_active_file_label(24, 0) draw_rocket_tab.configure()