Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Don't throw and show error if loading of data was cancelled by the us…
Browse files Browse the repository at this point in the history
…er (#456)

Co-authored-by: Juri <j.robl@osram.com>
  • Loading branch information
Genmutant and Juri committed Jun 13, 2021
1 parent 1ae71fe commit 372a376
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ def __update_kontaktdaten_pfad(self, pfad: str):
except FileNotFoundError:
return

if pfad is None:
return

self.pfad_kontaktdaten = pfad
self.i_kontaktdaten_pfad.setText(self.pfad_kontaktdaten)

Expand Down
6 changes: 5 additions & 1 deletion tools/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import platform
from typing import Optional

from PyQt5 import QtWidgets, uic
from PyQt5.QtWidgets import QMessageBox
Expand Down Expand Up @@ -41,7 +42,7 @@ def oeffne_file_dialog_save(parent_widged: QtWidgets.QWidget, titel: str, standa
return dateipfad


def oeffne_file_dialog_select(parent_widged: QtWidgets.QWidget, titel: str, standard_oeffnungspfad: str, dateityp="JSON Files (*.json)") -> str:
def oeffne_file_dialog_select(parent_widged: QtWidgets.QWidget, titel: str, standard_oeffnungspfad: str, dateityp="JSON Files (*.json)") -> Optional[str]:
"""
Öffnet einen File Dialog um eine existierende Datei auszuwählen
Expand All @@ -65,6 +66,9 @@ def oeffne_file_dialog_select(parent_widged: QtWidgets.QWidget, titel: str, stan
options |= QtWidgets.QFileDialog.DontUseNativeDialog

datei_data = QtWidgets.QFileDialog.getOpenFileName(parent=parent_widged, caption=titel, directory=standard_oeffnungspfad, filter=dateityp, options=options)
# Open dialog wurde abgebrochen
if datei_data == ('', ''):
return None
dateipfad = datei_data[0] # (pfad, typ)

dateipfad = dateipfad.replace("/", os.path.sep)
Expand Down
3 changes: 3 additions & 0 deletions tools/gui/qtkontakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def __lade_einstellungen(self):
info="Die von Ihnen gewählte Datei konne nicht geöffnet werden.")
return

if speicherpfad is None:
return

self.standard_speicherpfad = speicherpfad
self.update_path.emit(speicherpfad)

Expand Down

0 comments on commit 372a376

Please sign in to comment.