1. Yannick Gingras
  2. talkticks

Commits

Yannick Gingras  committed e37068d

added popup-mode for notifications

  • Participants
  • Parent commits fa063ae
  • Branches default

Comments (0)

Files changed (2)

File app.py

View file
     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")
     return parser.parse_args()
 
 def main():

File timepanalwin.py

View file
         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.start_time -= 15
             self.update_time_left()
             event.accept()
+        elif event.key() == QtCore.Qt.Key_Escape:
+            self.reject()
 
     
     def update_time_left(self):
         palette = self.time_left_lbl.palette()
         palette.setColor(palette.Foreground, col)
 
+        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 resizeEvent(self, event):
         metric = self.time_left_lbl.fontMetrics()
         font = self.time_left_lbl.font()