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:
@@ -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([])
|
||||
|
||||
Reference in New Issue
Block a user