Skip to content

Commit

Permalink
clearn up & GUI chanegs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwangwyx committed May 20, 2024
1 parent dfb6b8c commit 22d4cee
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cmdcompass/gui/commandbodybox.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def set_command(self, command):
def save_command(self):
if self.main_window.selected_command:
new_command_str = self.command_textbox.get("1.0", "end-1c")
new_command_str = new_command_str.replace('\u2212', '-') # Minus sign should be dash
self.main_window.selected_command.command_str = new_command_str
if '\u2212' in self.command_textbox.get("1.0", "end-1c"):
self.set_command(self.main_window.selected_command)
self.main_window.data_manager.save_data()
self.save_button.configure(state="disabled", fg_color="gray")
self.main_window.refresh_command_list() # Refresh the command list
Expand Down
3 changes: 3 additions & 0 deletions cmdcompass/gui/commandbox.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import customtkinter as ctk
import tkinter.font as tkFont
import platform

COMMAND_LABLE_WIDTH = 200
if platform.system() == "Windows":
COMMAND_LABLE_WIDTH = 210

class TagBox(ctk.CTkFrame):
def __init__(self, master, tags, command, main_window,**kwargs):
Expand Down
7 changes: 6 additions & 1 deletion cmdcompass/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
from CTkToolTip import CTkToolTip

from CTkMessagebox import CTkMessagebox
import platform

DEFAULT_BUTTON_COLOR = "blue"
COMMAND_LIST_FRAME_WIDTH = 240
if platform.system() == "Windows":
COMMAND_LIST_FRAME_WIDTH = 230


class MainWindow(ctk.CTk):
Expand Down Expand Up @@ -106,7 +111,7 @@ def __init__(self):
CTkToolTip(tag_operations_button, message="Define/Remove Tags here to be later assigned to commands")

# Create scrollable frame for the command list
self.command_list_frame = ctk.CTkScrollableFrame(self.left_frame, height=450, width=240)
self.command_list_frame = ctk.CTkScrollableFrame(self.left_frame, height=450, width=COMMAND_LIST_FRAME_WIDTH)
self.command_list_frame.grid(row=3, column=0, padx=10, pady=10, sticky="nsew")

# Configure scrolling behavior
Expand Down
1 change: 0 additions & 1 deletion cmdcompass/gui/manpagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def set_man_page(self, command):
else:
def download_and_update():
progress_window = self.create_progress_window()
progress_window.update_progress(HTML_CORE_DIR)
progress_window.update_progress(f"Downloading {command_name}...")
download_and_process_package(command_name, progress_window)
# After download and processing is complete, update the HTML
Expand Down
3 changes: 0 additions & 3 deletions cmdcompass/man_parser/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,12 @@ def move_and_clean_man_pages(package_name, extract_to, man_dest_folder):
return found_page

def download_and_process_package(package_name, progress_window):
progress_window.update_progress(f"Searching for {package_name}...", 0.1)
# Ensure destination folders exist
if not os.path.exists(UNPACKING_DIR):
os.makedirs(UNPACKING_DIR)
progress_window.update_progress(f"read from {KV_DB_PATH}")
with SqliteDict(KV_DB_PATH) as db:
if package_name in db:
try:
progress_window.update_progress(f"found")
# Note the db value can contain a list of package that includes the command man page.
# The value is in tuple of ("package_link", #number of man pages in this package) and ordered by the #number
# We can have a feature to allow user to choose which package to use
Expand Down

0 comments on commit 22d4cee

Please sign in to comment.