diff --git a/Pipfile b/Pipfile new file mode 100644 index 00000000..e69de29b diff --git a/daemon/core/gui/coreclient.py b/daemon/core/gui/coreclient.py index 46009324..f4371715 100644 --- a/daemon/core/gui/coreclient.py +++ b/daemon/core/gui/coreclient.py @@ -93,6 +93,9 @@ class CoreClient: self.handling_throughputs = None self.handling_events = None + self.xml_dir = None + self.xml_file = None + def reset(self): # helpers self.interfaces_manager.reset() diff --git a/daemon/core/gui/dialogs/sessions.py b/daemon/core/gui/dialogs/sessions.py index f717462d..6efe598e 100644 --- a/daemon/core/gui/dialogs/sessions.py +++ b/daemon/core/gui/dialogs/sessions.py @@ -189,6 +189,8 @@ class SessionsDialog(Dialog): logging.error("querysessiondrawing.py invalid state") def join_session(self, session_id: int): + if self.app.core.xml_file: + self.app.core.xml_file = None self.app.statusbar.progress_bar.start(5) task = BackgroundTask(self.app, self.app.core.join_session, args=(session_id,)) task.start() diff --git a/daemon/core/gui/graph/graph.py b/daemon/core/gui/graph/graph.py index 2ae47b83..76dc427f 100644 --- a/daemon/core/gui/graph/graph.py +++ b/daemon/core/gui/graph/graph.py @@ -133,7 +133,7 @@ class CanvasGraph(tk.Canvas): self.bind("", lambda e: self.scan_mark(e.x, e.y)) self.bind("", lambda e: self.scan_dragto(e.x, e.y, gain=1)) - def hide_context(self): + def hide_context(self, event=None): if self.context: self.context.unpost() self.context = None @@ -642,9 +642,10 @@ class CanvasGraph(tk.Canvas): if canvas_node: logging.debug("node context: %s", selected) self.context = canvas_node.create_context() + self.context.bind("", self.hide_context) self.context.post(event.x_root, event.y_root) - else: - self.hide_context() + # else: + # self.hide_context() def press_delete(self, event: tk.Event): """ diff --git a/daemon/core/gui/menuaction.py b/daemon/core/gui/menuaction.py index 4edc4797..5767d4b1 100644 --- a/daemon/core/gui/menuaction.py +++ b/daemon/core/gui/menuaction.py @@ -3,6 +3,7 @@ The actions taken when each menubar option is clicked """ import logging +import os import tkinter as tk import webbrowser from tkinter import filedialog, messagebox @@ -61,8 +62,11 @@ class MenuAction: def file_save_as_xml(self, event: tk.Event = None): logging.info("menuaction.py file_save_as_xml()") + init_dir = self.app.core.xml_dir + if not init_dir: + init_dir = str(XMLS_PATH) file_path = filedialog.asksaveasfilename( - initialdir=str(XMLS_PATH), + initialdir=init_dir, title="Save As", filetypes=(("EmulationScript XML files", "*.xml"), ("All files", "*")), defaultextension=".xml", @@ -71,14 +75,19 @@ class MenuAction: self.app.core.save_xml(file_path) def file_open_xml(self, event: tk.Event = None): + init_dir = self.app.core.xml_dir + if not init_dir: + init_dir = str(XMLS_PATH) logging.info("menuaction.py file_open_xml()") file_path = filedialog.askopenfilename( - initialdir=str(XMLS_PATH), + initialdir=init_dir, title="Open", filetypes=(("XML Files", "*.xml"), ("All Files", "*")), ) if file_path: logging.info("opening xml: %s", file_path) + self.app.core.xml_file = file_path + self.app.core.xml_dir = str(os.path.dirname(file_path)) self.prompt_save_running_session() self.app.statusbar.progress_bar.start(5) task = BackgroundTask(self.app, self.app.core.open_xml, args=(file_path,)) diff --git a/daemon/core/gui/menubar.py b/daemon/core/gui/menubar.py index c8908333..afaf2b1a 100644 --- a/daemon/core/gui/menubar.py +++ b/daemon/core/gui/menubar.py @@ -52,11 +52,9 @@ class Menubar(tk.Menu): label="Open...", command=self.menuaction.file_open_xml, accelerator="Ctrl+O" ) self.app.bind_all("", self.menuaction.file_open_xml) - menu.add_command( - label="Save", accelerator="Ctrl+S", command=self.menuaction.file_save_as_xml - ) + menu.add_command(label="Save", accelerator="Ctrl+S", command=self.save) menu.add_command(label="Reload", underline=0, state=tk.DISABLED) - self.app.bind_all("", self.menuaction.file_save_as_xml) + self.app.bind_all("", self.save) menu.add_separator() menu.add_command(label="Export Python script...", state=tk.DISABLED) menu.add_command(label="Execute XML or Python script...", state=tk.DISABLED) @@ -410,3 +408,10 @@ class Menubar(tk.Menu): ) menu.add_command(label="About", command=self.menuaction.show_about) self.add_cascade(label="Help", menu=menu) + + def save(self): + xml_file = self.app.core.xml_file + if xml_file: + self.app.core.save_xml(xml_file) + else: + self.menuaction.file_save_as_xml()