Commits

Yannick Gingras  committed 35ded2e

improved package layout

  • Participants
  • Parent commits cb20e19

Comments (0)

Files changed (6)

 syntax: glob
-ui_*.py
+timeticks/ui_*.py
-ui_timepanalwin.py: ui/ui_timepanalwin.ui
-	pyuic4 -o ui_timepanalwin.py ui/ui_timepanalwin.ui
+timeticks/ui_timetickswin.py: ui/ui_timepanalwin.ui
+	pyuic4 -o timeticks/ui_timetickswin.py ui/ui_timepanalwin.ui
 
 clean:
-	rm -f ui_*.py *.pyc *.pyo
+	cd timeticks && rm -f ui_*.py *.pyc *.pyo

File app.py

-#!/usr/bin/python
-#  Copyright (C) 2009 Yannick Gingras <ygingras@ygingras.net>
-
-#  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-
-#  You should have received a copy of the GNU General Public License
-#  along with this program.  If not, see <http://www.gnu.org/licenses/>
-
-""" Graphical countdown timer for live presentations """
-
-import sys
-from argparse import ArgumentParser
-
-from PyQt4 import QtGui
-from timepanalwin import TimepanalWin
-
-def parse_args():
-    parser = ArgumentParser(description=__doc__)
-    parser.add_argument("-s", "--seconds", dest="seconds", type=int, 
-                        default=300)
-    parser.add_argument("-p", "--popup", dest="popup_mode", 
-                        action="store_true", default=False, 
-                        help="open a popup window when time is over")
-    parser.add_argument("-t", "--title", dest="title", 
-                        default="Time Left", 
-                        help="set title of the timer window to TITLE")
-    return parser.parse_args()
-
-def main():
-    args = parse_args()
-    app = QtGui.QApplication(sys.argv)
-    win = TimepanalWin(args)
-    win.setWindowTitle(args.title)
-    win.show()
-    sys.exit(app.exec_())
-
-if __name__ == "__main__":
-    main()

File talkticks/talkticks.py

+#!/usr/bin/python
+#  Copyright (C) 2009 Yannick Gingras <ygingras@ygingras.net>
+
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>
+
+""" Graphical countdown timer for live presentations """
+
+import sys
+from argparse import ArgumentParser
+
+from PyQt4 import QtGui
+from timepanalwin import TimepanalWin
+
+def parse_args():
+    parser = ArgumentParser(description=__doc__)
+    parser.add_argument("-s", "--seconds", dest="seconds", type=int, 
+                        default=300)
+    parser.add_argument("-p", "--popup", dest="popup_mode", 
+                        action="store_true", default=False, 
+                        help="open a popup window when time is over")
+    parser.add_argument("-t", "--title", dest="title", 
+                        default="Time Left", 
+                        help="set title of the timer window to TITLE")
+    return parser.parse_args()
+
+def main():
+    args = parse_args()
+    app = QtGui.QApplication(sys.argv)
+    win = TimepanalWin(args)
+    win.setWindowTitle(args.title)
+    win.show()
+    sys.exit(app.exec_())
+
+if __name__ == "__main__":
+    main()

File talkticks/talktickswin.py

+#!/usr/bin/python
+#  Copyright (C) 2009 Yannick Gingras <ygingras@ygingras.net>
+
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from time import time
+from pprint import pprint
+
+from PyQt4 import QtGui, QtCore
+from ui_timepanalwin import Ui_TimepanalWin
+
+REFRESH_DELAY = 250
+
+PRESET_TIMES = dict(a=300, 
+                    b=600, 
+                    c=1200, 
+                    d=1500, 
+                    e=1800, 
+                    f=2700, 
+                    g=3600)
+
+class TimepanalWin(QtGui.QDialog, Ui_TimepanalWin):
+    def __init__(self, options):
+        QtGui.QDialog.__init__(self)
+        self.setupUi(self)
+        self.refresh_timer = QtCore.QTimer()
+        self.duration = options.seconds
+        self.start_duration = options.seconds
+        self.start_time = None
+        self.popup_mode = options.popup_mode
+
+        self.connect(self.refresh_timer, 
+                     QtCore.SIGNAL("timeout()"), 
+                     self.update_time_left)
+
+        self.update_time_left()
+
+    def get_time_left(self):
+        if self.start_time:
+            return max(self.start_duration - (time() - self.start_time), 0)
+        else:
+            return self.duration
+
+    def reset_clock(self):
+        self.refresh_timer.stop()
+        self.start_time = None
+        self.start_duration = self.duration
+        self.update_time_left()
+
+    def toggle_timer(self):
+        if self.refresh_timer.isActive():
+            self.start_duration = self.get_time_left()
+            self.refresh_timer.stop()
+        else:
+            self.start_time = time()
+            self.refresh_timer.start(REFRESH_DELAY)
+    
+    def keyPressEvent(self, event):
+        text = unicode(event.text())
+
+        if event.key() == QtCore.Qt.Key_Space:
+            self.toggle_timer()
+            event.accept()
+        elif event.key() in [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]:
+            self.reset_clock()
+            event.accept()
+        elif event.key() == QtCore.Qt.Key_Left:
+            self.start_time += 15
+            self.update_time_left()
+            event.accept()
+        elif event.key() == QtCore.Qt.Key_Right:
+            self.start_time -= 15
+            self.update_time_left()
+            event.accept()
+        elif event.key() == QtCore.Qt.Key_Escape:
+            self.reject()
+            event.accept()
+        elif text in PRESET_TIMES:
+            self.duration = PRESET_TIMES[text]
+            self.reset_clock()
+            self.rescale_font()
+            event.accept()
+
+
+    def cur_msg(self):
+        time_left = self.get_time_left()
+        msg = "%d:%02d" % (time_left / 60, 
+                             time_left % 60)
+        return msg
+
+    def update_time_left(self):
+        time_left = self.get_time_left()
+        self.time_left_lbl.setText(self.cur_msg())
+
+        # we warn that the presentation is about to end with a smooth
+        # color gradiant toward red
+        col = QtGui.QColor()
+        hue = round(1.0 * time_left / self.duration * 120)
+        col.setHsv( hue, 255, 170)
+        palette = self.time_left_lbl.palette()
+        palette.setColor(palette.Foreground, col)
+        self.time_left_lbl.setPalette(palette)
+
+        if time_left <= 0:
+            self.refresh_timer.stop()
+
+            if self.popup_mode:
+                win = self.window()
+                win.show()
+                win.raise_()
+                win.activateWindow()
+                QtGui.QMessageBox.information(win, "Time is over", 
+                                              "Timer ran out of time.")
+                    
+
+    def rescale_font(self):
+        metric = self.time_left_lbl.fontMetrics()
+        font = self.time_left_lbl.font()
+        w = self.size().width()
+        cur_ps = font.pointSize()
+        cur_w = metric.width(self.cur_msg())
+        
+        new_ps = int(0.9 * w * cur_ps / cur_w)
+        font.setPointSize(new_ps)
+        self.time_left_lbl.setFont(font)
+
+    def resizeEvent(self, event):
+        self.rescale_font()
+        event.accept()

