示例#1
0
def new_build_screen_start() -> None:
    # Build title label
    screen_start.build_title_label(text="Fixed Gas GC Data Aggregator",
                                   font=('arial', 15, 'bold'))

    child_container_start_menu = gb.ChildContainer(screen_start)

    # Button for Data Aggregator Config Form
    button_screen_data_agg_config_form = gb.WidgetBuilder(
        child_container_start_menu,
        tk.Button,
        text="Aggregate Data",
        command=lambda: application.show_screen(screen_data_agg_config_form))

    button_screen_data_agg_config_form.set_placement_settings(sticky="ew",
                                                              pady=1)

    child_container_start_menu.new_build_row(
        button_screen_data_agg_config_form)

    # Button for Config File Builder
    button_screen_config_file_builder = gb.WidgetBuilder(
        child_container_start_menu,
        tk.Button,
        text="Build Config File",
        command=lambda: application.show_screen(screen_config_file_builder))

    button_screen_config_file_builder.set_placement_settings(sticky="ew",
                                                             pady=1)

    child_container_start_menu.new_build_row(button_screen_config_file_builder)

    # Button for Help Screen
    button_screen_help = gb.WidgetBuilder(
        child_container_start_menu,
        tk.Button,
        text="Help",
        command=lambda: application.show_screen(screen_help))

    button_screen_help.set_placement_settings(sticky="ew", pady=1)

    child_container_start_menu.new_build_row(button_screen_help)

    # Button Quit
    button_quit = gb.WidgetBuilder(
        child_container_start_menu,
        tk.Button,
        text="Quit",
        command=lambda: application.close_application())

    button_quit.set_placement_settings(sticky="ew", pady=1)

    child_container_start_menu.new_build_row(button_quit)
示例#2
0
def build_screen_help() -> None:
    screen_help.build_title_label(text="Help", font=('arial', 15, 'bold'))

    child_container_help_messages = gb.ChildContainer(screen_help)

    # Create a child container for the help messages
    child_container_help_messages.set_pack_options(fill=tk.X)
    child_container_help_messages.config_column(0, weight=1)

    # LabelFrame for Data Aggregator help section
    labelframe_data_aggregator = gb.WidgetBuilder(
        child_container_help_messages, tk.LabelFrame, text="Data Aggregator")

    labelframe_data_aggregator.set_placement_settings(sticky="ew", padx=5)

    label_data_aggregator = tk.Label(labelframe_data_aggregator.widget_object,
                                     text="Coming Soon!",
                                     justify=tk.LEFT)

    label_data_aggregator.pack(side=tk.LEFT)

    child_container_help_messages.new_build_row(labelframe_data_aggregator)

    labelframe_config_file_builder = gb.WidgetBuilder(
        child_container_help_messages,
        tk.LabelFrame,
        text="Config File Builder")

    label_config_file_builder = tk.Label(
        labelframe_config_file_builder.widget_object,
        text="Coming Soon!",
        justify=tk.LEFT)

    labelframe_config_file_builder.set_placement_settings(sticky="ew",
                                                          padx=5,
                                                          pady=10)

    label_config_file_builder.pack(side=tk.LEFT)

    child_container_help_messages.new_build_row(labelframe_config_file_builder)

    screen_help.build_back_button(screen_start)
