Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    [PY] Timer

    Salve a tutti stò sviluppando anche se su una piattaforma diversa dal computer un gioco ma mi serve sapere almeno la sintassi del timer qualkuno sà come si usa il timer nel python??? grazie in anticipo

  2. #2
    Non ti ho capito ..
    Cosa vuoi fare con il timer ?

    Vedi se ti può servire:
    from time import *
    t = time()
    Experience is what you get when you don’t get what you want

  3. #3
    Allora in poche parole nel gioco che sto facendo devo far si che per una TOT secondi mi visualizzi un immagine

  4. #4
    per attendere un tot di tempo

    import time
    time.sleep(<secondi>)
    Experience is what you get when you don’t get what you want

  5. #5
    oppure anche
    codice:
    >>> tempo = raw_input("Inserire tempo di attesa ")
    >>> from time import *
    >>> t = time()
    >>> t += tempo
    >>> tmp = time()
    >>> while tmp < t :
    	tmp = time()
    Experience is what you get when you don’t get what you want

  6. #6
    Forse questo potrebbe fare al caso tuo (utilizza i thread):

    codice:
    import threading
    
    class Timer: 
    
        def __init__(self): 
            wait_for = 4 
            self.timer = threading.Timer(wait_for, self.timeout) 
    
        def start(self): 
            self.timer.start() 
    
        def stop(self): 
            self.timer.cancel() 
    
        def timeout(self): 
            # global_lock.acquire() 
            print "timeout" 
            # global_lock.release()
    Esempio di utilizzo:

    codice:
    >>> t = Timer() 
    >>> t.start() 
    timeout 
    >>> t = Timer() 
    >>> t.start() 
    >>> t.stop()
    >>>
    Saluti
    Rilasciata Python FTP Server library 0.5.1
    http://code.google.com/p/pyftpdlib/

    We'll be those who'll make the italian folks know how difficult can be defecating in Southern California without having the crap flying all around the house.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.