File timepanalwin.py

-#!/usr/bin/python
-#  Copyright (C) 2009 Yannick Gingras <ygingras@ygingras.net>
-
-#  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-
-#  You should have received a copy of the GNU General Public License
-#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from time import time
-from pprint import pprint
-
-from PyQt4 import QtGui, QtCore
-from ui_timepanalwin import Ui_TimepanalWin
-
-REFRESH_DELAY = 250
-
-PRESET_TIMES = dict(a=300, 
-                    b=600, 
-                    c=1200, 
-                    d=1500, 
-                    e=1800, 
-                    f=2700, 
-                    g=3600)
-
-class TimepanalWin(QtGui.QDialog, Ui_TimepanalWin):
-    def __init__(self, options):
-        QtGui.QDialog.__init__(self)
-        self.setupUi(self)
-        self.refresh_timer = QtCore.QTimer()
-        self.duration = options.seconds
-        self.start_duration = options.seconds
-        self.start_time = None
-        self.popup_mode = options.popup_mode
-
-        self.connect(self.refresh_timer, 
-                     QtCore.SIGNAL("timeout()"), 
-                     self.update_time_left)
-
-        self.update_time_left()
-
-    def get_time_left(self):
-        if self.start_time:
-            return max(self.start_duration - (time() - self.start_time), 0)
-        else:
-            return self.duration
-
-    def reset_clock(self):
-        self.refresh_timer.stop()
-        self.start_time = None
-        self.start_duration = self.duration
-        self.update_time_left()
-
-    def toggle_timer(self):
-        if self.refresh_timer.isActive():
-            self.start_duration = self.get_time_left()
-            self.refresh_timer.stop()
-        else:
-            self.start_time = time()
-            self.refresh_timer.start(REFRESH_DELAY)
-    
-    def keyPressEvent(self, event):
-        text = unicode(event.text())
-
-        if event.key() == QtCore.Qt.Key_Space:
-            self.toggle_timer()
-            event.accept()
-        elif event.key() in [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]:
-            self.reset_clock()
-            event.accept()
-        elif event.key() == QtCore.Qt.Key_Left:
-            self.start_time += 15
-            self.update_time_left()
-            event.accept()
-        elif event.key() == QtCore.Qt.Key_Right:
-            self.start_time -= 15
-            self.update_time_left()
-            event.accept()
-        elif event.key() == QtCore.Qt.Key_Escape:
-            self.reject()
-            event.accept()
-        elif text in PRESET_TIMES:
-            self.duration = PRESET_TIMES[text]
-            self.reset_clock()
-            self.rescale_font()
-            event.accept()
-
-
-    def cur_msg(self):
-        time_left = self.get_time_left()
-        msg = "%d:%02d" % (time_left / 60, 
-                             time_left % 60)
-        return msg
-
-    def update_time_left(self):
-        time_left = self.get_time_left()
-        self.time_left_lbl.setText(self.cur_msg())
-
-        # we warn that the presentation is about to end with a smooth
-        # color gradiant toward red
-        col = QtGui.QColor()
-        hue = round(1.0 * time_left / self.duration * 120)
-        col.setHsv( hue, 255, 170)
-        palette = self.time_left_lbl.palette()
-        palette.setColor(palette.Foreground, col)
-        self.time_left_lbl.setPalette(palette)
-
-        if time_left <= 0:
-            self.refresh_timer.stop()
-
-            if self.popup_mode:
-                win = self.window()
-                win.show()
-                win.raise_()
-                win.activateWindow()
-                QtGui.QMessageBox.information(win, "Time is over", 
-                                              "Timer ran out of time.")
-                    
-
-    def rescale_font(self):
-        metric = self.time_left_lbl.fontMetrics()
-        font = self.time_left_lbl.font()
-        w = self.size().width()
-        cur_ps = font.pointSize()
-        cur_w = metric.width(self.cur_msg())
-        
-        new_ps = int(0.9 * w * cur_ps / cur_w)
-        font.setPointSize(new_ps)
-        self.time_left_lbl.setFont(font)
-
-    def resizeEvent(self, event):
-        self.rescale_font()
-        event.accept()