示例#3
0
def new_build_screen_data_agg_config_form() -> None:
    # Build the Screen Title
    screen_data_agg_config_form.build_title_label(
        text="Data Aggregator: Configuration Settings",
        font=('arial', 15, 'bold'))

    # CHILD CONTAINER 1: FORM ENTRY
    # Create a child container for the Form entry
    child_container_form_input = gb.ChildContainer(screen_data_agg_config_form)
    child_container_form_input.set_pack_options(fill=tk.X)

    # Column configure
    child_container_form_input.config_column(1, weight=3)

    # ROW 1: CONFIG FILE
    # Label
    label_config_file = gb.WidgetBuilder(child_container_form_input,
                                         tk.Label,
                                         text="Config File:")

    label_config_file.set_placement_settings(sticky="e")

    # Entry
    entry_config_file = gb.WidgetBuilder(child_container_form_input, tk.Entry)

    entry_config_file.set_placement_settings(sticky="ew")

    # Button
    button_config_file = gb.WidgetBuilder(
        child_container_form_input,
        tk.Button,
        text="Browse",
        command=lambda: set_entry_value(entry_config_file.widget_object,
                                        get_file_path(), 0, True))

    button_config_file.set_placement_settings(padx=5)

    # Build row
    child_container_form_input.new_build_row(label_config_file,
                                             entry_config_file,
                                             button_config_file)

    # ROW 2: INPUT DIRECTORY
    # Label
    label_input_directory = gb.WidgetBuilder(child_container_form_input,
                                             tk.Label,
                                             text="Input Folder:")

    label_input_directory.set_placement_settings(sticky="e")

    # Entry
    entry_input_directory = gb.WidgetBuilder(child_container_form_input,
                                             tk.Entry)

    entry_input_directory.set_placement_settings(sticky="ew")

    # Button
    button_input_directory = gb.WidgetBuilder(
        child_container_form_input,
        tk.Button,
        text="Browse",
        command=lambda: set_entry_value(entry_input_directory.widget_object,
                                        get_dir_path(), 0, True))

    button_input_directory.set_placement_settings(padx=5)

    # Build Row:
    child_container_form_input.new_build_row(label_input_directory,
                                             entry_input_directory,
                                             button_input_directory)

    # CHILD CONTAINER 2: END FORM
    child_container_form_end = gb.ChildContainer(screen_data_agg_config_form)

    child_container_form_end.set_pack_options(side=tk.RIGHT, pady=10)

    # Button: Clear
    def clear() -> None:
        # Clear stored UI values:
        input_form_ui.config_file_path_str = None
        input_form_ui.input_dir_path_str = None

        # Clear each entry
        entry_config_file.widget_object.delete(0, tk.END)
        entry_input_directory.widget_object.delete(0, tk.END)

        print("Form was cleared!")

    button_end_form_clear = gb.WidgetBuilder(child_container_form_end,
                                             tk.Button,
                                             text="Clear",
                                             command=lambda: clear())

    button_end_form_clear.set_placement_settings(padx=5)

    # Button: Submit
    def submit() -> None:
        # Reset UI error values:
        input_form_ui.config_file_path_input_error = False
        input_form_ui.input_dir_input_error = False

        # Set Input Form UI Variables
        input_form_ui.config_file_path_str = entry_config_file.widget_object.get(
        )
        input_form_ui.input_dir_path_str = entry_input_directory.widget_object.get(
        )

        # Check if all required entries were filled
        if input_form_ui.config_file_path_input_error or input_form_ui.input_dir_input_error:
            # Don't allow user to continue
            messagebox.showwarning(
                title="Required Input Missing",
                message="Please fill out all required fields!")

            # Don't submit
            return

        # Store the input values to the global_string_var
        global_string_var.set(
            f"\nConfig File:\t{input_form_ui.config_file_path_str}"
            f"\nInput Folder:\t{input_form_ui.input_dir_path_str}")

        application.update_idletasks()

        # Confirm Form Submitted
        print("Form was submitted!")

        # Go to the info confirmation screen
        application.show_screen(screen_data_agg_input_confirmation)

    button_end_form_submit = gb.WidgetBuilder(child_container_form_end,
                                              tk.Button,
                                              text="Submit",
                                              command=lambda: submit())

    button_end_form_submit.set_placement_settings(padx=5)

    # Build row
    child_container_form_end.new_build_row(button_end_form_clear,
                                           button_end_form_submit)

    # BACK BUTTON
    screen_data_agg_config_form.build_back_button(screen_start)
