Skip to content

Commit

Permalink
Adjustments to Windows/Linux UI (#45)
Browse files Browse the repository at this point in the history
* Adapt to windows os

* Check os and adapt

* Update gui.py

* Adapt to os

* Update gui.py
  • Loading branch information
helderbetiol authored Mar 6, 2024
1 parent 753c50f commit 300db68
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions 3dtools/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -915,7 +926,7 @@ def create_json_window(self):
self.unbind("<Escape>")

# 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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 300db68

Please sign in to comment.