use an Event to signal when to redraw the gui

This commit is contained in:
ecdsa 2013-04-27 19:17:36 +02:00
parent df13564155
commit 7d1075d85d
1 changed files with 6 additions and 3 deletions

View File

@ -16,7 +16,7 @@
# 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
import sys, time, datetime, re, threading
from i18n import _, set_language
from electrum.util import print_error, print_msg
import os.path, json, ast, traceback
@ -268,7 +268,8 @@ class ElectrumWindow(QMainWindow):
self.init_plugins()
self.create_status_bar()
self.wallet.interface.register_callback('updated', lambda: self.emit(QtCore.SIGNAL('update_wallet')))
self.need_update = threading.Event()
self.wallet.interface.register_callback('updated', lambda: self.need_update.set())
self.wallet.interface.register_callback('banner', lambda: self.emit(QtCore.SIGNAL('banner_signal')))
self.wallet.interface.register_callback('disconnected', lambda: self.emit(QtCore.SIGNAL('update_status')))
self.wallet.interface.register_callback('disconnecting', lambda: self.emit(QtCore.SIGNAL('update_status')))
@ -303,7 +304,6 @@ class ElectrumWindow(QMainWindow):
QShortcut(QKeySequence("Ctrl+PgUp"), self, lambda: tabs.setCurrentIndex( (tabs.currentIndex() - 1 )%tabs.count() ))
QShortcut(QKeySequence("Ctrl+PgDown"), self, lambda: tabs.setCurrentIndex( (tabs.currentIndex() + 1 )%tabs.count() ))
self.connect(self, QtCore.SIGNAL('update_wallet'), self.update_wallet)
self.connect(self, QtCore.SIGNAL('update_status'), self.update_status)
self.connect(self, QtCore.SIGNAL('banner_signal'), lambda: self.console.showMessage(self.wallet.interface.banner) )
self.history_list.setFocus(True)
@ -406,6 +406,9 @@ class ElectrumWindow(QMainWindow):
self.previous_payto_e=''
def timer_actions(self):
if self.need_update.is_set():
self.update_wallet()
self.need_update.clear()
self.run_hook('timer_actions')
def format_amount(self, x, is_diff=False):