def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure(text='''Tuning parameters, please wait...''') set_widget_to_left(self.instructions) # Page body loading_gif = LOADING_WINDOW_SETTINGS.get('LOADING_GIF') delay_between_frames = LOADING_WINDOW_SETTINGS.get('DELAY_BETWEEN_FRAMES') self.title_font = Font(family='Helvetica', size=12, weight="bold") self.loading_gif = AnimatedGif(self, loading_gif, delay_between_frames) self.loading_gif.place(relx=0.1, rely=0.35, height=330, width=600) self.clock_label = tk.Label(self, text="", font=self.title_font) self.clock_label.place(relx=0.38, rely=0.7, height=32, width=150) # Page footer self.stop_button = HoverButton(self, command=self.stop_model_process) self.stop_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.stop_button, text='''Stop''') self.back_button = HoverButton(self, command=self.back_window) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Back''') self.back_button.configure(state='disabled') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright) # Page logic self.loading_gif.start()
def __init__(self, parent=None, picks=[], editButtons=False, checkCallback=None): """ Parameters ---------- :param parent: the parent window :param picks: the list of pairs to show :param editButtons: Indicator whether a configuration button should be displayed :param checkCallback: Callback for each pair """ Frame.__init__(self, parent) self.parent = parent self.vars = [] self.checks = [] self.buttons = [] relY = 0 relX = 0 enable_functionality = 'active' # Iterate over all pairs of check buttons and buttons for pick in picks: var = IntVar() algorithm_show_function = self.get_algorithm_show_function( str(pick)) # Create a check button dynamically check_button = Checkbutton( self, text=pick, variable=var, state=enable_functionality, command=lambda: self.set_button_state(checkCallback)) check_button.place(relx=relX, rely=relY, height=30, width=150) set_widget_to_left(check_button) if editButtons: # Create a configuration button dynamically edit_button = HoverButton(self, text=pick + " configuration", state='disabled', command=algorithm_show_function) edit_button.place(relx=relX + 0.35, rely=relY, height=30, width=220) edit_button.configure(cursor="hand2") self.buttons.append(edit_button) self.vars.append(var) self.checks.append(check_button) relY = relY + 0.1
def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text= '''Please select the algorithms for which you want to build anomaly detection models.''' ) set_widget_to_left(self.instructions) # Page body self.anomaly_detection_methods = Checkbar( self, picks=load_anomaly_detection_list(), editButtons=True, checkCallback=self.set_algorithm_checked) self.anomaly_detection_methods.place(relx=0.1, rely=0.35, height=400, width=700) # Page footer self.next_button = HoverButton(self, command=self.next_window) self.next_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.next_button, text='''Next''') self.back_button = HoverButton( self, command=lambda: controller.show_frame("NewModel")) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Back''') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright)
def reinitialize(self): """ Reinitialize frame values and view :return: new frame view """ new_model_running = self.controller.get_new_model_running() if new_model_running: chosen_algorithms = list(self.controller.get_algorithms()) else: chosen_algorithms = list( self.controller.get_existing_algorithms().keys()) flight_routes = list(self.controller.get_flight_routes()) similarity_functions = list(self.controller.get_similarity_functions()) transformed_chosen_algorithms = transform_list(chosen_algorithms) transformed_flight_routes = transform_list(flight_routes) transformed_similarity_functions = transform_list(similarity_functions) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text= "Choose an algorithm and a flight route in order to get the results." ) set_widget_to_left(self.instructions) # Algorithm and Flight route permutation choice self.parameters = {} # set dynamic pair of label and combo box to select an algorithm set_widget_for_param(frame=self, text="Algorithm:", combobox_values=transformed_chosen_algorithms, param_key="algorithm", relative_x=0.05, y_coordinate=0.4) # set dynamic pair of label and combo box to select a flight route set_widget_for_param(frame=self, text="Flight route:", combobox_values=transformed_flight_routes, param_key="flight_route", relative_x=0.45, y_coordinate=0.4) # set dynamic pair of label and combo box to select a similarity function set_widget_for_param(frame=self, text="Similarity:", combobox_values=transformed_similarity_functions, param_key="similarity_function", relative_x=0.05, y_coordinate=0.45)
def show_model_process_label(self, y_coordinate, algorithm): """ Show model process label on the screen :param y_coordinate: y place coordinate :param algorithm: which algorithm to display :return: new label """ self.model_process_finished = tk.Label(self) self.model_process_finished.place(relx=0.015, rely=y_coordinate, height=22, width=215) self.model_process_finished.configure( text='''{0} model runs on the test...'''.format(algorithm)) set_widget_to_left(self.model_process_finished)
def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text='''Please select your choice for parameters tuning:''') set_widget_to_left(self.instructions) # Page body self.reinitialize() # Page footer self.next_button = HoverButton(self, command=self.next_window) self.next_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.next_button, text='''Next''') self.back_button = HoverButton(self, command=self.back_window) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Back''') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright)
def loading_process(self): """ Run chosen models and move to results window :return: results window """ similarity_score, test_data_path, results_path, new_model_running = self.controller.init_models( ) if new_model_running: chosen_algorithms = self.controller.get_algorithms() else: chosen_algorithms = set( self.controller.get_existing_algorithms().keys()) y_coordinate = 0.34 enumerate_details = 0 for algorithm in chosen_algorithms: if new_model_running: print_text = '''{0} : Creates a new model and runs the test data on it...'''.format( algorithm) else: print_text = '''{0} : Runs the test data...'''.format( algorithm) if enumerate_details < 4: self.algorithm_process_finished = tk.Label(self) self.algorithm_process_finished.place(relx=0.015, rely=y_coordinate, height=22, width=400) self.algorithm_process_finished.configure(text=print_text) set_widget_to_left(self.algorithm_process_finished) y_coordinate += 0.04 self.controller.run_models(algorithm, similarity_score, test_data_path, results_path, new_model_running, self.event) enumerate_details += 1 self.controller.reinitialize_frame("ResultsWindow")
def set_widget_for_param(frame, text, combobox_values, param_key, relative_x, y_coordinate): """ Sets a dynamic pair of label and combo box by given parameters :param frame: frame to work on :param text: label text :param combobox_values: possible values for the combo box :param param_key: the key for the pair which will be used in the frame :param relative_x: parent relative x :param y_coordinate: y-axis coordinate :return: dynamic pair of label and combo box """ try: # Create new label frame.algorithm_param = tk.Label(frame) frame.algorithm_param.place(relx=relative_x, rely=y_coordinate, height=25, width=100) frame.algorithm_param.configure(text=text) # Set the widget in the left side of the block set_widget_to_left(frame.algorithm_param) # Create new combo box - possible values for the label frame.algorithm_param_combo = ttk.Combobox(frame, state="readonly", values=combobox_values) frame.algorithm_param_combo.place(relx=relative_x + 0.12, rely=y_coordinate, height=25, width=160) frame.algorithm_param_combo.current(0) frame.parameters[param_key] = frame.algorithm_param_combo except Exception as e: # Handle an error with a stack trace print print("Source: gui/shared/helper_methods.py") print("Function: set_widget_for_param") print("error: " + str(e))
def reinitialize(self): """ Reinitialize frame values and view :return: new frame view """ self.path_label = tk.Label(self) self.path_label.place(relx=0.015, rely=0.4, height=32, width=146) self.path_label.configure(text='''Input file:''') set_widget_to_left(self.path_label) self.path_input = tk.Entry(self) self.path_input.place(relx=0.195, rely=0.4, height=25, relwidth=0.624) self.browse_btn = HoverButton(self, command=self.input_file_browse_command) self.browse_btn.place(relx=0.833, rely=0.4, height=25, width=60) set_button_configuration(self.browse_btn, text='''Browse''') # Results output directory self.results_path_label = tk.Label(self) self.results_path_label.place(relx=0.015, rely=0.5, height=32, width=146) self.results_path_label.configure(text='''Results directory:''') set_widget_to_left(self.results_path_label) self.results_path_input = tk.Entry(self) self.results_path_input.place(relx=0.195, rely=0.5, height=25, relwidth=0.624) self.results_browse_btn = HoverButton( self, command=self.results_browse_command) self.results_browse_btn.place(relx=0.833, rely=0.5, height=25, width=60) set_button_configuration(self.results_browse_btn, text='''Browse''')
def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text='''Please choose both input and target features:''') set_widget_to_left(self.instructions) # Page body # initialize features columns options self.features_columns_options = {} self.features_columns_options = self.get_features_columns_options() self.csv_features = tk.StringVar() self.csv_features.set(self.features_columns_options) self.features_instructions = tk.Label(self) self.features_instructions.place(relx=0.05, rely=0.34, height=22, width=100) self.features_instructions.configure(text='''Input features:''') set_widget_to_left(self.features_instructions) self.features_listbox = tk.Listbox( self, font=tkfont.Font(size=9), listvariable=self.csv_features, selectmode=tk.MULTIPLE, exportselection= 0, # Fix : ComboBox clears unrelated ListBox selection width=120, height=180, bd=3, bg='antique white', selectbackground='sandy brown') self.features_listbox.place(relx=0.05, rely=0.42, height=230, width=140) self.target_instructions = tk.Label(self) self.target_instructions.place(relx=0.35, rely=0.34, height=22, width=100) self.target_instructions.configure(text='''Target features:''') set_widget_to_left(self.target_instructions) self.target_features_listbox = tk.Listbox( self, font=tkfont.Font(size=9), listvariable=self.csv_features, selectmode=tk.MULTIPLE, exportselection=0, # Fix : ComboBox clears unrelated ListBox selection width=120, height=180, bd=3, bg='antique white', selectbackground='sandy brown') self.target_features_listbox.place(relx=0.35, rely=0.42, height=230, width=140) # Side logo feature_selection_logo = CROSS_WINDOWS_SETTINGS.get( 'FEATURE_SELECTION') feature_selection_photo_location = os.path.join(feature_selection_logo) global fs_logo_img fs_logo_img = tk.PhotoImage(file=feature_selection_photo_location) self.features_logo_png = tk.Button(self) self.features_logo_png.place(relx=0.6, rely=0.28, height=200, width=200) set_logo_configuration(self.features_logo_png, image=fs_logo_img) # Page footer self.next_button = HoverButton(self, command=self.next_window) self.next_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.next_button, text='''Next''') self.back_button = HoverButton(self, command=self.back_window) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Back''') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright)
def reinitialize(self): """ Reinitialize frame values and view :return: new frame view """ self.features_columns_options = {} self.features_columns_options = self.get_features_columns_options() self.csv_features = tk.StringVar() self.csv_features.set(self.features_columns_options) self.input_indicator = False self.target_indicator = False self.select_all_features_button = tk.Button( self, command=self.select_all_features) self.select_all_features_button.place(relx=0.17, rely=0.38, height=18, width=55) set_button_configuration(self.select_all_features_button, text='''Select all''') self.select_all_features_button.configure(bg='sandy brown') self.features_listbox = tk.Listbox( self, font=tkfont.Font(size=9), listvariable=self.csv_features, selectmode=tk.MULTIPLE, exportselection= 0, # Fix : ComboBox clears unrelated ListBox selection width=120, height=180, bd=3, bg='antique white', selectbackground='sandy brown') self.features_listbox.place(relx=0.05, rely=0.42, height=230, width=140) self.select_all_target_button = tk.Button( self, command=self.select_all_target) self.select_all_target_button.place(relx=0.47, rely=0.38, height=18, width=55) set_button_configuration(self.select_all_target_button, text='''Select all''') self.select_all_target_button.configure(bg='sandy brown') self.target_features_listbox = tk.Listbox( self, listvariable=self.csv_features, font=tkfont.Font(size=9), selectmode=tk.MULTIPLE, exportselection=0, # Fix : ComboBox clears unrelated ListBox selection width=120, height=180, bd=3, bg='antique white', selectbackground='sandy brown') self.target_features_listbox.place(relx=0.35, rely=0.42, height=230, width=140) title_styling = Font(size=11, weight=BOLD) self.previous_choice_label = tk.Label(self) self.previous_choice_label.place(relx=0.58, rely=0.62, height=25, width=300) self.previous_choice_label.configure(text="Your previous selections:", font=title_styling, fg='blue') set_widget_to_left(self.previous_choice_label) chosen_algorithms = self.controller.get_algorithms() y_coordinate = 0.66 for algorithm in chosen_algorithms: window_size = self.controller.get_window_size(algorithm) self.algorithm_label = tk.Label(self) self.algorithm_label.place(relx=0.58, rely=y_coordinate, height=25, width=300) self.algorithm_label.configure(text="{0} window size: {1}".format( algorithm, window_size), font=Font(size=10), fg='blue') set_widget_to_left(self.algorithm_label) y_coordinate += 0.04
def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text= '''Please choose similarity functions from the following options.''' ) set_widget_to_left(self.instructions) # Page body self.similarity_functions = Checkbar( self, load_similarity_list(), checkCallback=self.set_similarity_score) self.similarity_functions.place(relx=0.1, rely=0.36, height=400, width=700) self.save_model_var = tk.IntVar() self.save_model_check_button = tk.Checkbutton( self, text="Save model", variable=self.save_model_var, command=self.set_saving_model) self.note = tk.Label(self) self.note.place(relx=0.015, rely=0.7, height=32, width=635) self.note.configure( text= '''Note: Similarity function is used for calculating a score for each record''', font=Font(size=9, weight=BOLD)) set_widget_to_left(self.note) # Page footer self.next_button = HoverButton(self, command=self.next_window) self.next_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.next_button, text='''Run''') self.back_button = HoverButton(self, command=self.back_window) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Back''') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright)
def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text='''Please insert input files for existing model.''') set_widget_to_left(self.instructions) # Page body # Testing input directory self.test_label = tk.Label(self) self.test_label.place(relx=0.015, rely=0.4, height=32, width=146) self.test_label.configure(text='''Test directory''') set_widget_to_left(self.test_label) self.test_input = tk.Entry(self) self.test_input.place(relx=0.195, rely=0.4, height=25, relwidth=0.624) self.test_btn = HoverButton(self, command=self.set_test_path) self.test_btn.place(relx=0.833, rely=0.4, height=25, width=60) set_button_configuration(self.test_btn, text='''Browse''') # Results output directory self.results_label = tk.Label(self) self.results_label.place(relx=0.015, rely=0.5, height=32, width=146) self.results_label.configure(text='''Results directory''') set_widget_to_left(self.results_label) self.results_input = tk.Entry(self) self.results_input.place(relx=0.195, rely=0.5, height=25, relwidth=0.624) self.results_btn = HoverButton(self, command=self.set_results_path) self.results_btn.place(relx=0.833, rely=0.5, height=25, width=60) set_button_configuration(self.results_btn, text='''Browse''') # Page footer self.next_button = HoverButton(self, command=self.next_window) self.next_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.next_button, text='''Next''') self.back_button = HoverButton(self, command=self.back_window) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Back''') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright)
def reinitialize_results_table(self): """ Reinitialize results table and view :return: new frame view """ try: # Handle suitable flow new_model_running = self.controller.get_new_model_running() if new_model_running: chosen_algorithms = list(self.controller.get_algorithms()) else: chosen_algorithms = list( self.controller.get_existing_algorithms().keys()) flight_routes = list(self.controller.get_flight_routes()) similarity_functions = list( self.controller.get_similarity_functions()) # selected values with transformation to UI components selected_algorithm = self.controller.get_results_selected_algorithm( ) selected_flight_route = self.controller.get_results_selected_flight_route( ) selected_similarity_function = self.controller.get_results_selected_similarity_function( ) original_algorithm = "" for algorithm in chosen_algorithms: if trim_unnecessary_chars( algorithm).lower() == selected_algorithm.lower(): original_algorithm = algorithm original_flight_route = "" for route in flight_routes: if trim_unnecessary_chars( route).lower() == selected_flight_route.lower(): original_flight_route = route original_similarity_function = "" for similarity_function in similarity_functions: if trim_unnecessary_chars(similarity_function).lower( ) == selected_similarity_function.lower(): original_similarity_function = similarity_function current_title = 'Test set attacks comparison table' self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.29, height=35, width=635) self.instructions.configure(text=current_title) set_widget_to_left(self.instructions) results_data = self.controller.get_results_metrics_data() data = results_data[original_algorithm][original_flight_route][ original_similarity_function] attacks_columns = list(data.values())[0] transform_attacks_list = transform_list( list(attacks_columns.keys())) table_columns = self.generate_table_columns_list( transform_attacks_list) self.results_table.pack_forget() # self.results_table.destroy() self.results_table = Table(self, columns=table_columns, header_anchor=CENTER, column_minwidths=[1, 1, 1], pady=2) self.results_table.pack(fill=X, padx=18, pady=182) # Creates a 2D array, all set to 0 rows = len(data.keys()) + 2 columns = len(attacks_columns) zero_matrix = [[0 for i in xrange(columns)] for i in xrange(rows)] self.results_table.set_data(zero_matrix) # Set the updated values to the table for i, metric in enumerate(data.keys()): attacks_data = data[metric] if metric.upper() == 'DELAY': self.results_table.cell(i, 0, metric.upper() + " [sec]") else: self.results_table.cell(i, 0, metric.upper()) for j, attack in enumerate(attacks_data.keys()): self.results_table.cell(i, j + 1, attacks_data[attack]) self.results_table.cell(rows - 2, 0, "Attack duration [sec]") for i in range(1, columns + 1): self.results_table.cell( rows - 2, i, str( float(results_data[original_algorithm] [original_flight_route][ list(attacks_columns.keys())[i - 1] + "_attack_duration"]))) self.results_table.cell(rows - 1, 0, "Flight duration [sec]") for i in range(1, columns + 1): self.results_table.cell( rows - 1, i, str( float(results_data[original_algorithm] [original_flight_route][ list(attacks_columns.keys())[i - 1] + "_duration"]))) permutation_styling = Font(family="Times New Roman", size=11, weight=BOLD) self.algorithm_label = tk.Label(self) self.algorithm_label.place(relx=0.015, rely=0.68, height=25, width=300) self.algorithm_label.configure( text="Algorithm: {0}".format(selected_algorithm), font=permutation_styling, fg='blue') set_widget_to_left(self.algorithm_label) self.similarity_function_label = tk.Label(self) self.similarity_function_label.place(relx=0.015, rely=0.72, height=25, width=300) self.similarity_function_label.configure( text="Similarity function: {0}".format( selected_similarity_function), font=permutation_styling, fg='blue') set_widget_to_left(self.similarity_function_label) self.route_label = tk.Label(self) self.route_label.place(relx=0.015, rely=0.76, height=25, width=300) self.route_label.configure( text="Flight route: {0}".format(selected_flight_route), font=permutation_styling, fg='blue') set_widget_to_left(self.route_label) except Exception as e: # Handle error in setting new data in the table print("Source: gui/windows/results_table_window.py") print("Function: reinitialize_results_table") print("error: " + str(e))
def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text='''Please insert paths for existing models.''') set_widget_to_left(self.instructions) # Page body self.algorithms = dict() self.browse_buttons = dict() self.input_entries = dict() # LSTM existing algorithm self.lstm_var = tk.IntVar() self.lstm_check_button = tk.Checkbutton(self) self.lstm_check_button.place(relx=0.015, rely=0.38, height=32, width=146) self.lstm_check_button.configure(text="LSTM", variable=self.lstm_var, command=lambda: self.set_input_entry("LSTM", self.lstm_var.get())) set_widget_to_left(self.lstm_check_button) self.lstm_input = tk.Entry(self) self.lstm_input.place(relx=0.195, rely=0.38, height=25, relwidth=0.624) self.lstm_input.configure(state='disabled') self.lstm_btn = HoverButton(self, command=lambda: self.set_algorithm_path("LSTM")) self.lstm_btn.place(relx=0.833, rely=0.38, height=25, width=60) self.lstm_btn.configure(state='disabled') set_button_configuration(self.lstm_btn, text='''Browse''') self.browse_buttons["LSTM"] = self.lstm_btn self.input_entries["LSTM"] = self.lstm_input # SVR existing algorithm self.svr_var = tk.IntVar() self.svr_check_button = tk.Checkbutton(self) self.svr_check_button.place(relx=0.015, rely=0.47, height=32, width=146) self.svr_check_button.configure(text="SVR", variable=self.svr_var, command=lambda: self.set_input_entry("SVR", self.svr_var.get())) set_widget_to_left(self.svr_check_button) self.svr_input = tk.Entry(self) self.svr_input.place(relx=0.195, rely=0.47, height=25, relwidth=0.624) self.svr_input.configure(state='disabled') self.svr_btn = HoverButton(self, command=lambda: self.set_algorithm_path("SVR")) self.svr_btn.place(relx=0.833, rely=0.47, height=25, width=60) self.svr_btn.configure(state='disabled') set_button_configuration(self.svr_btn, text='''Browse''') self.browse_buttons["SVR"] = self.svr_btn self.input_entries["SVR"] = self.svr_input # MLP existing algorithm self.mlp_var = tk.IntVar() self.mlp_check_button = tk.Checkbutton(self) self.mlp_check_button.place(relx=0.015, rely=0.56, height=32, width=146) self.mlp_check_button.configure(text="MLP", variable=self.mlp_var, command=lambda: self.set_input_entry("MLP", self.mlp_var.get())) set_widget_to_left(self.mlp_check_button) self.mlp_input = tk.Entry(self) self.mlp_input.place(relx=0.195, rely=0.56, height=25, relwidth=0.624) self.mlp_input.configure(state='disabled') self.mlp_btn = HoverButton(self, command=lambda: self.set_algorithm_path("MLP")) self.mlp_btn.place(relx=0.833, rely=0.56, height=25, width=60) self.mlp_btn.configure(state='disabled') set_button_configuration(self.mlp_btn, text='''Browse''') self.browse_buttons["MLP"] = self.mlp_btn self.input_entries["MLP"] = self.mlp_input # Random Forest existing algorithm self.random_forest_var = tk.IntVar() self.random_forest_check_button = tk.Checkbutton(self) self.random_forest_check_button.place(relx=0.015, rely=0.65, height=32, width=146) self.random_forest_check_button.configure(text="Random Forest", variable=self.random_forest_var, command=lambda: self.set_input_entry("Random Forest", self.random_forest_var.get())) set_widget_to_left(self.random_forest_check_button) self.random_forest_input = tk.Entry(self) self.random_forest_input.place(relx=0.195, rely=0.65, height=25, relwidth=0.624) self.random_forest_input.configure(state='disabled') self.random_forest_btn = HoverButton(self, command=lambda: self.set_algorithm_path("Random Forest")) self.random_forest_btn.place(relx=0.833, rely=0.65, height=25, width=60) self.random_forest_btn.configure(state='disabled') set_button_configuration(self.random_forest_btn, text='''Browse''') self.browse_buttons["Random Forest"] = self.random_forest_btn self.input_entries["Random Forest"] = self.random_forest_input # Page footer self.next_button = HoverButton(self, command=self.next_window) self.next_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.next_button, text='''Next''') self.back_button = HoverButton(self, command=self.back_window) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Back''') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright)
def __init__(self, parent, controller): """ Parameters ---------- :param parent: window :param controller: GUI controller """ tk.Frame.__init__(self, parent) # Page init self.controller = controller self.menubar = Menubar(controller) # Disables ability to tear menu bar into own window self.controller.option_add('*tearOff', 'FALSE') system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO') photo_location = os.path.join(system_logo) global logo_img logo_img = tk.PhotoImage(file=photo_location) # Page header self.logo_png = tk.Button(self) self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300) set_logo_configuration(self.logo_png, image=logo_img) self.instructions = tk.Label(self) self.instructions.place(relx=0.015, rely=0.3, height=32, width=635) self.instructions.configure( text= '''Please select the values for each of the following parameters:''' ) set_widget_to_left(self.instructions) # Page body # Dynamic algorithm options self.algorithms_files = load_anomaly_detection_list() self.current_algorithm = self.controller.get_current_algorithm_to_edit( ) self.current_yaml = self.set_suitable_yaml_file(self.current_algorithm) self.height_options_frame = 268 self.width_options_frame = 620 self.options_to_show = AlgorithmFrameOptions( self, yaml_filename=self.current_yaml) self.options_to_show.place(relx=0.05, rely=0.35, height=self.height_options_frame, width=self.width_options_frame) # Page footer self.next_button = HoverButton(self, command=self.handle_next_button) self.next_button.place(relx=0.813, rely=0.839, height=25, width=81) set_button_configuration(self.next_button, text='''Save''') self.back_button = HoverButton( self, command=lambda: self.controller.show_frame("AlgorithmsWindow")) self.back_button.place(relx=0.017, rely=0.839, height=25, width=81) set_button_configuration(self.back_button, text='''Cancel''') self.copyright = tk.Label(self) self.copyright.place(relx=0, rely=0.958, height=25, width=750) set_copyright_configuration(self.copyright)
def set_widget_for_param(frame, text, combobox_values, param_key, y_coordinate, filename): """ Sets a dynamic pair of label and combo box by given parameters :param frame: frame to work on :param text: label text :param combobox_values: possible values for the combo box :param param_key: the key for the pair which will be used in the frame :param y_coordinate: y-axis coordinate :param filename: the name of the algorithm :return: dynamic pair of label and combo box """ relative_x = 0 try: # Creating a photo image object to use for information button info_dir = CROSS_WINDOWS_SETTINGS.get('INFORMATION_DIR') info_file = CROSS_WINDOWS_SETTINGS.get('INFORMATION_FILE') base_folder = os.path.dirname(__file__) dir_path = os.path.join(base_folder, info_dir) photo_location = os.path.join(dir_path, info_file) global info_photo info_photo = tk.PhotoImage(file=photo_location) # frame.info_png_img = tk.PhotoImage(file=photo_location) # Create new label frame.algorithm_param = tk.Label(frame) frame.algorithm_param.place(relx=relative_x, rely=y_coordinate, height=25, width=150) frame.algorithm_param.configure(text=text) # Set the widget in the left side of the block set_widget_to_left(frame.algorithm_param) i_styling = Font(family="Times New Roman", size=12, weight=BOLD, slant=ITALIC) frame.algorithm_param_info_button = tk.Button( frame, text="i", bg="sky blue", font=i_styling, command=lambda: on_info_button_click( attribute=text, filename=filename.replace('_params', ''))) frame.algorithm_param_info_button.configure(cursor="hand2") frame.algorithm_param_info_button.place(relx=relative_x + 0.25, rely=y_coordinate, height=25, width=25) # frame.algorithm_param_info_button.configure(image=info_photo) # set_info_configuration(frame.algorithm_param_info_button, image=info_photo) # Create new combo box - possible values for the label frame.algorithm_param_combo = Combobox(frame, state="readonly", values=combobox_values) frame.algorithm_param_combo.place(relx=relative_x + 0.35, rely=y_coordinate, height=25, width=150) frame.algorithm_param_combo.current(0) frame.parameters[param_key] = frame.algorithm_param_combo except Exception as e: # Handle an error with a stack trace print print("Source: gui/algorithm_frame_options/shared/helper_methods.py") print("Function: set_widget_for_param") print("error: " + str(e))