GUI manage json files
This commit is contained in:
parent
5a271dce1d
commit
a110f3f2c5
@ -107,7 +107,10 @@ class UserInterface:
|
||||
|
||||
def store(self, filename: str, name: str) -> None:
|
||||
'''Stores a relation to file.'''
|
||||
raise Exception('Not implemented')
|
||||
if filename.endswith('.csv'):
|
||||
self.relations[name].save_csv(filename)
|
||||
else:
|
||||
self.relations[name].save(filename)
|
||||
|
||||
def session_dump(self, filename: Optional[str] = None) -> Optional[str]:
|
||||
'''
|
||||
|
@ -292,13 +292,13 @@ class relForm(QtWidgets.QMainWindow):
|
||||
filename = QtWidgets.QFileDialog.getSaveFileName(
|
||||
self, QtWidgets.QApplication.translate("Form", "Save Relation"),
|
||||
"",
|
||||
QtWidgets.QApplication.translate("Form", "Relations (*.csv)")
|
||||
QtWidgets.QApplication.translate("Form", "Json relations (*.json);;CSV relations (*.csv)")
|
||||
)[0]
|
||||
if (len(filename) == 0): # Returns if no file was selected
|
||||
return
|
||||
|
||||
relname = self.ui.lstRelations.selectedItems()[0].text()
|
||||
self.user_interface.relations[relname].save(filename)
|
||||
self.user_interface.store(filename, relname)
|
||||
|
||||
def unloadRelation(self):
|
||||
for i in self.ui.lstRelations.selectedItems():
|
||||
@ -422,7 +422,7 @@ class relForm(QtWidgets.QMainWindow):
|
||||
"",
|
||||
QtWidgets.QApplication.translate(
|
||||
"Form",
|
||||
"Relations (*.csv);;Text Files (*.txt);;All Files (*)"
|
||||
"Relations (*.json *.csv);;Text Files (*.txt);;All Files (*)"
|
||||
)
|
||||
)
|
||||
filenames = f[0]
|
||||
|
Loading…
Reference in New Issue
Block a user