3 # Electrum - lightweight Bitcoin client
4 # Copyright (C) 2012 thomasv@gitorious
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import sys, time, datetime, re, threading
20 from electrum.i18n import _, set_language
21 from electrum.util import print_error, print_msg, parse_url
22 from electrum.plugins import run_hook
23 import os.path, json, ast, traceback
30 sys.exit("Error: Could not import PyQt4 on Linux systems, you may try 'sudo apt-get install python-qt4'")
32 from PyQt4.QtGui import *
33 from PyQt4.QtCore import *
34 import PyQt4.QtCore as QtCore
36 from electrum import WalletStorage, Wallet
37 from electrum.i18n import _
38 from electrum.bitcoin import MIN_RELAY_TX_FEE
43 sys.exit("Error: Could not import icons_rc.py, please generate it with: 'pyrcc4 icons.qrc -o gui/qt/icons_rc.py'")
46 from main_window import ElectrumWindow
47 from electrum.plugins import init_plugins
49 class Timer(QtCore.QThread):
52 self.emit(QtCore.SIGNAL('timersignal'))
55 class OpenFileEventFilter(QObject):
56 def __init__(self, windows):
57 self.windows = windows
58 super(OpenFileEventFilter, self).__init__()
60 def eventFilter(self, obj, event):
61 if event.type() == QtCore.QEvent.FileOpen:
62 if len(self.windows) >= 1:
63 self.windows[0].set_url(event.url().toEncoded())
70 def __init__(self, config, network, app=None):
71 self.network = network
74 self.efilter = OpenFileEventFilter(self.windows)
76 self.app = QApplication(sys.argv)
77 self.app.installEventFilter(self.efilter)
84 storage = WalletStorage(self.config)
85 if not storage.file_exists:
87 wizard = installwizard.InstallWizard(self.config, self.network, storage)
92 wallet = Wallet(storage)
93 wallet.start_threads(self.network)
95 self.main_window = w = ElectrumWindow(self.config, self.network)
97 # plugins that need to change the GUI do it here
100 w.load_wallet(wallet)
105 self.windows.append(w)
106 if url: w.set_url(url)
113 wallet.stop_threads()