Skip to content

Commit

Permalink
fix: handle when end-user cancel save action (#167)
Browse files Browse the repository at this point in the history
fix: handle when end-user cancel save action
  • Loading branch information
Guts authored Nov 20, 2023
2 parents 2bfda13 + d14afd1 commit c6aadd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 14 additions & 3 deletions dicogis/DicoGIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# GUI
from tkinter import ACTIVE, DISABLED, END, NORMAL, Image, StringVar, Tk
from tkinter.messagebox import showerror as avert
from tkinter.messagebox import showinfo
from tkinter.ttk import (
Button,
Combobox,
Expand Down Expand Up @@ -1101,9 +1102,19 @@ def process_files(self):
logger.info("Workbook saved: %s", self.ent_outxl_filename.get())

# quit and exit
utils_global.open_dir_file(saved[1])
self.destroy()
exit()
if saved is not None:
utils_global.open_dir_file(saved[1])
self.destroy()
exit()
else:
showinfo(
title=self.blabla.get(
"no_output_file_selected", "No output file selected"
),
message=self.blabla.get(
"no_output_file_selected", "Dictionary has not been saved."
),
)

def process_db(self, sgbd_reader):
"""Process PostGIS DB analisis."""
Expand Down
5 changes: 5 additions & 0 deletions dicogis/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import logging
import subprocess
from os import R_OK, access, path
from pathlib import Path
from sys import exit
from sys import platform as opersys
from tkinter import ACTIVE, DISABLED
Expand Down Expand Up @@ -98,6 +99,10 @@ def safe_save(
title=dlg_title,
)

if not isinstance(out_name, (str, Path)) and len(str(out_name)):
logger.warning(f"No output file selected: {out_name}")
return None

# check if the extension is correctly indicated
if path.splitext(out_name)[1] != ".xlsx":
out_name = out_name + ".xlsx"
Expand Down

0 comments on commit c6aadd2

Please sign in to comment.