avoid issues when open/save xml provides no value
This commit is contained in:
parent
f10acbc8d9
commit
b4f4ecd93d
1 changed files with 9 additions and 8 deletions
|
@ -7,13 +7,12 @@ import webbrowser
|
||||||
from tkinter import filedialog, messagebox
|
from tkinter import filedialog, messagebox
|
||||||
|
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
|
from coretk.appdirs import XML_PATH
|
||||||
from coretk.dialogs.sessionoptions import SessionOptionsDialog
|
from coretk.dialogs.sessionoptions import SessionOptionsDialog
|
||||||
from coretk.dialogs.sessions import SessionsDialog
|
from coretk.dialogs.sessions import SessionsDialog
|
||||||
from coretk.setwallpaper import CanvasWallpaper
|
from coretk.setwallpaper import CanvasWallpaper
|
||||||
from coretk.sizeandscale import SizeAndScale
|
from coretk.sizeandscale import SizeAndScale
|
||||||
|
|
||||||
SAVEDIR = "/home/ncs/Desktop/"
|
|
||||||
|
|
||||||
|
|
||||||
def sub_menu_items():
|
def sub_menu_items():
|
||||||
logging.debug("Click on sub menu items")
|
logging.debug("Click on sub menu items")
|
||||||
|
@ -361,22 +360,24 @@ class MenuAction:
|
||||||
def file_save_as_xml(self):
|
def file_save_as_xml(self):
|
||||||
logging.info("menuaction.py file_save_as_xml()")
|
logging.info("menuaction.py file_save_as_xml()")
|
||||||
file_path = filedialog.asksaveasfilename(
|
file_path = filedialog.asksaveasfilename(
|
||||||
initialdir=SAVEDIR,
|
initialdir=str(XML_PATH),
|
||||||
title="Save As",
|
title="Save As",
|
||||||
filetypes=(("EmulationScript XML files", "*.xml"), ("All files", "*")),
|
filetypes=(("EmulationScript XML files", "*.xml"), ("All files", "*")),
|
||||||
defaultextension=".xml",
|
defaultextension=".xml",
|
||||||
)
|
)
|
||||||
|
if file_path:
|
||||||
self.app.core.save_xml(file_path)
|
self.app.core.save_xml(file_path)
|
||||||
|
|
||||||
def file_open_xml(self):
|
def file_open_xml(self):
|
||||||
logging.info("menuaction.py file_open_xml()")
|
logging.info("menuaction.py file_open_xml()")
|
||||||
self.app.is_open_xml = True
|
self.app.is_open_xml = True
|
||||||
file_path = filedialog.askopenfilename(
|
file_path = filedialog.askopenfilename(
|
||||||
initialdir=SAVEDIR,
|
initialdir=str(XML_PATH),
|
||||||
title="Open",
|
title="Open",
|
||||||
filetypes=(("EmulationScript XML File", "*.xml"), ("All Files", "*")),
|
filetypes=(("EmulationScript XML File", "*.xml"), ("All Files", "*")),
|
||||||
)
|
)
|
||||||
# clean up before opening a new session
|
if file_path:
|
||||||
|
logging.info("opening xml: %s", file_path)
|
||||||
self.prompt_save_running_session()
|
self.prompt_save_running_session()
|
||||||
self.app.core.open_xml(file_path)
|
self.app.core.open_xml(file_path)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue