diff options
Diffstat (limited to 'QtUI.py')
-rw-r--r-- | QtUI.py | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/QtUI.py b/QtUI.py index 071dab4..c772abf 100644 --- a/QtUI.py +++ b/QtUI.py @@ -6,13 +6,13 @@ import gobject # Qt stuff from PySide.QtCore import Signal, Qt from PySide.QtGui import QApplication, QWidget, QMainWindow, QVBoxLayout -from PySide.QtGui import QLabel, QPushButton, QCheckBox, QIcon +from PySide.QtGui import QLabel, QPushButton, QCheckBox, QIcon, QAction class UI(gobject.GObject): __gsignals__ = { 'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) } - + def __init__(self,args,continuous): self.continuous = continuous gobject.GObject.__init__(self) @@ -25,7 +25,7 @@ class UI(gobject.GObject): self.window.setMaximumSize(400,200) center = QWidget() self.window.setCentralWidget(center) - + layout = QVBoxLayout() center.setLayout(layout) #make a listen/stop button @@ -34,15 +34,25 @@ class UI(gobject.GObject): #make a continuous button self.ccheckbox = QCheckBox("Continuous Listen") layout.addWidget(self.ccheckbox) - - #connect the buttonsc + + #connect the buttons self.lsbutton.clicked.connect(self.lsbutton_clicked) self.ccheckbox.clicked.connect(self.ccheckbox_clicked) - + #add a label to the UI to display the last command self.label = QLabel() layout.addWidget(self.label) - + + #add the actions for quiting + quit_action = QAction(self.window) + quit_action.setShortcut('Ctrl+Q') + quit_action.triggered.connect(self.accel_quit) + self.window.addAction(quit_action) + + def accel_quit(self): + #emit the quit + self.emit("command", "quit") + def ccheckbox_clicked(self): checked = self.ccheckbox.isChecked() if checked: @@ -53,10 +63,10 @@ class UI(gobject.GObject): else: self.lsbutton.setEnabled(True) self.emit('command', "continuous_stop") - + def lsbutton_stopped(self): self.lsbutton.setText("Listen") - + def lsbutton_clicked(self): val = self.lsbutton.text() if val == "Listen": @@ -67,7 +77,7 @@ class UI(gobject.GObject): else: self.lsbutton_stopped() self.emit("command", "stop") - + def run(self): self.window.show() if self.continuous: @@ -75,17 +85,13 @@ class UI(gobject.GObject): self.ccheckbox_clicked() self.app.exec_() self.emit("command", "quit") - + def finished(self, text): print text #if the continuous isn't pressed if not self.ccheckbox.isChecked(): self.lsbutton_stopped() self.label.setText(text) - - def quit(self): - #sys.exit() - pass def set_icon(self, icon): - self.window.setWindowIcon(QIcon(icon)) + self.window.setWindowIcon(QIcon(icon)) |