diff --git a/app/helpers/font_loader.py b/app/helpers/font_loader.py deleted file mode 100644 index 81f9ec1..0000000 --- a/app/helpers/font_loader.py +++ /dev/null @@ -1,11 +0,0 @@ -from pyglet import font -from glob import glob -from pathlib import Path -from app.helpers.utilities.path_helpers import resource_path - - -def initialize_fonts(): - fonts_path = resource_path("fonts") - for file in glob(f"{fonts_path}/**.ttf"): - corrected_path = str(Path(file)) - font.add_file(corrected_path) diff --git a/app/helpers/ui/elements/button.py b/app/helpers/ui/elements/button.py new file mode 100644 index 0000000..6bf1ef6 --- /dev/null +++ b/app/helpers/ui/elements/button.py @@ -0,0 +1,37 @@ +from tkinter import Button + + +def small_button(master, label, command): + new_btn = Button( + master.ui, + text=label, + **master.theme, + command=command, + font=master.FONTS["buttons"]["small"] + ) + + return new_btn + + +def medium_button(master, label, command): + new_btn = Button( + master.ui, + text=label, + **master.theme, + command=command, + font=master.FONTS["buttons"]["medium"] + ) + + return new_btn + + +def large_button(master, label, command): + new_btn = Button( + master.ui, + text=label, + **master.theme, + command=command, + font=master.FONTS["buttons"]["large"] + ) + + return new_btn \ No newline at end of file diff --git a/app/helpers/ui/elements/checkbutton.py b/app/helpers/ui/elements/checkbutton.py new file mode 100644 index 0000000..81521ed --- /dev/null +++ b/app/helpers/ui/elements/checkbutton.py @@ -0,0 +1,19 @@ +from tkinter import Checkbutton + + +def check_btn(master, text, variable, command=None): + new_checkbtn = Checkbutton( + master.ui, + text=text, + variable=variable, + **master.theme, + command=command, + font=master.FONTS["buttons"]["small"], + activebackground=master.bg, + activeforeground=master.fg, + highlightcolor=master.bg, + selectcolor=master.bg, + onvalue=True, + offvalue=False, + ) + return new_checkbtn \ No newline at end of file diff --git a/app/helpers/ui/elements/init_class.py b/app/helpers/ui/elements/init_class.py new file mode 100644 index 0000000..ab81fb0 --- /dev/null +++ b/app/helpers/ui/elements/init_class.py @@ -0,0 +1,21 @@ +from app.helpers.ui.elements.button import small_button, medium_button, large_button +from app.helpers.ui.elements.label import small_label, medium_label, title_label +from app.helpers.ui.elements.checkbutton import check_btn +from app.helpers.ui.elements.radiobutton import radio_btn + + +class tk_elements: + def __init__(self): + # Buttons + self.small_btn = small_button + self.medium_btn = medium_button + self.large_btn = large_button + + # labels + self.small_lbl = small_label + self.medium_lbl = medium_label + self.title_lbl = title_label + + # others + self.check_btn = check_btn + self.radio_btn = radio_btn diff --git a/app/helpers/ui/elements/label.py b/app/helpers/ui/elements/label.py new file mode 100644 index 0000000..bcdc2ae --- /dev/null +++ b/app/helpers/ui/elements/label.py @@ -0,0 +1,18 @@ +from tkinter import Label + + +def small_label(master, text, bold): + font_label = "small_bold" if bold else "small" + new_label = Label(master.ui, text=text, **master.theme, font=master.FONTS[font_label]) + return new_label + + +def medium_label(master, text, bold): + font_label = "medium_bold" if bold else "medium" + new_label = Label(master.ui, text=text, **master.theme, font=master.FONTS[font_label]) + return new_label + + +def title_label(master, text): + new_label = Label(master.ui, text=text, **master.theme, font=master.FONTS["title"]) + return new_label \ No newline at end of file diff --git a/app/helpers/ui/elements/radiobutton.py b/app/helpers/ui/elements/radiobutton.py new file mode 100644 index 0000000..9a633b2 --- /dev/null +++ b/app/helpers/ui/elements/radiobutton.py @@ -0,0 +1,15 @@ +from tkinter import Radiobutton + + +def radio_btn(master, text, variable, value, command): + new_radiobtn = Radiobutton( + master.ui, + text=text, + variable=variable, + value=value, + **master.theme, + selectcolor=master.bg, + font=master.FONTS["buttons"]["small"], + command=command, + ) + return new_radiobtn \ No newline at end of file diff --git a/app/helpers/ui/base.py b/app/helpers/ui/helpers/base.py similarity index 63% rename from app/helpers/ui/base.py rename to app/helpers/ui/helpers/base.py index ff781b6..232d47a 100644 --- a/app/helpers/ui/base.py +++ b/app/helpers/ui/helpers/base.py @@ -1,9 +1,9 @@ import tkinter as tk from tkinter import ttk - from app.helpers.utilities.path_helpers import resource_path -from app.helpers.ui.theme_constants import * +from app.helpers.ui.helpers.theme_constants import * +from app.helpers.ui.elements.init_class import tk_elements class base_ui: @@ -18,36 +18,25 @@ def __init__(self, window_title, title, menu, logo, maxcol=4): self.ui.config(padx=20, pady=20, bg=self.bg) self.icon = tk.PhotoImage(file=resource_path("images/logo.png")) self.ui.iconphoto(False, self.icon) + self.elements = tk_elements() if menu: - self.menu_button = tk.Button( - self.ui, - text="Menu", - command=self.close_window, - **self.theme, - font=self.FONTS["buttons"]["small"], + self.menu_button = self.elements.small_btn( + self, label="Menu", command=self.close_window ) self.menu_button.grid( row=0, column=0, ) - self.about_button = tk.Button( - self.ui, - text="About", - **self.theme, - font=self.FONTS["buttons"]["small"], + self.about_button = self.elements.small_btn( + self, label="About", command=self.close_window ) self.about_button.grid(row=0, column=1) - self.main_title = tk.Label( - master=self.ui, - text=title, - font=self.FONTS["medium_bold"], - **self.theme, - ) - self.ui.focus_force() + self.main_title = self.elements.medium_lbl(self, text=title, bold=True) self.main_title.grid(row=1, column=0, columnspan=maxcol, pady=(10, 10)) + self.ui.focus_force() if logo: self.canvas = tk.Canvas( @@ -65,21 +54,15 @@ def __init__(self, window_title, title, menu, logo, maxcol=4): ) self.style.theme_use("gstr_theme") - self.developer_label_head = tk.Label( - self.ui, - text="Developed by", - font=self.FONTS["small_bold"], - **self.theme, + self.developer_label_head = self.elements.small_lbl( + self, text="Developed by", bold=False ) self.developer_label_head.grid( row=20, column=0, columnspan=maxcol, pady=(20, 0) ) - self.developer_label_value = tk.Label( - self.ui, - text="Shan.tk", - font=self.FONTS["small_bold"], - **self.theme, + self.developer_label_value = self.elements.small_lbl( + self, text="Shan.tk", bold=True ) self.developer_label_value.grid( row=21, column=0, columnspan=maxcol, pady=(0, 0) diff --git a/app/helpers/ui/helpers/theme_constants.py b/app/helpers/ui/helpers/theme_constants.py new file mode 100644 index 0000000..0f536f0 --- /dev/null +++ b/app/helpers/ui/helpers/theme_constants.py @@ -0,0 +1,28 @@ +BG = "#121212" +FG = "#FFFFFF" +ACCENT = "#e84545" + +THEME = {"background": BG, "foreground": FG} + +FONTS = { + "small": ("Arial", 10, "normal"), + "small_bold": ("Arial", 10, "bold"), + "medium": ("Arial", 12, "normal"), + "medium_bold": ("Arial", 12, "bold"), + "title": ("Arial", 25, "bold"), + "buttons": { + "small": ("Arial", 9, "bold"), + "medium": ("Arial", 11, "bold"), + "large": ("Arial", 15, "bold"), + }, +} + +TTK_THEME = { + "TProgressbar": { + "configure": { + "troughcolor": BG, + "bordercolor": FG, + "background": ACCENT, + } + }, +} diff --git a/app/helpers/ui/main_ui.py b/app/helpers/ui/main_windows/main_ui.py similarity index 50% rename from app/helpers/ui/main_ui.py rename to app/helpers/ui/main_windows/main_ui.py index ac32ae3..7636408 100644 --- a/app/helpers/ui/main_ui.py +++ b/app/helpers/ui/main_windows/main_ui.py @@ -1,5 +1,4 @@ -import tkinter as tk -from app.helpers.ui.base import base_ui +from app.helpers.ui.helpers.base import base_ui class main_window(base_ui): @@ -10,28 +9,22 @@ def __init__(self, window_title, title, buttons, menu): self.ui.config(padx=60, pady=60) - utility_label = tk.Label( - text="General Utilities", **self.theme, font=self.FONTS["small"] + utility_label = self.elements.small_lbl( + self, text="General Utilities", bold=True ) utility_label.grid(row=3, column=0, columnspan=4) for btn in buttons["utility_buttons"]: - new_btn = tk.Button( - text=btn["title"], - **self.theme, - command=btn["command"], - font=self.FONTS["buttons"]["small"] + new_btn = self.elements.small_btn( + self, label=btn["title"], command=btn["command"] ) new_btn.grid(row=btn["row"], column=btn["column"], pady=10, columnspan=2) - reco_label = tk.Label( - text="Reconciliation Utilities", **self.theme, font=self.FONTS["small"] + reco_label = self.elements.small_lbl( + self, text="Reconciliation Utilities", bold=True ) reco_label.grid(row=5, column=0, columnspan=4) for btn in buttons["reco_buttons"]: - new_btn = tk.Button( - text=btn["title"], - **self.theme, - command=btn["command"], - font=self.FONTS["buttons"]["small"] + new_btn = self.elements.small_btn( + self, label=btn["title"], command=btn["command"] ) new_btn.grid(row=btn["row"], column=btn["column"], pady=10, columnspan=4) diff --git a/app/helpers/ui/reco_ui.py b/app/helpers/ui/main_windows/reco_ui.py similarity index 68% rename from app/helpers/ui/reco_ui.py rename to app/helpers/ui/main_windows/reco_ui.py index 66dba7b..2b890fb 100644 --- a/app/helpers/ui/reco_ui.py +++ b/app/helpers/ui/main_windows/reco_ui.py @@ -1,5 +1,4 @@ -import tkinter as tk -from app.helpers.ui.base import base_ui +from app.helpers.ui.helpers.base import base_ui class gst_reco_ui(base_ui): @@ -15,31 +14,21 @@ def __init__(self, window_title, title, button_commands): self.button_commands = button_commands - self.project_init_status = tk.Label( - self.ui, - text="Project: Not Initialized", - **self.theme, - font=self.FONTS["small"], + self.project_init_status = self.elements.small_lbl( + self, text="Project: Not Initialized", bold=False ) self.project_init_status.grid(row=3, column=0, columnspan=maxcol, pady=(0, 10)) - self.project_command_label = tk.Label( - self.ui, - text="Manage Project", - **self.theme, - font=self.FONTS["small"], + self.project_command_label = self.elements.small_lbl( + self, text="Manage Project", bold=False ) self.project_command_label.grid(row=4, column=0, columnspan=maxcol) self.project_command_buttons = {} for buttons in button_commands["project_commands"]: for (button_key, button_props) in buttons.items(): - self.project_command_buttons[button_key] = tk.Button( - self.ui, - text=button_key, - command=button_props["command"], - font=self.FONTS["small_bold"], - **self.theme, + self.project_command_buttons[button_key] = self.elements.small_btn( + self, label=button_key, command=button_props["command"] ) self.project_command_buttons[button_key].grid( row=button_props["row"], @@ -48,12 +37,10 @@ def __init__(self, window_title, title, button_commands): pady=5, padx=5, ) - self.reset_button = tk.Button( - self.ui, - text=button_commands["reset_button"]["title"], + self.reset_button = self.elements.small_btn( + self, + label=button_commands["reset_button"]["title"], command=button_commands["reset_button"]["command"], - **self.theme, - font=self.FONTS["small_bold"], ) self.reset_button.grid( row=button_commands["reset_button"]["row"], @@ -62,12 +49,10 @@ def __init__(self, window_title, title, button_commands): ) self.reset_button.grid_remove() - self.start_button = tk.Button( - self.ui, - text=button_commands["start_button"]["title"], + self.start_button = self.elements.medium_btn( + self, + label=button_commands["start_button"]["title"], command=button_commands["start_button"]["command"], - **self.theme, - font=self.FONTS["buttons"]["medium"], ) self.start_button.grid( row=button_commands["start_button"]["row"], diff --git a/app/helpers/ui/utils_ui.py b/app/helpers/ui/main_windows/utils_ui.py similarity index 66% rename from app/helpers/ui/utils_ui.py rename to app/helpers/ui/main_windows/utils_ui.py index 71f86df..ddd5dff 100644 --- a/app/helpers/ui/utils_ui.py +++ b/app/helpers/ui/main_windows/utils_ui.py @@ -1,7 +1,7 @@ import tkinter as tk -from app.helpers.ui.base import base_ui -from app.helpers.ui.check_box_window import check_box_window +from app.helpers.ui.helpers.base import base_ui +from app.helpers.ui.sub_windows.check_box_window import check_box_window class gst_utils_ui(base_ui): @@ -9,11 +9,8 @@ def __init__(self, window_title, title, commands, start_button): super(gst_utils_ui, self).__init__( window_title=window_title, title=title, menu=False, logo=False ) - self.app_generation_mode_label = tk.Label( - self.ui, - text="Select App Working Mode", - **self.theme, - font=self.FONTS["small"], + self.app_generation_mode_label = self.elements.small_lbl( + self, text="Select App Working Mode", bold=False ) self.app_generation_mode_label.grid(row=3, column=0, columnspan=4) self.app_generation_mode_var = tk.StringVar(self.ui, "single") @@ -22,14 +19,11 @@ def __init__(self, window_title, title, commands, start_button): "Directory": {"value": "directory", "row": 4, "column": 2, "span": 2}, } for (modes, mode_vals) in app_generation_modes.items(): - tk.Radiobutton( - self.ui, + self.elements.radio_btn( + self, text=modes, variable=self.app_generation_mode_var, value=mode_vals["value"], - **self.theme, - selectcolor=self.bg, - font=self.FONTS["small_bold"], command=commands["app_generation"], ).grid( row=mode_vals["row"], @@ -37,11 +31,8 @@ def __init__(self, window_title, title, commands, start_button): columnspan=mode_vals["span"], ) - self.app_processing_mode_label = tk.Label( - self.ui, - text="Select File Processing Mode", - **self.theme, - font=self.FONTS["small"], + self.app_processing_mode_label = self.elements.small_lbl( + self, text="Select File Processing Mode", bold=False ) self.app_processing_mode_var = tk.StringVar(self.ui, "excel") self.app_processing_mode_label.grid(row=5, column=0, columnspan=4) @@ -65,23 +56,18 @@ def __init__(self, window_title, title, commands, start_button): } for (modes, mode_vals) in app_processing_modes.items(): - tk.Radiobutton( - self.ui, + self.elements.radio_btn( + self, text=modes, variable=self.app_processing_mode_var, value=mode_vals["value"], - **self.theme, - selectcolor=self.bg, - font=self.FONTS["small_bold"], command=commands["app_processing"], ).grid(row=mode_vals["row"], column=mode_vals["column"]) - self.invoice_config_button = tk.Button( - self.ui, - text="Select Invoices to Extract", - font=self.FONTS["small_bold"], + self.invoice_config_button = self.elements.small_btn( + self, + label="Select Invoices to Extract", command=self.wait_for_checkbox_selector, - **self.theme, ) self.invoice_extract_options_selected = None @@ -89,12 +75,8 @@ def __init__(self, window_title, title, commands, start_button): self.invoice_config_button.grid(row=7, column=0, columnspan=4) - self.source_dir_label = tk.Label( - self.ui, - text="Source: ", - **self.theme, - wraplength=450, - font=self.FONTS["small"], + self.source_dir_label = self.elements.small_lbl( + self, text="Source: ", bold=False ) self.source_dir_label.grid(row=8, column=0, columnspan=1, pady=(10, 0)) self.source_dir_entry = tk.Entry( @@ -110,13 +92,7 @@ def __init__(self, window_title, title, commands, start_button): ) self.source_dir_entry.grid(row=8, column=1, columnspan=3, pady=(10, 0)) - self.final_dir_label = tk.Label( - self.ui, - text="Dest: ", - **self.theme, - wraplength=450, - font=self.FONTS["small"], - ) + self.final_dir_label = self.elements.small_lbl(self, text="Dest: ", bold=False) self.final_dir_label.grid(row=9, column=0, columnspan=1, pady=(0, 10)) self.final_dir_entry = tk.Entry( self.ui, @@ -131,38 +107,23 @@ def __init__(self, window_title, title, commands, start_button): ) self.final_dir_entry.grid(row=9, column=1, columnspan=3, pady=(0, 10)) - self.start_gstr_1_process_button = tk.Button( - self.ui, - text="Start Processing", + self.start_gstr_1_process_button = self.elements.medium_btn( + self, + label="Start Processing", command=start_button, - **self.theme, - font=self.FONTS["buttons"]["medium"], ) self.start_gstr_1_process_button.grid(row=10, column=0, columnspan=4) self.open_final_dir_var = tk.BooleanVar(self.ui, False) - self.open_final_dir_checkButton = tk.Checkbutton( - self.ui, + self.open_final_dir_checkButton = self.elements.check_btn( + self, text="Open the Destination Directory after Finish", variable=self.open_final_dir_var, - **self.theme, - font=self.FONTS["small_bold"], - activebackground=self.bg, - activeforeground=self.fg, - highlightcolor=self.bg, - selectcolor=self.bg, - onvalue=True, - offvalue=False, ) self.open_final_dir_checkButton.grid(row=11, column=0, columnspan=4) - self.app_status_text = tk.Label( - self.ui, - text="Status - Ready to Process", - **self.theme, - font=self.FONTS["small_bold"], - padx=5, - pady=5, + self.app_status_text = self.elements.small_lbl( + self, text="Status - Ready to Process", bold=True ) self.app_status_text.grid(row=12, column=0, columnspan=4) diff --git a/app/helpers/ui/about_window.py b/app/helpers/ui/sub_windows/about_window.py similarity index 100% rename from app/helpers/ui/about_window.py rename to app/helpers/ui/sub_windows/about_window.py diff --git a/app/helpers/ui/check_box_window.py b/app/helpers/ui/sub_windows/check_box_window.py similarity index 100% rename from app/helpers/ui/check_box_window.py rename to app/helpers/ui/sub_windows/check_box_window.py diff --git a/app/helpers/ui/loader_window.py b/app/helpers/ui/sub_windows/loader_window.py similarity index 100% rename from app/helpers/ui/loader_window.py rename to app/helpers/ui/sub_windows/loader_window.py diff --git a/app/helpers/ui/text_box_window.py b/app/helpers/ui/sub_windows/text_box_window.py similarity index 100% rename from app/helpers/ui/text_box_window.py rename to app/helpers/ui/sub_windows/text_box_window.py diff --git a/app/helpers/ui/theme_constants.py b/app/helpers/ui/theme_constants.py deleted file mode 100644 index 21a5c02..0000000 --- a/app/helpers/ui/theme_constants.py +++ /dev/null @@ -1,29 +0,0 @@ -BG = "#121212" -FG = "#FFFFFF" -ACCENT = "#e84545" - -THEME = {"background": BG, "foreground": FG} - -FONTS = { - "small": ("Roboto", 10, "normal"), - "small_bold": ("Roboto", 10, "bold"), - "medium": ("Roboto", 12, "normal"), - "medium_bold": ("Roboto", 12, "bold"), - "title": ("Roboto", 20, "bold"), - "title_big": ("Roboto", 25, "bold"), - "buttons": { - "small": ("Roboto", 9, "bold"), - "medium": ("Roboto", 11, "bold"), - "large": ("Roboto", 15, "bold"), - }, -} - -TTK_THEME = { - "TProgressbar": { - "configure": { - "troughcolor": BG, - "bordercolor": FG, - "background": ACCENT, - } - }, -} diff --git a/app/reco/gstr_9c/main.py b/app/reco/gstr_9c/main.py index adab479..840b33a 100644 --- a/app/reco/gstr_9c/main.py +++ b/app/reco/gstr_9c/main.py @@ -2,9 +2,9 @@ from app.reco.gstr_9c.generators.initializer import initialize_new_project from app.reco.gstr_9c.generators.project_configs import load_toml_config -from app.helpers.ui.text_box_window import text_box_window -from app.helpers.ui.reco_ui import gst_reco_ui -from app.helpers.ui.loader_window import loader_window +from app.helpers.ui.sub_windows.text_box_window import text_box_window +from app.helpers.ui.main_windows.reco_ui import gst_reco_ui +from app.helpers.ui.sub_windows.loader_window import loader_window def initialize_project(): diff --git a/app/utils/gstr_1.py b/app/utils/gstr_1.py index 8b53676..ff2a4f0 100644 --- a/app/utils/gstr_1.py +++ b/app/utils/gstr_1.py @@ -5,8 +5,8 @@ from openpyxl import Workbook # Other Imports -from app.helpers.ui.utils_ui import gst_utils_ui -from app.helpers.ui.loader_window import loader_window +from app.helpers.ui.main_windows.utils_ui import gst_utils_ui +from app.helpers.ui.sub_windows.loader_window import loader_window from app.helpers.utilities.invoice_writer import invoices_writer from app.helpers.utilities.path_helpers import ( get_user_json_directory, diff --git a/app/utils/gstr_2.py b/app/utils/gstr_2.py index c4d0c5a..7b7dbd5 100644 --- a/app/utils/gstr_2.py +++ b/app/utils/gstr_2.py @@ -5,8 +5,8 @@ from openpyxl import Workbook # Other Imports -from app.helpers.ui.utils_ui import gst_utils_ui -from app.helpers.ui.loader_window import loader_window +from app.helpers.ui.main_windows.utils_ui import gst_utils_ui +from app.helpers.ui.sub_windows.loader_window import loader_window from app.helpers.utilities.invoice_writer import invoices_writer from app.helpers.utilities.path_helpers import ( get_user_json_directory, diff --git a/main.py b/main.py index a0e7253..b439139 100644 --- a/main.py +++ b/main.py @@ -2,8 +2,7 @@ import app.utils.gstr_2 as gstr_2_utils import app.reco.gstr_9c.main as gstr_9c_utils -from app.helpers.ui.main_ui import main_window -from app.helpers.font_loader import initialize_fonts +from app.helpers.ui.main_windows.main_ui import main_window def main_ui_window(): @@ -75,5 +74,4 @@ def open_gstr_9c_window(): main_ui = None if __name__ == "__main__": - initialize_fonts() main_ui_window() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6c90c65..cda7c54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,11 +2,12 @@ altgraph==0.17 et-xmlfile==1.1.0 flatten-json==0.1.13 future==0.18.2 +gitdb==4.0.7 openpyxl==3.0.7 pefile==2021.5.24 -pyglet==1.5.17 pyinstaller==4.3 pyinstaller-hooks-contrib==2021.1 pywin32-ctypes==0.2.0 six==1.16.0 +smmap==4.0.0 toml==0.10.2 diff --git a/version.txt b/version.txt index 3c77e11..90aa366 100644 --- a/version.txt +++ b/version.txt @@ -1,7 +1,7 @@ VSVersionInfo( ffi=FixedFileInfo( - filevers=(2, 4, 1, 10522), - prodvers=(2, 4, 1, 10522), + filevers=(2, 4, 2, 11222), + prodvers=(2, 4, 2, 11222), mask=0x3f, flags=0x0, OS=0x40004,