Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Tkinter as tk
- import RPi.GPIO as GPIO
- # Warnungen ausschalten
- GPIO.setwarnings(False)
- #Boardmodus
- GPIO.setmode(GPIO.BCM)
- #setzen des GPIO 23 auf HIGH
- GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- nummer = 0
- def update_timeText():
- if (state):
- global timer
- timer[2] += 1
- if (timer[2] >= 100):
- timer[2] = 0
- timer[1] += 1
- if (timer[1] >= 60):
- timer[0] += 1
- timer[1] = 0
- timeString = pattern.format(timer[0], timer[1], timer[2])
- timeText.configure(text=timeString)
- root.after(10, update_timeText)
- def start():
- global state
- GPIO.wait_for_edge(22, GPIO.FALLING)
- state = True
- def stop():
- global state
- state = False
- def exist():
- root.destroy()
- def zeiten():
- global timer
- global nummer
- print "Dauer: ", timer
- file = open("log.txt", "a")
- file.write("Teil" + " #" + repr(nummer) + " " + repr(timer) + '\n')
- nummer += 1
- timer = [0, 0, 0]
- timeText.configure(text='00:00:00')
- state = False
- root = tk.Tk()
- self = root
- self.overrideredirect(1)
- w, h = self.winfo_screenwidth(), self.winfo_screenheight()
- self.geometry("%dx%d+0+0" % (w, h))
- root.wm_title('Stoppuhr')
- timer = [0, 0, 0]
- pattern = '{0:02d}:{1:02d}:{2:02d}'
- timeText = tk.Label(root, text="00:00:00", font=("Helvetica", 150))
- timeText.pack()
- startButton = tk.Button(root, text='Start', command=start)
- startButton.pack()
- pauseButton = tk.Button(root, text='Stop', command=stop and zeiten)
- pauseButton.pack()
- quitButton = tk.Button(root, text='Quit', command=exist)
- quitButton.pack()
- update_timeText()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement