__init__.py (2524B)
1 #!/usr/bin/env python 2 # 3 # Electrum - lightweight Bitcoin client 4 # Copyright (C) 2012 thomasv@gitorious 5 # 6 # Permission is hereby granted, free of charge, to any person 7 # obtaining a copy of this software and associated documentation files 8 # (the "Software"), to deal in the Software without restriction, 9 # including without limitation the rights to use, copy, modify, merge, 10 # publish, distribute, sublicense, and/or sell copies of the Software, 11 # and to permit persons to whom the Software is furnished to do so, 12 # subject to the following conditions: 13 # 14 # The above copyright notice and this permission notice shall be 15 # included in all copies or substantial portions of the Software. 16 # 17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 # SOFTWARE. 25 # 26 # Kivy GUI 27 28 import sys 29 import os 30 from typing import TYPE_CHECKING 31 32 KIVY_GUI_PATH = os.path.abspath(os.path.dirname(__file__)) 33 os.environ['KIVY_DATA_DIR'] = os.path.join(KIVY_GUI_PATH, 'data') 34 35 try: 36 sys.argv = [''] 37 import kivy 38 except ImportError: 39 # This error ideally shouldn't be raised with pre-built packages 40 sys.exit("Error: Could not import kivy. Please install it using the " 41 "instructions mentioned here `https://kivy.org/#download` .") 42 43 # minimum required version for kivy 44 kivy.require('1.8.0') 45 46 from electrum.logging import Logger 47 48 if TYPE_CHECKING: 49 from electrum.simple_config import SimpleConfig 50 from electrum.daemon import Daemon 51 from electrum.plugin import Plugins 52 53 54 55 56 class ElectrumGui(Logger): 57 58 def __init__(self, config: 'SimpleConfig', daemon: 'Daemon', plugins: 'Plugins'): 59 Logger.__init__(self) 60 self.logger.debug('ElectrumGUI: initialising') 61 self.daemon = daemon 62 self.network = daemon.network 63 self.config = config 64 self.plugins = plugins 65 66 def main(self): 67 from .main_window import ElectrumWindow 68 w = ElectrumWindow(config=self.config, 69 network=self.network, 70 plugins = self.plugins, 71 gui_object=self) 72 w.run() 73 74 def stop(self): 75 pass