vampite
Posts: 2
Joined: Mon Aug 22, 2016 10:02 pm

Countdown timer that turns off with password

Mon Aug 22, 2016 10:07 pm

Hi everyone, I'm a total Pi Noob, and I'm trying to learn as much as I can to use the Pi for the family business (my family owns an escape room business).

Currently, I'm looking to either find or code an app that does two things:
1. Displays a countdown timer starting at 60 minutes counting down to zero
2. Has a box to input a password: when the correct password is input the clock will stop counting down.

Does anyone know of an app that does this already, or if not, can someone point me in some starting direction as to how I'd write code to do this?

Thanks!

Heater
Posts: 10006
Joined: Tue Jul 17, 2012 3:02 pm

Re: Countdown timer that turns off with password

Mon Aug 22, 2016 10:46 pm

No idea about your question but:

"my family owns an escape room business"

Good grief, that is curious. What is an "escape room"? Or an "escape room business"? You say that as if it is some kind of normal thing like "my family owns a trucking company"

I mean, perhaps I need to call you and get one. :)

Get me an escape room and I will make your count down timer for free!

vampite
Posts: 2
Joined: Mon Aug 22, 2016 10:02 pm

Re: Countdown timer that turns off with password

Tue Aug 23, 2016 1:31 am

Heater wrote:Good grief, that is curious. What is an "escape room"? Or an "escape room business"? You say that as if it is some kind of normal thing like "my family owns a trucking company"
Ahaha, it is a pretty normal thing in my city, I forget that not everyone has heard about it :P An escape room is basically a room that a group of 4 - 8 people are "locked" into (the door is never actually locked) and you have to solve a series of puzzles and riddles to get out before the time limit (usually 60 minutes). For example, you're locked in a spaceship with only 60 minutes of oxygen, or you have 60 minutes to get out of prison, that kind of thing. You should give one a try if there are any nearby you, I think they're a blast!

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Countdown timer that turns off with password

Tue Aug 23, 2016 6:56 am

Here's a one hour counter

Code: Select all

#!/usr/bin/python

from Tkinter import *
import time

rootWindow = Tk()
rootWindow.title('Tk Timer')
rootWindow.geometry("300x250")
rootWindow.resizable(0,0)

defaultColour = rootWindow.cget("bg")

time1 = ''
prevSec = ''
mins = 0
secs = 0
hours = 1
running = False
#clock = Label(rootWindow, font=('fixed', 20, 'bold'))
clock = Label(rootWindow, font=('fixed', 20))
clock.grid(row = 1, column = 2, padx = 5, pady = (5,2))

def tick():
    global prevSec, time1, secs, mins, hours, running
    # get the current local time from the PC
#    time2 = time.strftime('%Y/%m/%d %H:%M:%S')
    if running:
        newSec = time.strftime('%S')
    else:
        newSec = ''
        prevSec = ''
    if newSec != prevSec:
        prevSec = newSec
        secs = secs - 1
        if secs < 0:
            secs = 59
            mins = mins - 1
            if mins < 0:
                mins = 59
                hours = hours - 1
                if hours < 0:
                    hours = 0
                    mins = 0
                    secs = 0
                    clock.config(bg='dark red')
    time2 = '%02d:%02d:%02d' % (hours, mins, secs)
    # if time string has changed, update it
    if time2 != time1:
        time1 = time2
        clock.config(text=time2)
    # calls itself every 200 milliseconds
    # to update the time display as needed
    # could use >200 ms, but display gets jerky
    clock.after(200, tick)

tick()

def start_btn():
    global running
    clock.config(bg='green')
    btn_start.config(state='disabled',background=defaultColour)
    btn_stop.config(state='normal',bg='dark red')
    btn_reset.config(state='disabled')
    running = True

def stop_btn():
    global running
    clock.config(bg='dark red')
    btn_start.config(state='normal',bg='green')
    btn_stop.config(state='disabled',bg=defaultColour)
    btn_reset.config(state='normal')
    running = False

def reset_btn():
    global prevSec, time1, secs, mins, hours, running
    clock.config(bg=defaultColour)
    hours = 2
    mins = 0
    secs = 0
    prevSec = ''
    time1 = ''
    running = False
    btn_stop.config(state='disabled',bg=defaultColour)
    btn_start.config(state='normal',bg='green')
    btn_reset.config(state='disabled')

btn_reset = Button(rootWindow, state='disabled', text = 'Reset', command = reset_btn)
btn_reset.grid(sticky=EW, row = 1, column = 3, padx = 5, pady = (5,2))
btn_start = Button(rootWindow, text = 'Start', bg='green', command = start_btn)
btn_start.grid(sticky=EW, row = 2, column = 3, padx = 5, pady = 2)
btn_stop = Button(rootWindow, state='disabled', text = 'Stop', command = stop_btn)
btn_stop.grid(sticky=EW, row = 3, column = 3, padx = 5, pady = (2,5))
btn_exit = Button(rootWindow, text = 'exit', command = exit)
btn_exit.grid(row = 4, column = 1, padx = 5, pady = 5)

rootWindow.mainloop()
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Heater
Posts: 10006
Joined: Tue Jul 17, 2012 3:02 pm

Re: Countdown timer that turns off with password

Tue Aug 23, 2016 10:58 am

vampite,

Thanks for the explanation. Never heard of such a thing. What city is that?

jgreen71
Posts: 89
Joined: Wed May 01, 2013 12:29 pm
Location: Clarksville, IN

Re: Countdown timer that turns off with password

Tue Aug 23, 2016 2:23 pm

One company https://breakoutgames.com has locations in over 50 US cities.

Heater
Posts: 10006
Joined: Tue Jul 17, 2012 3:02 pm

Re: Countdown timer that turns off with password

Tue Aug 23, 2016 5:38 pm

Ah, I get it. This is all about corporate "team building".

No thanks.

fabycyberbob
Posts: 40
Joined: Mon Nov 07, 2016 3:58 pm

Re: Countdown timer that turns off with password

Fri Sep 07, 2018 2:35 pm

Hi ALL,

THIS is EXACTLY what I need :D :D , but i don't understand if finally, the program attached works or not???!!!! :?:

Where is the STOP PASSWORD line program??


With Raspbian STRETCH Full, I need, possible a FULL SCREEN (OR biggest in a monitor 800x600) countdown from 45 minute.
Raspbian STOP the countdown and shows the remain time if I press a single letter (IF IS MORE EASY TO DO) or a short word as "stop password" I decided!!!

Then I exit and relunch the program manually.

Could someome help me??

Thanls in advance!

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Countdown timer that turns off with password

Fri Sep 07, 2018 3:53 pm

fabycyberbob wrote:
Fri Sep 07, 2018 2:35 pm
Where is the STOP PASSWORD line program??
Time to find your coding pad and sharpen your coding pencil.

You should be able to hack something like https://stackoverflow.com/questions/308 ... ord-system into the code sample I gave earlier.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Return to “General programming discussion”