add __init__.py to classic, fix a few imports
authorthomasv <thomasv@gitorious>
Wed, 11 Sep 2013 11:43:37 +0000 (13:43 +0200)
committerthomasv <thomasv@gitorious>
Wed, 11 Sep 2013 11:43:37 +0000 (13:43 +0200)
gui/gui_classic/__init__.py [new file with mode: 0644]
gui/gui_classic/main_window.py
gui/gui_classic/network_dialog.py
gui/gui_classic/qrcodewidget.py
gui/gui_classic/qt_util.py
gui/gui_classic/version_getter.py

diff --git a/gui/gui_classic/__init__.py b/gui/gui_classic/__init__.py
new file mode 100644 (file)
index 0000000..3555b1e
--- /dev/null
@@ -0,0 +1,109 @@
+#!/usr/bin/env python
+#
+# Electrum - lightweight Bitcoin client
+# Copyright (C) 2012 thomasv@gitorious
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import sys, time, datetime, re, threading
+from electrum.i18n import _, set_language
+from electrum.util import print_error, print_msg
+import os.path, json, ast, traceback
+import shutil
+
+
+try:
+    import PyQt4
+except:
+    sys.exit("Error: Could not import PyQt4 on Linux systems, you may try 'sudo apt-get install python-qt4'")
+
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+import PyQt4.QtCore as QtCore
+
+from electrum import WalletStorage, Wallet
+from electrum.i18n import _
+from electrum.bitcoin import MIN_RELAY_TX_FEE
+
+try:
+    import icons_rc
+except:
+    sys.exit("Error: Could not import icons_rc.py, please generate it with: 'pyrcc4 icons.qrc -o gui/gui_classic/icons_rc.py'")
+
+from qt_util import *
+from main_window import ElectrumWindow
+
+
+class Timer(QtCore.QThread):
+    def run(self):
+        while True:
+            self.emit(QtCore.SIGNAL('timersignal'))
+            time.sleep(0.5)
+
+class OpenFileEventFilter(QObject):
+    def __init__(self, windows):
+        self.windows = windows
+        super(OpenFileEventFilter, self).__init__()
+
+    def eventFilter(self, obj, event):
+        if event.type() == QtCore.QEvent.FileOpen:
+            if len(self.windows) >= 1:
+                self.windows[0].set_url(event.url().toString())
+                return True
+        return False
+
+
+class ElectrumGui:
+
+    def __init__(self, config, network, app=None):
+        self.network = network
+        self.config = config
+        self.windows = []
+        self.efilter = OpenFileEventFilter(self.windows)
+        if app is None:
+            self.app = QApplication(sys.argv)
+        self.app.installEventFilter(self.efilter)
+
+
+    def main(self, url):
+
+        storage = WalletStorage(self.config)
+        if not storage.file_exists:
+            import installwizard
+            wizard = installwizard.InstallWizard(self.config, self.network, storage)
+            wallet = wizard.run()
+            if not wallet: 
+                exit()
+        else:
+            wallet = Wallet(storage)
+
+        wallet.start_threads(self.network)
+
+        s = Timer()
+        s.start()
+        w = ElectrumWindow(self.config, self.network)
+        w.load_wallet(wallet)
+
+        self.windows.append(w)
+        if url: w.set_url(url)
+        w.app = self.app
+        w.connect_slots(s)
+        w.update_wallet()
+        w.show()
+
+        self.app.exec_()
+
+        wallet.stop_threads()
+
+
index f45cc60..db90a00 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 import sys, time, datetime, re, threading
-from i18n import _, set_language
+from electrum.i18n import _, set_language
 from electrum.util import print_error, print_msg
 import os.path, json, ast, traceback
 import shutil
@@ -47,7 +47,7 @@ from electrum import util, bitcoin, commands, Interface, Wallet
 from electrum import SimpleConfig, Wallet, WalletStorage
 
 
-import bmp, pyqrnative
+from electrum import bmp, pyqrnative
 import exchange_rate
 
 from amountedit import AmountEdit
index 3a65f6c..5b4502d 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 import sys, time, datetime, re, threading
-from i18n import _
+from electrum.i18n import _
 from electrum.util import print_error, print_msg
 import os.path, json, ast, traceback
 
index 8aa8993..feae5f1 100644 (file)
@@ -3,7 +3,7 @@ from PyQt4.QtCore import *
 import PyQt4.QtCore as QtCore
 import PyQt4.QtGui as QtGui
 
-import bmp, pyqrnative
+from electrum import bmp, pyqrnative
 
 
 class QRCodeWidget(QWidget):
index 3c82c7b..b015701 100644 (file)
@@ -1,4 +1,4 @@
-from i18n import _
+from electrum.i18n import _
 from PyQt4.QtGui import *
 from PyQt4.QtCore import *
 import os.path
index ed77bb0..fb443d5 100644 (file)
@@ -22,7 +22,7 @@ from PyQt4.QtGui import *
 from PyQt4.QtCore import *
 import PyQt4.QtCore as QtCore
 
-from i18n import _
+from electrum.i18n import _
 from electrum import ELECTRUM_VERSION
 
 class VersionGetter(threading.Thread):