@@ -23,6 +23,54 @@ def write(self, string):
2323 def flush(self):
2424 pass
2525
26+ # Add this new class after the redirect_text class and before MainApp
27+ class TokenConfig(tk.Toplevel):
28+ """
29+ Token configuration window for Dataverse and GitHub tokens
30+ """
31+ def __init__(self, parent):
32+ tk.Toplevel.__init__(self, parent)
33+ self.title("API Tokens")
34+
35+ # Make window modal
36+ self.transient(parent)
37+ self.grab_set()
38+
39+ # Create frame
40+ frame = ttk.Frame(self, padding="10")
41+ frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S))
42+
43+ # Dataverse token
44+ ttk.Label(frame, text="Dataverse token:").grid(column=0, row=0, sticky=tk.W, pady=5)
45+ self.dv_token = tk.StringVar(value=parent.dv_token.get())
46+ ttk.Entry(frame, textvariable=self.dv_token, width=40).grid(column=1, row=0, padx=5)
47+
48+ # GitHub token
49+ ttk.Label(frame, text="GitHub token:").grid(column=0, row=1, sticky=tk.W, pady=5)
50+ self.gh_token = tk.StringVar(value=parent.gh_token.get())
51+ ttk.Entry(frame, textvariable=self.gh_token, width=40).grid(column=1, row=1, padx=5)
52+
53+ # Buttons
54+ button_frame = ttk.Frame(frame)
55+ button_frame.grid(column=0, row=2, columnspan=2, pady=10)
56+
57+ ttk.Button(button_frame, text="Save", command=self.save).pack(side=tk.LEFT, padx=5)
58+ ttk.Button(button_frame, text="Cancel", command=self.cancel).pack(side=tk.LEFT, padx=5)
59+
60+ self.parent = parent
61+
62+ # Center the window
63+ self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
64+ parent.winfo_rooty()+50))
65+
66+ def save(self):
67+ self.parent.dv_token.set(self.dv_token.get())
68+ self.parent.gh_token.set(self.gh_token.get())
69+ self.destroy()
70+
71+ def cancel(self):
72+ self.destroy()
73+
2674class MainApp(tk.Frame):
2775 def disable_buttons(self):
2876 """
@@ -215,6 +263,7 @@ def load_citation(self):
215263 self.doi_entry.config(state="disabled")
216264 self.download_button.config(state="normal")
217265 self.makeproject_button.config(state="normal")
266+ self.open_folder_button.config(state="normal")
218267 self.menubar.entryconfig("File processing", state=tk.NORMAL)
219268
220269 def download_extract(self):
@@ -254,6 +303,7 @@ def reset_all(self):
254303 # Disable all other buttons
255304 self.download_button.config(state="disabled")
256305 self.makeproject_button.config(state="disabled")
306+ self.open_folder_button.config(state="disabled")
257307 self.menubar.entryconfig("File processing", state=tk.DISABLED)
258308 self.out.delete('1.0', tk.END)
259309
@@ -324,6 +374,10 @@ def close_window(self):
324374 pass
325375
326376 self.parent.destroy()
377+
378+ def configure_tokens(self):
379+ """Open the token configuration window"""
380+ TokenConfig(self)
327381
328382 def __init__(self, parent, *args, **kwargs):
329383 """
@@ -334,13 +388,15 @@ def __init__(self, parent, *args, **kwargs):
334388
335389 # Start with the menu
336390 self.menubar = tk.Menu(self)
337-
391+
338392 self.filemenu = tk.Menu(self.menubar, tearoff=False)
339- #self.filemenu.add_command(label="Save config", command=self.save_config)
393+ self.filemenu.add_command(label="Configure tokens", command=self.configure_tokens)
394+ self.filemenu.add_separator()
340395 self.filemenu.add_command(label="Open config", command=self.open_config)
341396 self.filemenu.add_command(label="Save config as", command=self.save_config_as)
397+ self.filemenu.add_separator()
342398 self.filemenu.add_command(label="Exit dvcurator", command=parent.destroy)
343- self.menubar.add_cascade(label="dvcurator ", menu=self.filemenu)
399+ self.menubar.add_cascade(label="DVCurator ", menu=self.filemenu)
344400
345401 self.editmenu = tk.Menu(self.menubar, tearoff=False)
346402 self.editmenu.add_command(label="Basic file rename", command=self.rename)
@@ -357,39 +413,34 @@ def __init__(self, parent, *args, **kwargs):
357413 parent.config(menu=self.menubar)
358414
359415 # Settings
416+ self.dv_token = tk.StringVar()
417+ self.gh_token = tk.StringVar()
360418 self.github_org = tk.StringVar()
361419 self.curation_repo = tk.StringVar()
362420 self.dataverse_host = tk.StringVar()
363421
364422 settings = tk.Frame(self)
365423
424+ # Main boxes
366425 self.doi=tk.StringVar()
367426 doi_label = ttk.Label(settings, text="Persistent ID (DOI): ")
368427 self.doi_entry = ttk.Entry(settings, textvariable=self.doi)
369428 doi_label.grid(column=1, row=2)
370429 self.doi_entry.grid(column=2, row=2)
371-
372- self.dv_token = tk.StringVar()
373- dv_label = ttk.Label(settings, text="Dataverse token: ")
374- dv_entry = ttk.Entry(settings, textvariable=self.dv_token)
375- dv_label.grid(column=1, row=3)
376- dv_entry.grid(column=2, row=3)
377-
378- self.gh_token = tk.StringVar()
379- gh_label = ttk.Label(settings, text="Github token: ")
380- gh_entry = ttk.Entry(settings, textvariable=self.gh_token)
381- gh_label.grid(column=1, row=4)
382- gh_entry.grid(column=2, row=4)
383-
430+
384431 self.dropbox=tk.StringVar()
385432 dropbox_label = ttk.Label(settings, text="QDR GA folder: ")
386433 self.dropbox_entry = ttk.Button(settings, width=20, text="Select folder", command=self.set_dropbox)
387434 dropbox_label.grid(column=1, row=5)
388435 self.dropbox_entry.grid(column=2, row=5, sticky="w")
389436
437+ self.open_folder_button = ttk.Button(settings, width=20, text="Open project folder",
438+ command=self.open_explorer, state="disabled")
439+ self.open_folder_button.grid(column=2, row=6, sticky="w")
440+
390441 process = tk.Frame(self)
391442 pb_width = 25
392- self.cite_button = ttk.Button(process, width=pb_width, text="(Re)load metadata", command=self.load_citation)
443+ self.cite_button = ttk.Button(process, width=pb_width, text="Load metadata", command=self.load_citation)
393444 self.cite_button.grid(row=1, column=1, sticky="e")
394445 self.download_button = ttk.Button(process, width=pb_width, text="Download and extract", state="disabled", command=self.download_extract)
395446 self.download_button.grid(row=2, column=1, sticky="e")
@@ -405,7 +456,7 @@ def __init__(self, parent, *args, **kwargs):
405456 self.pb = ttk.Progressbar(self, orient="horizontal", length=300, mode="indeterminate")
406457 self.pb.grid(column=1, row=2, columnspan=2, pady=3)
407458
408- self.out = tk.Text(self, width=50 , height=15,
459+ self.out = tk.Text(self, width=70 , height=15,
409460 font=("Courier", "10"))
410461 redir = redirect_text(self.out)
411462 sys.stdout = redir
@@ -428,7 +479,6 @@ def __init__(self, parent, *args, **kwargs):
428479 if os.path.exists(self.local_ini):
429480 self.load_config(self.local_ini)
430481
431-
432482 # save config on exit
433483 parent.protocol("WM_DELETE_WINDOW", self.close_window)
434484
0 commit comments