M
M
Mikhail Sokov2022-02-10 13:11:30
css
Mikhail Sokov, 2022-02-10 13:11:30

How to make a timer for a Python function?

In my program, there is a reading_keys function that works in While True mode. I need the main() function to restart the reading_keys function every 60 seconds.

PS Please do not show the method using the built-in threading library, it is not suitable for my purposes.

def main():
    reading_keys()
    print('test')

if __name__ == '__main__':
    main()

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
sergski, 2016-02-08
@sergski

If it’s quick, then using media queries, replace all the width in pixels of the divs with auto or 100% at the desired maximum screen width (for example, 900px) and add to the head
Those

@media screen and (max-width: 900px) {
.art-sheet {width: auto}
}

etc.

P
Pavel Volintsev, 2016-02-10
@copist

www.liquidapsive.com examples of different layout versions, switch to "Responsive" mode and resize the browser window in every possible way - you will see how the blocks move, adjusting to the screen width
Details on terminology
Details on implementation in CSS and HTML

A
Anton Agaltsov, 2016-02-08
@Archusha

Options:
1) Design an adaptively current site, for example on bootstrap
2) Take a special Framework similar to jquery Mobile - in general, the question is covered here Mobile web framework

N
NiicKz, 2022-02-10
@NiicKz

import time

def main():
    while True:
        reading_keys()
        print('test')
        time.sleep(60)

if __name__ == '__main__':
    main()

Try using the time library.

D
Daniil Shevkunov, 2022-02-10
@danila763

from time import time


def reading_keys():
    t = time()
    while True:
        if time() - t >= 60:
            return 0
        # ваш код

def main():
    while True:
        reading_keys()
        print('test')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question