Skip to content

Commit

Permalink
multiple file support gui
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurDeclercq committed Oct 3, 2023
1 parent df35f18 commit 4b6f35d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ms2rescore/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def __init__(self, *args, **kwargs):
self.grid_columnconfigure(0, weight=1)

self.psm_file = widgets.LabeledFileSelect(
self, label="Select identification file", file_option="openfile"
self, label="Select identification file", file_option="openfiles"
)
self.psm_file.grid(row=0, column=0, pady=0, padx=(0, 5), sticky="nsew")

Expand All @@ -281,8 +281,9 @@ def __init__(self, *args, **kwargs):

def get(self) -> Dict:
"""Get the configured values as a dictionary."""

return {
"psm_file": self.psm_file.get(),
"psm_file": self.psm_file.get().split(" "), # there cannot be spaces in the file path
"psm_file_type": self.psm_file_type.get(),
}

Expand Down Expand Up @@ -498,7 +499,7 @@ def __init__(self, *args, **kwargs):
self.title = widgets.Heading(self, text="Ionmob")
self.title.grid(row=0, column=0, columnspan=2, pady=(0, 5), sticky="ew")

self.enabled = widgets.LabeledSwitch(self, label="Enable Ionmob", default=True)
self.enabled = widgets.LabeledSwitch(self, label="Enable Ionmob", default=False)
self.enabled.grid(row=1, column=0, pady=(0, 10), sticky="nsew")

self.model = widgets.LabeledEntry(
Expand Down
7 changes: 7 additions & 0 deletions ms2rescore/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ def __init__(self, *args, label="Select file", file_option="openfile", **kwargs)
elif file_option == "openfile":
self._button_1 = ctk.CTkButton(self, text="Browse files", command=self._pick_file)

elif file_option == "openfiles":
self._button_1 = ctk.CTkButton(self, text="Browse files", command=self._pick_files)

elif file_option == "file/dir":
self._button_1 = ctk.CTkButton(self, text="Browse files", command=self._pick_file)
self._button_2 = ctk.CTkButton(self, text="Browse directories", command=self._pick_dir)
Expand Down Expand Up @@ -296,6 +299,10 @@ def _pick_file(self):
self._selected_filename = tk.filedialog.askopenfilename()
self._update_entry()

def _pick_files(self):
self._selected_filename = tk.filedialog.askopenfilenames()
self._update_entry()

def _pick_dir(self):
self._selected_filename = tk.filedialog.askdirectory()
self._update_entry()
Expand Down

0 comments on commit 4b6f35d

Please sign in to comment.