aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpux <pux@pux.dom>2020-02-08 09:59:10 +0100
committerpux <pux@pux.dom>2020-02-08 09:59:10 +0100
commit2c72388c50aabd13a0015dedce52f50169e16dee (patch)
tree579ee6dbdc428ff9da325ff260e6ffccc8d58a2c
downloadtimebomb-2c72388c50aabd13a0015dedce52f50169e16dee.tar.gz
timebomb-2c72388c50aabd13a0015dedce52f50169e16dee.tar.bz2
timebomb-2c72388c50aabd13a0015dedce52f50169e16dee.zip
egg timer, first version
-rw-r--r--timebomb.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/timebomb.py b/timebomb.py
new file mode 100644
index 0000000..49729b3
--- /dev/null
+++ b/timebomb.py
@@ -0,0 +1,73 @@
+#!/bin/env python3
+
+# Egg timer
+# 2020-02-08
+# OM
+
+from tkinter import *
+from tkinter import messagebox
+from tkinter import Canvas
+import argparse
+import time
+
+root = Tk()
+
+def message(m, s):
+ screen_width = root.winfo_screenwidth()
+ screen_height = root.winfo_screenheight()
+
+ if screen_width <= 0:
+ screen_width = 1024
+ if screen_height <= 0:
+ screen_height = 768
+
+ c = Canvas(root, bg = "darkred", \
+ width = screen_width, height = screen_height)
+ c.pack()
+ messagebox.showwarning('ALARM', 'Timer ran ' + str(m) + ' m and ' \
+ + str(s) + ' s')
+ #root.mainloop()
+
+def main():
+ argparser = argparse.ArgumentParser()
+ argparser.add_argument(
+ '-s',
+ help='seconds',
+ type=int,
+ nargs=1
+ )
+ argparser.add_argument(
+ '-m',
+ help='minutes',
+ type=int,
+ nargs=1
+ )
+
+ args = argparser.parse_args()
+ if not args.s and not args.m:
+ argparser.print_help()
+
+ time_s = 0
+ time_m = 0
+ if args.s:
+ time_s = abs(args.s[0])
+ if args.m:
+ time_m = abs(args.m[0])
+
+ if args.s or args.m:
+ sleep(m=time_m, s=time_s)
+ message(m=time_m, s=time_s)
+
+def sleep(m, s):
+ print('Start: ' + time.ctime())
+ print('Sleeping for: ' + str(m) \
+ + ' mins and ' + str(s) + ' seconds')
+
+ sleep_time_s = s + (m*60)
+ for s in range(sleep_time_s):
+ pr_m, pr_s = divmod(s, 60)
+ print(' {:02d}:{:02d}'.format(pr_m, pr_s), end='\r')
+ time.sleep(1)
+
+if __name__ == '__main__':
+ main()
in each repos: see "about"-tab (if existing) for more details / README.
mailto contact at omeckman dot net
all timestamps in UTC (German winter time: UTC+01:00, summer time: UTC+02:00)
dark theme is a modded version of: https://gist.github.com/Yoplitein/f4b671a2ec70c9e743fa