示例#4
0
    def build_gui(self, screen: "gb.ScreenContainer") -> None:
        # Build Child Containers:
        # 1) Child Container: Report File
        child_container_report_file = gb.ChildContainer(screen)

        child_container_report_file.set_pack_options(fill=tk.X, padx=5)

        # Label: Report File
        label_report_file = gb.WidgetBuilder(child_container_report_file,
                                             tk.Label,
                                             text="Report File:")

        label_report_file.set_placement_settings(sticky="w")

        # Entry: Report File Name
        self.entry_report_file_name = gb.WidgetBuilder(
            child_container_report_file, tk.Entry)

        # Label: Report File Ext
        label_report_file_ext = gb.WidgetBuilder(child_container_report_file,
                                                 tk.Label,
                                                 text=".")

        label_report_file_ext.set_placement_settings(padx=1)

        # ComboBox: File Ext
        self.combobox_report_file_ext = gb.WidgetBuilder(
            child_container_report_file,
            ttk.Combobox,
            values=("xls", "xlsx", "csv"),
            width=4,
            state='readonly')

        self.combobox_report_file_ext.set_placement_settings(padx=1)

        child_container_report_file.new_build_row(
            label_report_file, self.entry_report_file_name,
            label_report_file_ext, self.combobox_report_file_ext)

        # 2) Notebook section label
        child_container_datasheets_section_label = gb.ChildContainer(screen)

        child_container_datasheets_section_label.set_pack_options(fill=tk.X,
                                                                  padx=5)

        # Label: Datasheets Section
        label_datasheets_section = gb.WidgetBuilder(
            child_container_datasheets_section_label,
            tk.Label,
            text="Datasheets")

        # Button: Add Datasheet
        button_add_datasheets = gb.WidgetBuilder(
            child_container_datasheets_section_label,
            tk.Button,
            text="+",
            width=2,
            command=lambda: self.add_datasheet_gui())

        button_add_datasheets.set_placement_settings(padx=1)

        child_container_datasheets_section_label.new_build_row(
            label_datasheets_section, button_add_datasheets)

        # 3) Child Container: Datasheets Notebook
        child_container_datasheets_notebook = gb.ChildContainer(screen)

        child_container_datasheets_notebook.set_pack_options(fill=tk.X, padx=5)

        # Notebook:
        self.notebook_datasheets = gb.WidgetBuilder(
            child_container_datasheets_notebook, ttk.Notebook)

        self.notebook_datasheets.set_placement_settings(fill=tk.X)

        child_container_datasheets_notebook.pack_widget(
            self.notebook_datasheets)

        # 4) Child Container: Submit
        child_container_submit = gb.ChildContainer(screen)

        child_container_submit.set_pack_options(side=tk.RIGHT, padx=5)

        # Button: Clear
        button_clear = gb.WidgetBuilder(child_container_submit,
                                        tk.Button,
                                        text="Clear",
                                        command=lambda: self.refresh())

        button_clear.set_placement_settings(padx=5)

        # Button: Submit
        button_submit = gb.WidgetBuilder(child_container_submit,
                                         tk.Button,
                                         text="Submit",
                                         command=lambda: self.submit())

        button_submit.set_placement_settings(padx=5)

        # Button: Download
        self.button_download = gb.WidgetBuilder(
            child_container_submit,
            tk.Button,
            text="Download",
            state=tk.DISABLED,
            command=lambda: self.download())

        self.button_download.set_placement_settings(padx=5)

        # self.child_container_submit.pack_widget(button_submit)
        child_container_submit.new_build_row(button_clear, button_submit,
                                             self.button_download)
