Skip to content

Commit 891eb51

Browse files
Fix GUI on Linux to not look ugly
1 parent 26ea20a commit 891eb51

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

gui.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,12 @@ def create_new_project_location(self) -> None:
347347
self.project_location_label = ttk.Label(master=self.project_location_frame, text="Project location: ")
348348
self.project_location_label.grid(row=0, column=0, padx=1, pady=1, sticky=tk.NW)
349349
self.project_location_var = tk.StringVar()
350-
self.project_location_entry = EntryWithRightClick(master=self.project_location_frame,
351-
textvariable=self.project_location_var, width=51)
350+
if os_detect.on_linux():
351+
self.project_location_entry = EntryWithRightClick(master=self.project_location_frame,
352+
textvariable=self.project_location_var, width=32)
353+
else:
354+
self.project_location_entry = EntryWithRightClick(master=self.project_location_frame,
355+
textvariable=self.project_location_var, width=51)
352356
self.project_location_entry.initiate_right_click_menu()
353357
self.project_location_entry.grid(row=0, column=1, padx=1, pady=1, sticky=tk.NW)
354358
self.add_tooltip(self.project_location_entry, "Where to put the new project.")
@@ -368,7 +372,10 @@ def create_new_project_details(self) -> None:
368372
self.project_title_label = ttk.Label(master=self.project_details_frame, text="Project title: ")
369373
self.project_title_label.grid(row=0, column=0, padx=1, pady=1, sticky=tk.NW)
370374
self.project_title_var = tk.StringVar(value="Untitled")
371-
self.project_title_entry = EntryWithRightClick(master=self.project_details_frame, width=40, textvariable=self.project_title_var)
375+
if os_detect.on_linux():
376+
self.project_title_entry = EntryWithRightClick(master=self.project_details_frame, width=24, textvariable=self.project_title_var)
377+
else:
378+
self.project_title_entry = EntryWithRightClick(master=self.project_details_frame, width=40, textvariable=self.project_title_var)
372379
self.project_title_entry.initiate_right_click_menu()
373380
self.project_title_entry.grid(row=0, column=1, padx=1, pady=1, sticky=tk.NW)
374381
self.add_tooltip(self.project_title_entry, "The title of the project.")
@@ -762,7 +769,10 @@ def make_title(self, title: str) -> None:
762769
self.title_label = ttk.Label(master=self.title_frame, text="Project title: ")
763770
self.title_label.grid(row=0, column=0, padx=1, pady=1, sticky=tk.NW)
764771
self.title_var = tk.StringVar(value=title)
765-
self.title_entry = EntryWithRightClick(master=self.title_frame, width=29, textvariable=self.title_var)
772+
if os_detect.on_linux():
773+
self.title_entry = EntryWithRightClick(master=self.title_frame, width=24, textvariable=self.title_var)
774+
else:
775+
self.title_entry = EntryWithRightClick(master=self.title_frame, width=29, textvariable=self.title_var)
766776
self.title_entry.initiate_right_click_menu()
767777
self.title_entry.grid(row=0, column=1, padx=1, pady=1, sticky=tk.NW)
768778
self.add_tooltip(self.title_entry, "The title of the opened project.")
@@ -778,7 +788,10 @@ def make_description(self, description: str) -> None:
778788
self.description_frame.grid(row=1, column=0, padx=1, pady=1, sticky=tk.NW)
779789
self.description_label = ttk.Label(master=self.description_frame, text="Project description: ")
780790
self.description_label.grid(row=0, column=0, padx=1, pady=1, sticky=tk.NW)
781-
self.description_text = TextWithRightClick(master=self.description_frame, width=31, height=8, wrap=tk.WORD)
791+
if os_detect.on_linux():
792+
self.description_text = TextWithRightClick(master=self.description_frame, width=35, height=11, wrap=tk.WORD)
793+
else:
794+
self.description_text = TextWithRightClick(master=self.description_frame, width=31, height=8, wrap=tk.WORD)
782795
self.description_text.initiate_right_click_menu()
783796
self.description_text.grid(row=1, column=0, padx=1, pady=1, sticky=tk.NW)
784797
self.description_text.insert("1.0", description)
@@ -816,7 +829,10 @@ def make_drive_selector(self, drive: Path) -> None:
816829
self.drive_selector_var = tk.StringVar()
817830
if drive is not None:
818831
self.drive_selector_var.set(str(drive))
819-
self.drive_selector_combobox = ComboboxWithRightClick(master=self.drive_selector_frame, width=48, textvariable=self.drive_selector_var)
832+
if os_detect.on_linux():
833+
self.drive_selector_combobox = ComboboxWithRightClick(master=self.drive_selector_frame, width=44, textvariable=self.drive_selector_var)
834+
else:
835+
self.drive_selector_combobox = ComboboxWithRightClick(master=self.drive_selector_frame, width=48, textvariable=self.drive_selector_var)
820836
self.drive_selector_combobox.initiate_right_click_menu()
821837
self.drive_selector_combobox.grid(row=0, column=1, padx=1, pady=1, sticky=tk.NW)
822838
self.add_tooltip(self.drive_selector_combobox, "The CircuitPython device to sync to.")
@@ -853,7 +869,10 @@ def make_file_sync_listbox(self, to_sync: list[str], project_root: Path) -> None
853869
self.to_sync_label = ttk.Label(master=self.to_sync_frame, text="Files and directories to sync: ")
854870
self.to_sync_label.grid(row=0, column=0, columnspan=3, padx=1, pady=1, sticky=tk.NW)
855871
self.to_sync_var = tk.StringVar(value=to_sync)
856-
self.to_sync_listbox = ListboxWithRightClick(master=self.to_sync_frame, height=10, width=20, listvariable=self.to_sync_var)
872+
if os_detect.on_linux():
873+
self.to_sync_listbox = ListboxWithRightClick(master=self.to_sync_frame, height=12, width=20, listvariable=self.to_sync_var)
874+
else:
875+
self.to_sync_listbox = ListboxWithRightClick(master=self.to_sync_frame, height=10, width=20, listvariable=self.to_sync_var)
857876
self.to_sync_listbox.initiate_right_click_menu(disable=["Copy", "Cut", "Paste", "Delete", "Select all"],
858877
callback=self.update_listbox_context)
859878
self.to_sync_listbox.right_click_menu.entryconfigure("Delete", command=self.remove_thing_to_sync)
@@ -973,7 +992,7 @@ def make_file_sync_buttons(self) -> None:
973992
command=self.add_file_to_sync)
974993
self.to_sync_add_file_btn.grid(row=0, column=0, padx=1, pady=1, sticky=tk.NW)
975994
self.add_tooltip(self.to_sync_add_file_btn, "Add a new file via the file selector.")
976-
self.to_sync_add_directory_btn = ttk.Button(master=self.right_frame, text="Add directory",
995+
self.to_sync_add_directory_btn = ttk.Button(master=self.right_frame, text="Add directory", width=12,
977996
command=self.add_directory_to_sync)
978997
self.to_sync_add_directory_btn.grid(row=1, column=0, padx=1, pady=1, sticky=tk.NW)
979998
self.add_tooltip(self.to_sync_add_directory_btn, "Add a new directory via the directory selector.")

0 commit comments

Comments
 (0)