From 300db68b191ba7896a2119607f0ed420cbc6005c Mon Sep 17 00:00:00 2001 From: Helder Betiol <37706737+helderbetiol@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:58:37 +0100 Subject: [PATCH] Adjustments to Windows/Linux UI (#45) * Adapt to windows os * Check os and adapt * Update gui.py * Adapt to os * Update gui.py --- 3dtools/gui.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/3dtools/gui.py b/3dtools/gui.py index 85bede6..367b7c8 100644 --- a/3dtools/gui.py +++ b/3dtools/gui.py @@ -13,6 +13,17 @@ from PIL import Image, ImageTk from ultralytics import YOLO +# OS specific UI adaptations +if sys.platform == "darwin": + FontSizeJSON = 14 + FontSizeOutput = 14 + OutputHeight = 19 + BigBtnWidth = 40 +else: + FontSizeJSON = 10 + FontSizeOutput = 11 + OutputHeight = 17 + BigBtnWidth = 44 class Stdout_to_window(object): def __init__(self, widget): @@ -915,7 +926,7 @@ def create_json_window(self): self.unbind("") # JSON text on top leftmost columns - self.json_text = scrolledtext.ScrolledText(self, bg="black", fg="white", font=("Courier", 14), width=47, height=31) + self.json_text = scrolledtext.ScrolledText(self, bg="black", fg="white", font=("Courier", FontSizeJSON), width=47, height=31) self.json_text.grid(columnspan=2, rowspan=5, column=0, row=3, pady=(20, 20)) # Buttons on bottom leftmost columns @@ -986,7 +997,7 @@ def create_editing_window(self): self.save_component_button.grid(column=0, row=7) self.delete_component_button = Button(self, text="Delete component", command=self.delete_component, fg="black", height=4, width=14) - self.delete_component_button.grid(column=1, row=7) + self.delete_component_button.grid(column=1, row=7, sticky="w") self.return_to_detection_button = Button(self, text="Return to detection", command=self.return_to_detection, fg="black", height=4, width=40) self.return_to_detection_button.grid(columnspan=2, column=0, row=8) @@ -1021,8 +1032,7 @@ def create_editing_window(self): def create_detection_window(self): # Window self.title("OGrEE-Tools/3dtools") - self.geometry("1280x720") - self.resizable(False, False) + self.geometry("1280x740") self.protocol("WM_DELETE_WINDOW", self.close_window) self.createcommand("::tk::mac::Quit", self.close_window) @@ -1041,10 +1051,10 @@ def create_detection_window(self): self.open_images_label = Label(self, text="Welcome to OGrEE-Tools/3dtools!", bg="white", fg="black", font=("Helvetica, 16"), justify="center", height=4) self.open_images_label.grid(columnspan=2, column=0, row=3) - self.open_images_button = Button(self, text="Open images\n(rear AND/OR front)", command=lambda: Open_images_window(self), fg="black", height=4, width=40) + self.open_images_button = Button(self, text="Open images\n(rear AND/OR front)", command=lambda: Open_images_window(self), fg="black", height=4, width=BigBtnWidth) self.open_images_button.grid(columnspan=2, column=0, row=4) - self.detect_all_button = Button(self, text="Detect all components", command=self.detect_all, fg="black", height=4, width=14) + self.detect_all_button = Button(self, text="Detect all\ncomponents", command=self.detect_all, fg="black", height=4, width=14) self.detect_all_button.grid(column=0, row=5) self.detect_slot_button = Button(self, text="Detect slots", command=self.detect_slot, fg="black", height=4, width=14) @@ -1068,13 +1078,13 @@ def create_detection_window(self): self.detect_usb_button = Button(self, text="Detect USB ports", command=self.detect_usb, fg="black", height=4, width=14) self.detect_usb_button.grid(column=1, row=8) - self.create_editing_window_button = Button(self, text="Finish detection", command=self.create_editing_window, fg="black", height=4, width=40) + self.create_editing_window_button = Button(self, text="Finish detection", command=self.create_editing_window, fg="black", height=4, width=BigBtnWidth) self.create_editing_window_button.grid(columnspan=2, column=0, row=9) self.detection_widgets = [self.open_images_label, self.open_images_button, self.detect_all_button, self.detect_slot_button, self.detect_disk_button, self.detect_psu_button, self.detect_serial_button, self.detect_vga_button, self.detect_bmc_button, self.detect_usb_button, self.create_editing_window_button] # Output text on bottom rightmost columns - self.output = scrolledtext.ScrolledText(self, bg="black", fg="white", font=("Courier", 14), width=94, height=19) + self.output = scrolledtext.ScrolledText(self, bg="black", fg="white", font=("Courier", FontSizeOutput), width=94, height=OutputHeight) self.output.grid(columnspan=3, rowspan=3, column=2, row=7) self.prev_stdout = sys.stdout @@ -1136,4 +1146,5 @@ def __init__(self, options): # Creates and runs the GUI def run_gui(opt): gui = Gui(vars(opt)) + gui.configure(bg='white') mainloop()