示例#5
0
def build_screen_data_import() -> None:
    # Build Title Label
    screen_data_import.build_title_label(text="Importing Data",
                                         font=('arial', 15, 'bold'))

    child_container_loading_status = gb.ChildContainer(screen_data_import)

    child_container_loading_status.config_column(0, weight=1)

    label_loading_status = gb.WidgetBuilder(child_container_loading_status,
                                            tk.Label,
                                            textvariable=global_string_var)

    child_container_loading_status.new_build_row(label_loading_status)

    child_container_loading_status.set_pack_options(fill=tk.X)

    progress_bar_upload = gb.WidgetBuilder(child_container_loading_status,
                                           ttk.Progressbar,
                                           mode='determinate',
                                           orient=tk.HORIZONTAL)

    progress_bar_upload.set_placement_settings(sticky="ew", padx=5)

    child_container_loading_status.new_build_row(progress_bar_upload)

    # Action Buttons
    child_container_action_buttons = gb.ChildContainer(screen_data_import)

    # child_container_action_buttons.config_column(0, weight=1)

    child_container_action_buttons.set_pack_options(fill=tk.X, pady=10)

    # Download Buttons
    button_download = gb.WidgetBuilder(child_container_action_buttons,
                                       tk.Button,
                                       text="Download File",
                                       state=tk.DISABLED,
                                       command=lambda: download())

    button_download.set_placement_settings(padx=5)

    def progress_update(file_num) -> None:
        # Set the progress value equal to the file number processed
        progress_bar_upload.widget_object['value'] += 1
        global_string_var.set(
            f"{file_num} out of {global_int_var.get()} files uploaded...")

        application.update_idletasks()

    def upload() -> None:
        # Dedicate thread to uploading data
        thread_upload = threading.Thread(target=data_importer.aggregate_data(
            status_message_func=progress_update,
            download_button=button_download.widget_object,
            progress_bar=progress_bar_upload.widget_object))

        # Start new thread
        thread_upload.start()

        # button_download.widget_object["command"] = lambda: download()

    def download() -> None:
        export_data_full_file_name = fd.asksaveasfilename(
            defaultextension='.xlsx',
            filetypes=(("Excel files", "*.xlsx"), ("CSV Files", "*.csv")))

        # Create the data exporter object
        exporter = du.DataExporter(data_importer.agg_data_df,
                                   export_data_full_file_name)

        # Export data
        exporter.export()

        # Clean up importer and exporter values
        # data_importer.reset()
        data_importer.reset()

        # config.reset()
        config.reset()

        del exporter

        # Open the generated file
        os.startfile(export_data_full_file_name)

        # Raise the Start Screen
        application.show_screen(screen_start)

        progress_bar_upload.widget_object['value'] = 0

        # Update Application
        application.update_idletasks()

    # Create Upload Button
    button_upload = gb.WidgetBuilder(child_container_action_buttons,
                                     tk.Button,
                                     text="Upload Data",
                                     command=lambda: upload())

    button_upload.set_placement_settings(padx=5)

    child_container_loading_status.new_build_row(button_upload,
                                                 button_download)
示例#6
0
def build_screen_data_agg_input_confirmation() -> None:
    screen_data_agg_input_confirmation.build_title_label(
        text="Input Confirmation", font=('arial', 15, 'bold'))

    child_container_message = gb.ChildContainer(
        screen_data_agg_input_confirmation)

    child_container_message.set_pack_options(fill=tk.X)

    text_instructions = "Please review your configuration settings below."

    label_instructions = gb.WidgetBuilder(
        child_container_message,
        tk.Label,
        text=text_instructions,
        # justify=tk.LEFT
    )

    child_container_message.new_build_row(label_instructions)

    # Build the Label form input values widget
    label_form_input_values = gb.WidgetBuilder(
        child_container_message,
        tk.Label,
        # text=text_instructions + text_config_settings
        textvariable=global_string_var,
        justify=tk.LEFT)

    child_container_message.new_build_row(label_form_input_values)

    child_container_confirm_button = gb.ChildContainer(
        screen_data_agg_input_confirmation)

    child_container_confirm_button.set_pack_options(side=tk.RIGHT, padx=5)

    def confirm() -> None:
        # Import config settings
        config.config = input_form_ui.config_file_path_str

        # Configure settings
        config.config_settings()

        # Get the config data
        data_importer.config = config
        data_importer.root_path = input_form_ui.input_dir_path_str
        data_importer.config_import_settings()

        # Set global int var to total number of files
        global_int_var.set(data_importer.file_count)
        global_string_var.set(
            f"0 out of {global_int_var.get()} files uploaded...")

        application.update_idletasks()

        # Show the Data Import screen
        application.show_screen(screen_data_import)

    button_confirm = gb.WidgetBuilder(child_container_confirm_button,
                                      tk.Button,
                                      text="Confirm",
                                      command=lambda: confirm())

    child_container_confirm_button.new_build_row(button_confirm)

    screen_data_agg_input_confirmation.build_back_button(
        screen_data_agg_config_form)