I m new to Python and I m writing a script that includes some timed routines. My current approach is to instantiate a class that includes those Timers (from: threading.Timer), but I don t want the script to return when it gets to the end of the function:
import mytimer
timer = mytimer()
Suppose I have a imple script like that one. All it does is instantiate a mytimer object which performs a series of timed activities.
为了不退出申请,我可以这样使用Qt:
from PyQt4.QtCore import QCoreApplication
import mytimer
import sys
def main():
app = QCoreApplication(sys.argv)
timer = mytimer()
sys.exit(app.exec_())
if __name__ == __main__ :
main()
This way, the sys.exit() call won t return immediately, and the timer would just keep doing its thing forever in background.
Although this is a solution I ve used before, using Qt just for this doesn t fell right to me. So my question is, Is there any way to accomplish this using standard Python?
谢谢 谢谢