Skip to content

Commit

Permalink
Improve file not found handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Sep 21, 2023
1 parent 52eee3f commit ba71bcf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion finalcif/finalcif_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from finalcif.app_path import application_path
from finalcif.appwindow import AppWindow, DEBUG, app
from finalcif.gui.dialogs import show_bug_found_warning
from gui.dialogs import show_general_warning


def my_exception_hook(exctype: Type[BaseException], value: BaseException, error_traceback: traceback,
Expand Down Expand Up @@ -53,8 +54,12 @@ def main():
# windows_style = QStyleFactory.create('Fusion')
# app.setStyle(windows_style)
file = None
if len(sys.argv) > 1 and Path(sys.argv[1]).is_file():
if len(sys.argv) > 1:
file = Path(sys.argv[1])
if not file.is_file():
show_general_warning(warn_text=f'The file {file.resolve().absolute()} \nyou tried to open does not exist.',
window_title='File not found')
file = None
app.setQuitOnLastWindowClosed(True)
w = AppWindow(file=file)
app.setWindowIcon(QIcon(os.path.join(application_path, r'icon/finalcif2.png')))
Expand Down
1 change: 1 addition & 0 deletions finalcif/gui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def show_general_warning(warn_text: str = '', info_text: str = '', window_title=
box.setInformativeText(info_text)
box.setStyleSheet("QLabel{min-width:600 px; font-size: 14px;}")
box.exec()
box.close()


def show_keyword_help(parent, helptext: str, title: str = ''):
Expand Down

0 comments on commit ba71bcf

Please sign in to comment.