From adafa622c8b3a26babb480c7212ce226ed29d1ae Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 29 Apr 2010 04:24:34 +0400 Subject: [PATCH] Merge start/stop buttons into one --- TODO | 1 - nmea.py | 1 + uberlogger.py | 47 +++++++++++++++++------------------------------ 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/TODO b/TODO index 7143475..f9f283f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -- Single start/stop button - Table for GPS widgets - Clean exit - Enable bluetooth on start diff --git a/nmea.py b/nmea.py index 2082128..2d698eb 100644 --- a/nmea.py +++ b/nmea.py @@ -16,6 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with UberLogger. If not, see . +# import re diff --git a/uberlogger.py b/uberlogger.py index a656749..f3caa7f 100755 --- a/uberlogger.py +++ b/uberlogger.py @@ -181,14 +181,9 @@ class ContainerWidget(QWidget): self.status = "stopped" # UI: header - self.startbutton = QPushButton("Start") - self.startbutton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - self.connect(self.startbutton, SIGNAL('clicked()'), self.start_thread) - - self.stopbutton = QPushButton("Stop") - self.stopbutton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - self.stopbutton.setEnabled(False) - self.connect(self.stopbutton, SIGNAL('clicked()'), self.stop_thread) + self.togglebutton = QPushButton("Start") + self.togglebutton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.connect(self.togglebutton, SIGNAL('clicked()'), self.toggle_thread) self.statuswidget = QLabel() self.statuswidget.setWordWrap(True) @@ -196,8 +191,7 @@ class ContainerWidget(QWidget): self.monitorwidget = QLabel() header = QHBoxLayout() - header.addWidget(self.startbutton) - header.addWidget(self.stopbutton) + header.addWidget(self.togglebutton) header.addWidget(self.statuswidget) self.layout = QVBoxLayout() @@ -212,37 +206,30 @@ class ContainerWidget(QWidget): def __del__(self): self.thread = None - def start_thread(self): - if self.thread is not None: - return - - self.startbutton.setEnabled(False) - self.stopbutton.setEnabled(True) - - self.thread = GPSThread(self.addr, self.name, self) - self.connect(self.thread, SIGNAL("status_updated(QString)"), self.update_status) - self.connect(self.thread, SIGNAL("data_updated(QString)"), self.update_monitor) - self.connect(self.thread, SIGNAL("finished()"), self.gc_thread) - self.thread.start() - - def stop_thread(self): + def toggle_thread(self): if self.thread is None: - return + self.togglebutton.setText("Stop") - self.stopbutton.setEnabled(False) - self.thread.stop() + self.thread = GPSThread(self.addr, self.name, self) + self.connect(self.thread, SIGNAL("status_updated(QString)"), self.update_status) + self.connect(self.thread, SIGNAL("data_updated(QString)"), self.update_monitor) + self.connect(self.thread, SIGNAL("finished()"), self.gc_thread) + self.thread.start() + else: + self.togglebutton.setEnabled(False) + self.thread.stop() def gc_thread(self): self.thread = None # join - self.startbutton.setEnabled(True) - self.stopbutton.setEnabled(False) + self.togglebutton.setText("Start") + self.togglebutton.setEnabled(True) self.update_status() def update_status(self, status = None): if status is not None: self.status = status - self.statuswidget.setText("%s: %s" % (self.name, self.status)) + self.statuswidget.setText("%s\n%s" % (self.name, self.status)) def update_monitor(self, data = None): self.monitorwidget.setText(data) -- 1.7.9.5