text stringlengths 1 93.6k |
|---|
super().__init__(master, *args, **kwargs)
|
# initialize variables
|
self.investigation_id = investigation_id
|
self.data = data
|
# initialize database
|
self.db_handler = Database()
|
# hide window in background during drawing and load, to prevent flickering and glitches during frame load
|
self.withdraw()
|
# build and draw the window
|
self.build()
|
# unhide the Toplevel window immediately after draw and load
|
self.after(0, self.deiconify)
|
def build(self):
|
"""Initializes and builds application widgets"""
|
# create input labelframe
|
labelframe_1 = tk.LabelFrame(self, fg='brown')
|
labelframe_1.pack(side="top", expand='yes', fill='both', padx=2, pady=2, anchor="n")
|
# create explanation label
|
self.label = tk.Label(labelframe_1, text='Save As...')
|
self.label.pack(expand=True, fill='x', side="left", padx=2, pady=2)
|
# create data input entry widget
|
self.entry = tk.Entry(labelframe_1)
|
self.entry.pack(expand=True, fill='x', side="left", padx=2, pady=2)
|
# create save button
|
self.save_button = tk.Button(labelframe_1, text="Save", command=self.save_data)
|
self.save_button.pack(expand=False, side="left", padx=2, pady=2, anchor="e")
|
# create cancel button
|
self.cancel_button = tk.Button(labelframe_1, text="Cancel", command=self.quit_save)
|
self.cancel_button.pack(expand=False, side="left", padx=2, pady=2, anchor="e")
|
self.entry.insert(0, self.investigation_id)
|
def save_data(self):
|
"""Stores investigation data within database"""
|
if self.data:
|
try:
|
self.db_handler.store_investigation(self.entry.get(), self.data)
|
messagebox.showinfo("Success", "Successfully saved investigation")
|
self.quit_save()
|
except Exception:
|
messagebox.showerror("Error saving data", "Failed to save data!")
|
self.quit_save()
|
else:
|
messagebox.showinfo("No data", "There is no data to save")
|
def quit_save(self):
|
"""Quits the save window"""
|
self.db_handler.close_connection()
|
self.destroy()
|
class OpenTool(tk.Toplevel):
|
"""Opens a window to retrieve investigation data"""
|
def __init__(self, master=None, *args, **kwargs):
|
"""Initializes Toplevel object and builds interface"""
|
super().__init__(master, *args, **kwargs)
|
# initialize variables
|
self.selection = tk.StringVar(self)
|
# initialize database
|
self.db_handler = Database()
|
# hide window in background during drawing and load, to prevent flickering and glitches during frame load
|
self.withdraw()
|
# build and draw the window
|
self.build()
|
# unhide the Toplevel window immediately after draw and load
|
self.after(0, self.deiconify)
|
def build(self):
|
"""Initializes and builds application widgets"""
|
# create input labelframe
|
labelframe_1 = tk.LabelFrame(self, fg='brown')
|
labelframe_1.pack(side="top", expand='yes', fill='both', padx=2, pady=2, anchor="n")
|
# create explanation label
|
self.label = tk.Label(labelframe_1, text='Load...')
|
self.label.pack(expand=True, fill='x', side="left", padx=2, pady=2)
|
# create data input entry widget
|
self.options = tk.OptionMenu(labelframe_1, self.selection, *self.db_handler.retrieve_investigation_ids(),
|
command=self.open_data)
|
self.options.pack(expand=True, fill='x', side="left", padx=2, pady=2)
|
self.selection.set(self.db_handler.retrieve_investigation_ids()[0])
|
# create save button
|
self.save_button = tk.Button(labelframe_1, text="Open", command=self.open_data)
|
self.save_button.pack(expand=False, side="left", padx=2, pady=2, anchor="e")
|
# create cancel button
|
self.cancel_button = tk.Button(labelframe_1, text="Cancel", command=self.quit_open)
|
self.cancel_button.pack(expand=False, side="left", padx=2, pady=2, anchor="e")
|
def open_data(self, value=None):
|
"""Retrieves investigation data from database"""
|
pockint.treeview.delete(*pockint.treeview.get_children())
|
pockint.id_tracker = {}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.