URI: 
       tDefer discovery of exchange rate until later to make program startup faster. - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 8efc081ded281136bab4f7d9cc9b7fb76993dc47
   DIR parent 8d75b68152124a04194fa280b4c9c20bdb61d783
  HTML Author: Amir Taaki <genjix@riseup.net>
       Date:   Sat, 30 Jun 2012 15:54:02 +0200
       
       Defer discovery of exchange rate until later to make program startup faster.
       
       Diffstat:
         M lib/exchange_rate.py                |       7 ++++++-
         M lib/gui_lite.py                     |      18 ++++++++++--------
       
       2 files changed, 16 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/lib/exchange_rate.py b/lib/exchange_rate.py
       t@@ -6,9 +6,13 @@ class Exchanger:
        
            def __init__(self, quote_currencies, refresh_balance):
                self.refresh_balance = refresh_balance
       -        self.quote_currencies = {}
       +        self.quote_currencies = None
        
            def exchange(self, btc_amount, quote_currency):
       +        if self.quote_currencies is None:
       +            return None
       +        if quote_currency not in self.quote_currencies:
       +            return None
                return btc_amount * self.quote_currencies[quote_currency]
        
            def discovery(self):
       t@@ -22,6 +26,7 @@ class Exchanger:
                # 2 = BTC:EUR
                # 3 = BTC:USD
                # 4 = BTC:PLN
       +        self.quote_currencies = {}
                try:
                    self.quote_currencies["GBP"] = self.lookup_rate(response, 1)
                    self.quote_currencies["EUR"] = self.lookup_rate(response, 2)
   DIR diff --git a/lib/gui_lite.py b/lib/gui_lite.py
       t@@ -88,10 +88,10 @@ class MiniWindow(QDialog):
                self.quote_currencies = ("EUR", "USD", "GBP")
                self.exchanger = exchange_rate.Exchanger(self.quote_currencies,
                                                         self.refresh_balance)
       +        QTimer.singleShot(1000, self.exchanger.discovery)
        
                self.balance_label = BalanceLabel(self.change_quote_currency)
                self.balance_label.setObjectName("balance_label")
       -        self.exchanger.discovery()
        
                copy_button = QPushButton(_("&Copy Address"))
                copy_button.setObjectName("copy_button")
       t@@ -174,13 +174,15 @@ class MiniWindow(QDialog):
                self.btc_balance = btc_balance
                quote_currency = self.quote_currencies[0]
                quote_balance = self.exchanger.exchange(btc_balance, quote_currency)
       -        quote_balance = "%.2f" % (quote_balance / bitcoin(1))
       +        if quote_balance is None:
       +            quote_text = ""
       +        else:
       +            quote_text = "(%.2f %s)" % ((quote_balance / bitcoin(1)),
       +                                      quote_currency)
                btc_balance = "%.2f" % (btc_balance / bitcoin(1))
       -        self.balance_label.set_balances( \
       -            btc_balance, quote_balance, quote_currency)
       +        self.balance_label.set_balances(btc_balance, quote_text)
                main_account_info = \
       -            "Checking - %s BTC (%s %s)" % (btc_balance,
       -                                           quote_balance, quote_currency)
       +            "Checking - %s BTC %s" % (btc_balance, quote_text)
                self.setWindowTitle("Electrum - %s" % main_account_info)
                self.accounts_selector.clear()
                self.accounts_selector.addAction("%s" % main_account_info)
       t@@ -211,8 +213,8 @@ class BalanceLabel(QLabel):
                super(QLabel, self).__init__(_("Connecting..."), parent)
                self.change_quote_currency = change_quote_currency
        
       -    def set_balances(self, btc_balance, quote_balance, quote_currency):
       -        label_text = "<span style='font-size: 16pt'>%s</span> <span style='font-size: 10pt'>BTC</span> <span style='font-size: 10pt'>(%s %s)</span>" % (btc_balance, quote_balance, quote_currency)
       +    def set_balances(self, btc_balance, quote_text):
       +        label_text = "<span style='font-size: 16pt'>%s</span> <span style='font-size: 10pt'>BTC</span> <span style='font-size: 10pt'>%s</span>" % (btc_balance, quote_text)
                self.setText(label_text)
        
            def mousePressEvent(self, event):