예제 #1
0
    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')
        comparison_logo = CROSS_WINDOWS_SETTINGS.get('RESULTS')
        photo_location = os.path.join(system_logo)
        comparison_location = os.path.join(comparison_logo)
        global logo_img, comparison_img
        logo_img = tk.PhotoImage(file=photo_location)
        comparison_img = tk.PhotoImage(file=comparison_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)

        # Page body
        self.results_table = Table(self,
                                   columns=[
                                       "Metric", "Down attack", "Up attack",
                                       "Fore attack", "Random attack"
                                   ],
                                   header_anchor=CENTER,
                                   column_minwidths=[1, 1, 1],
                                   pady=2)
        self.results_table.pack(fill=X, padx=18, pady=182)

        self.comparison_png = tk.Button(self)
        self.comparison_png.place(relx=0.65, rely=0.7, height=150, width=145)
        set_logo_configuration(self.comparison_png, image=comparison_img)

        # Page footer
        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)
예제 #2
0
    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, yaml_filename=None):
        """
        Parameters
        ----------

        parent : ParametersOptionsWindow
            The parent window which controls the current frame

        yaml_filename : str
            The file which suits a specific algorithm in order to construct the frame

        """

        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.parameters = {}

        # Load all constant for a given algorithm
        self.parameters_lists = load_algorithm_constants(yaml_filename)
        self.parameters_lists_keys = list(self.parameters_lists.keys())

        # Set values for frame construction
        self.values_lists = []
        for key in self.parameters_lists_keys:
            self.values_lists.append(self.parameters_lists.get(key))

        # Pop keys of each list
        self.params_texts = self.values_lists.pop(0)
        self.params_keys = self.values_lists.pop(0)

        y_val = 0
        y_delta = 0.14

        index = 0

        # Create dynamic pairs of label and combo box for each algorithm param
        for param_description in self.params_texts:
            # Set generic param with suitable values according to suitable yaml file
            set_widget_for_param(frame=self,
                                 text=param_description,
                                 combobox_values=self.values_lists[index],
                                 param_key=self.params_keys[index],
                                 y_coordinate=y_val,
                                 filename=yaml_filename)
            y_val += y_delta
            index += 1

        # Side logo
        param_options_logo = CROSS_WINDOWS_SETTINGS.get('PARAMETERS_OPTIONS')
        param_options_photo_location = os.path.join(param_options_logo)
        global po_logo_img
        po_logo_img = tk.PhotoImage(file=param_options_photo_location)

        self.parameters_logo_png = tk.Button(self)
        self.parameters_logo_png.place(relx=0.75, rely=0.22, height=140, width=140)
        set_logo_configuration(self.parameters_logo_png, image=po_logo_img)
    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 = HoverButton(self)
        self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300)
        set_logo_configuration(self.logo_png, image=logo_img)

        # Page body
        self.toggle_results_button = HoverButton(self,
                                                 command=self.toggle_results)
        self.toggle_results_button.place(relx=0.68,
                                         rely=0.5,
                                         height=25,
                                         width=81)
        set_button_configuration(self.toggle_results_button,
                                 text='''Show results''')

        # Page footer
        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='''Home page''')

        self.copyright = tk.Label(self)
        self.copyright.place(relx=0, rely=0.958, height=25, width=750)
        set_copyright_configuration(self.copyright)
예제 #5
0
    def __init__(self, parent, controller):
        """
        Parameters
        ----------

        :param parent: window
        :param controller: GUI controller
        """

        ttk.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')
        bgu_logo = CROSS_WINDOWS_SETTINGS.get('BGU')
        israel_innovation_authority_logo = CROSS_WINDOWS_SETTINGS.get(
            'ISRAEL_INNOVATION_AUTHORITY')
        ministry_of_defense_logo = CROSS_WINDOWS_SETTINGS.get(
            'MINISTRY_OF_DEFENSE')
        mobilicom_logo = CROSS_WINDOWS_SETTINGS.get('MOBILICOM')

        photo_location = os.path.join(system_logo)
        bgu_location = os.path.join(bgu_logo)
        israel_innovation_authority_location = os.path.join(
            israel_innovation_authority_logo)
        ministry_of_defense_location = os.path.join(ministry_of_defense_logo)
        mobilicom_location = os.path.join(mobilicom_logo)

        global logo_img, bgu_img, israel_innovation_authority_img, ministry_of_defense_img, mobilicom_img

        logo_img = tk.PhotoImage(file=photo_location)
        bgu_img = tk.PhotoImage(file=bgu_location)
        israel_innovation_authority_img = tk.PhotoImage(
            file=israel_innovation_authority_location)
        ministry_of_defense_img = tk.PhotoImage(
            file=ministry_of_defense_location)
        mobilicom_img = tk.PhotoImage(file=mobilicom_location)

        self.controller.geometry("700x550")
        self.controller.minsize(700, 550)
        self.controller.maxsize(700, 550)
        self.controller.resizable(1, 1)
        self.controller.title("Anomaly Detection System")
        self.controller.configure(background="#eeeeee")

        # 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)

        # Page body
        self.create_model_btn = HoverButton(self, command=self.new_flow)
        self.create_model_btn.place(relx=0.41, rely=0.35, height=42, width=120)
        set_button_configuration(self.create_model_btn,
                                 text='''Create model''')

        self.load_model_btn = HoverButton(self, command=self.load_flow)
        self.load_model_btn.place(relx=0.41, rely=0.52, height=42, width=120)
        set_button_configuration(self.load_model_btn, text='''Load model''')

        # self.tune_model_btn = HoverButton(self, command=self.tune_flow)
        # self.tune_model_btn.place(relx=0.395, rely=0.65, height=42, width=140)
        # set_button_configuration(self.tune_model_btn, text='''Tune model parameters''')

        self.bgu_png = tk.Button(self)
        self.bgu_png.place(relx=0, rely=0, height=35, width=186)
        set_logo_configuration(self.bgu_png, image=bgu_img)

        self.israel_innovation_authority_png = tk.Button(self)
        self.israel_innovation_authority_png.place(relx=0.04,
                                                   rely=0.78,
                                                   height=61,
                                                   width=200)
        set_logo_configuration(self.israel_innovation_authority_png,
                               image=israel_innovation_authority_img)

        self.ministry_of_defense_png = tk.Button(self)
        self.ministry_of_defense_png.place(relx=0.7,
                                           rely=0.67,
                                           height=119,
                                           width=136)
        set_logo_configuration(self.ministry_of_defense_png,
                               image=ministry_of_defense_img)

        self.mobilicom_png = tk.Button(self)
        self.mobilicom_png.place(relx=0.41, rely=0.75, height=116, width=116)
        set_logo_configuration(self.mobilicom_png, image=mobilicom_img)

        # Page footer
        self.copyright = tk.Label(self)
        self.copyright.place(relx=0, rely=0.958, height=25, width=750)
        set_copyright_configuration(self.copyright)
예제 #6
0
    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)
예제 #7
0
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))