Skip to content
Snippets Groups Projects
Commit f6e5b897 authored by Toumji Abdallah's avatar Toumji Abdallah
Browse files

QoL saved the last directory opened for better user experience

parent b389f0d8
Branches
No related tags found
No related merge requests found
......@@ -368,6 +368,8 @@ class Application(tk.Frame):
command=self.next_step)
self.integrate_data_confirm_button.pack()
self.previous_directory = None
def integrate_data_file(self):
""" This method is used to integrate a file to the new BIDS project.
......@@ -390,7 +392,11 @@ class Application(tk.Frame):
The user is prompted to select the file to integrate to the new BIDS project.
The confirm button is enabled after the file is selected.
"""
if self.previous_directory is not None:
self.experiment_file = tk.filedialog.askopenfilename(initialdir=self.previous_directory)
else:
self.experiment_file = tk.filedialog.askopenfilename()
self.previous_directory = os.path.dirname(self.experiment_file)
self.integrate_data_window.lift()
self.integrate_data_label.config(text='File selected: ' + self.experiment_file)
......@@ -414,18 +420,20 @@ class Application(tk.Frame):
self.integrate_data_button.grid_forget()
# To Do : make this method generic by using a json file
self.task_label = tk.Label(self.integrate_data_window, text='Task:', font=('Arial', 12, 'bold'))
font = tk.font.nametofont("TkDefaultFont").actual().copy()
font["weight"] = "bold"
self.task_label = tk.Label(self.integrate_data_window, text='Task:', font=font)
self.task_label.grid(row=1, column=0)
self.task_entry = Entry(self.integrate_data_window, label=self.task_label, row=1, column=1, columnspan=1,
valid_condition='len(value) > 0')
self.acquisition_label = tk.Label(self.integrate_data_window, text='Acquisition:', font=('Arial', 12, 'normal'))
font["weight"] = "normal"
self.acquisition_label = tk.Label(self.integrate_data_window, text='Acquisition:', font=font)
self.acquisition_label.grid(row=2, column=0)
self.acquisition_entry = Entry(self.integrate_data_window, label=self.acquisition_label, row=2, column=1,
columnspan=1, valid_condition='len(value) > 0')
self.run_label = tk.Label(self.integrate_data_window, text='Run:', font=('Arial', 12, 'normal'))
self.run_label = tk.Label(self.integrate_data_window, text='Run:', font=font)
self.run_label.grid(row=3, column=0)
self.run_entry = Entry(self.integrate_data_window, label=self.run_label, row=3, column=1, columnspan=1,
valid_condition='len(value) > 0')
......@@ -522,6 +530,8 @@ class Application(tk.Frame):
command=lambda: os.startfile(self.project_directory))
open_project_button.pack()
self.previous_directory = None
def integrate_sidecar_file(self):
""" This method is used to integrate a sidecar to the new BIDS project.
......@@ -624,7 +634,11 @@ class Application(tk.Frame):
"""
self.sidecar_type_label.destroy()
self.sidecar_type_dropdown.destroy()
if self.previous_directory is not None:
self.sidecar_file = tk.filedialog.askopenfilename(initialdir=self.previous_directory)
else:
self.sidecar_file = tk.filedialog.askopenfilename()
self.previous_directory = os.path.dirname(self.sidecar_file)
self.sidecar_file = self.sidecar_file.replace('\\', '/')
self.integrate_sidecar_window.lift()
self.integrate_sidecar_label.config(text='File selected: ' + self.sidecar_file)
......@@ -686,7 +700,11 @@ class Application(tk.Frame):
The user is also shown a dropdown menu to select the type of the sidecar (e.g. channels, events, etc.).
The option are loaded from a json file.
"""
if self.previous_directory is not None:
self.sidecar_file = tk.filedialog.askopenfilename(initialdir=self.previous_directory)
else:
self.sidecar_file = tk.filedialog.askopenfilename()
self.previous_directory = os.path.dirname(self.sidecar_file)
self.integrate_sidecar_window.lift()
self.integrate_sidecar_label.config(text='File selected: ' + self.sidecar_file)
......
......@@ -150,5 +150,8 @@
},
"LICENSE" : {
"description" : "A text file that provides the full license text for the dataset."
},
"CITATION.cff" : {
"description" : "A Citation File Format (CFF) file that provides citation information for the dataset."
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment