-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimelapse.py
executable file
·52 lines (37 loc) · 1.35 KB
/
timelapse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from ui_timelapse import Ui_MainWindow
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
# Set up the user interface from Designer.
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setWindowTitle("Timelapse Calculator")
self.do_calc()
@pyqtSlot(float)
def on_sleepSpin_valueChanged(self, v):
self.do_calc()
@pyqtSlot(float)
def on_intervalSpin_valueChanged(self, v):
self.do_calc()
@pyqtSlot(int)
def on_framesSpin_valueChanged(self, v):
self.do_calc()
def do_calc(self):
# hours of sleep to seconds of sleep
seconds = self.ui.sleepSpin.value() * 60 * 60
# how many pictures will be taken?
n_pictures = seconds / self.ui.intervalSpin.value()
# those pictures at X fps will yield how many minutes of video?
length = n_pictures / self.ui.framesSpin.value()
minutes, seconds = divmod(length, 60)
self.ui.picsEdit.setText("%d" % n_pictures)
self.ui.lengthEdit.setText("%d:%02d" % (int(minutes), int(seconds)))
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())