Alternative to time.sleep(n) ?
-
-
normaly the should work. but it is not nice, because it blocks e2 while this 5seconds.
Python
Alles anzeigenfrom enigma import eTimer def timerfired(): print "time ends" mytimer.start(5000) def starttimer(): mytimer= eTimer() mytimer.timeout.get().append(timerfired) mytimer.start(5000) def stoptimer(): mytimer.stop() starttimer()
this will print each 5 sec. 'time ends'
-
Thank you very much. It works.
Example code :-
Codedef main(session, **kwargs): print "In main" delay = Test(session, None) f = delay.starttimer() session.openWithCallback(test, MessageBox, _("Test-Messagebox2?"), timeout = 10) f = delay.stoptimer() session.openWithCallback(test, MessageBox, _("Test-Messagebox1?"), timeout = 10)
It is interesting that the first command has to be listed second !
Regards, pcd.
-
Hi!
As far as i know there is no need to start() the timer again everytime it fires.
As long as you don't do a timer.stop() it keeps running! -
Zitat
Original von pcd
It is interesting that the first command has to be listed second !Unfortunately this is not true. Of course code is still executed in order but what you're experiencing is the following:
- First Messagebox is created and shown, Timer in Messagebox counts down
- Without any delay the second one is created and also shown, Timer of first Messagebox stops counting down; second one does count down
- Second Messagebox times out
- Timer of First Messagebox counts down again
- First Messagebox times outThis occurs to the user as if the second Messagebox would be shown first although this is actually not true.
I experienced similar Problems with SimpleRSS when the User gets informed about the updates done in Background. When an error occurs a new Messagebox is created and after this times out or is hidden the first one is shown again with the countdown still showing the same timeout as before.And Reichi is also right as the timer is not called as singleShot.
PS: My Comment is based on observations I made while developing myself, I did not try the actual samples but I checked its contents
-
Ok, I understand it now. Thanks to both of you.
Regards, pcd.