Sunday, 15 February 2015

python 2.7 - take user input and activate and de activate a function at specified times -


OK, so I'm building a time-lapse program to run my pie. I have used a typewriter entry widget for one time and one time to get another entry widget and then save them to a list.

The problem is that I am looking for a way to compare these variables against one clock and one incident triggers and is idle at fixed time.

Actually the user enters the logic and the action is activated for the camera at 13:00, and then at 7:00, then it becomes inactive at 13:00 A simple boolean can be turned on and off to activate the code for the camera.

Everything else is working, but it is not the best way to compare variables against time, badly.

Any help please

================

Update:

First of all thank you for your reply, I have made this test app and how it works, how do I want to do it now

>  import time, as a teak camera Tanker = Fault on_time = '17: 48 'off_time = '07: 55' class app (): def __init __ (self): itself .root = tk.Tk () self.root.geometry ("50x50") self. Label = tk.Label (text = "") self.label.pack () self.checkTime () self.root.mainloop () def check time (auto): time_en = time.strftime ("% H:% M") Self.root.afte R (1000, self.checkTime) if time_now & gt; = On_time and time_now & lt; = Off_time: camera = true self.label.configure (text = camera) print camera and: camera = wrong self.label.configure (text = camera) print camera app = app ()  

It works fine if on_time is less than off_time but not in other way, so if I want the camera to be closed at 7:00 and at 17:00, the job is fine but if I do it at 17:00 I want it and it will not work at 07:00.

I need to know just one better way to compare the variable Thank you

Thanks

The best thing I can suggest is a background Thread should be in which there is an infinite loop which is checking time and setting boolean values ​​in proper form.


No comments:

Post a Comment