diff options
author | jerous <jerous@gmail.com> | 2008-05-29 16:07:47 +0200 |
---|---|---|
committer | jerous <jerous@gmail.com> | 2008-05-29 16:07:47 +0200 |
commit | 32c283aa6e020249e9f5416bd42a15c22fb12ed6 (patch) | |
tree | bf059039114388f3e1e06fdcd2ce7a2e6c396019 /winConnect.py | |
parent | 375fbbe6813ce6ebb092550a71fe0d66a4c0b9ba (diff) |
better info when connecting/connected
Diffstat (limited to 'winConnect.py')
-rw-r--r-- | winConnect.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/winConnect.py b/winConnect.py index d6ee90c..8b20dee 100644 --- a/winConnect.py +++ b/winConnect.py @@ -2,6 +2,7 @@ from PyQt4 import QtGui, QtCore import time from clMonty import monty from misc import * +from traceback import print_exc class winConnect(QtGui.QWidget): txtHost=None @@ -30,17 +31,20 @@ class winConnect(QtGui.QWidget): self.center() doEvents() + monty.addListener('onReady', self.onReady) monty.addListener('onConnect', self.onConnect) monty.addListener('onDisconnect', self.onDisconnect) def center(self): screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() - self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) + self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2+100) def monitor(self): + self.txtHost.setEnabled(True) + self.txtPort.setEnabled(True) if self._timerID==None: - self._timerID=self.startTimer(500) + self._timerID=self.startTimer(200) if self.isVisible()==False: self.show() self.activateWindow() @@ -52,9 +56,14 @@ class winConnect(QtGui.QWidget): if self._timerID: self.killTimer(self._timerID) self._timerID=None - self.hide() + self.lblInfo.setText('Connected!\nRestoring library ...') + self.txtHost.setEnabled(False) + self.txtPort.setEnabled(False) doEvents() + def onReady(self, params): + self.hide() + def onDisconnect(self, params): self.monitor() @@ -62,10 +71,14 @@ class winConnect(QtGui.QWidget): host=str(self.txtHost.text()) try: port=int(self.txtPort.text()) - self.lblInfo.setText('Disconnected.\nTrying to connect to '+host+':'+str(port)+' ...') - monty.init(host, port) + self.lblInfo.setText('Trying to connect to '+host+':'+str(port)+' ...') + doEvents() + monty.connect(host, port) + doEvents() except: + print_exc() self.lblInfo.setText('Invalid port.') + doEvents() def windowActivationChange(self, bool): self.activateWindow() |