1
0

better code organization

function parameters should be lowercase

Fix crash on invalid labels import

Added invoice exporting and reduced duplicate code

Better exception handling

removed json module import

some more cleanup

Cleaned up some stuff

Added exporting contacts
This commit is contained in:
Abdussamad
2018-02-15 18:07:00 +01:00
committed by SomberNight
parent 36a444ba6c
commit 5997c18aef
7 changed files with 111 additions and 75 deletions

View File

@@ -11,6 +11,7 @@ from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from electrum.util import FileImportFailed, FileExportFailed
if platform.system() == 'Windows':
MONOSPACE_FONT = 'Lucida Console'
elif platform.system() == 'Darwin':
@@ -674,6 +675,28 @@ class AcceptFileDragDrop:
def onFileAdded(self, fn):
raise NotImplementedError()
def import_meta_gui(electrum_window, title, importer, on_success):
filename = electrum_window.getOpenFileName(_("Open {} file").format(title) , "*.json")
if not filename:
return
try:
importer(filename)
except FileImportFailed as e:
electrum_window.show_critical(str(e))
else:
electrum_window.show_message(_("Your {} were successfully imported" ).format(title))
on_success()
def export_meta_gui(electrum_window, title, exporter):
filename = electrum_window.getSaveFileName(_("Select file to save your {}").format(title), 'electrum_{}.json'.format(title), "*.json")
if not filename:
return
try:
exporter(filename)
except FileExportFailed as e:
electrum_window.show_critical(str(e))
else:
electrum_window.show_message(_("Your {0} were exported to '{1}'").format(title,str(filename)))
if __name__ == "__main__":
app = QApplication([])