print traceback in waiting dialog
[electrum-nvc.git] / gui / qt / util.py
index 9842f05..94a0898 100644 (file)
@@ -3,7 +3,8 @@ from PyQt4.QtGui import *
 from PyQt4.QtCore import *
 import os.path
 import time
-
+import traceback
+import sys
 import threading
 
 class WaitingDialog(QThread):
@@ -21,11 +22,20 @@ class WaitingDialog(QThread):
         self.d.show()
 
     def run(self):
-        self.result = self.run_task()
+        self.error = None
+        try:
+            self.result = self.run_task()
+        except Exception as e:
+            traceback.print_exc(file=sys.stdout)
+            self.error = str(e)
         self.d.emit(SIGNAL('done'))
 
     def close(self):
         self.d.accept()
+        if self.error:
+            QMessageBox.warning(self.parent, _('Error'), self.error, _('OK'))
+            return
+
         if self.on_complete:
             self.on_complete(*self.result)
 
@@ -98,6 +108,7 @@ def ok_cancel_buttons(dialog, ok_label=_("OK") ):
     return hbox
 
 def text_dialog(parent, title, label, ok_label, default=None):
+    from qrtextedit import QRTextEdit
     dialog = QDialog(parent)
     dialog.setMinimumWidth(500)
     dialog.setWindowTitle(title)
@@ -105,7 +116,7 @@ def text_dialog(parent, title, label, ok_label, default=None):
     l = QVBoxLayout()
     dialog.setLayout(l)
     l.addWidget(QLabel(label))
-    txt = QTextEdit()
+    txt = QRTextEdit()
     if default:
         txt.setText(default)
     l.addWidget(txt)