[使用tkinter在Python中添加代码的开始和停止按钮

问题描述 投票:0回答:1

我想使用tkinter为我的代码添加开始和停止按钮我只希望当我单击scheduler.start()开始按钮时,代码将运行当我单击scheduler.shutdown()停止按钮时,代码将停止它是一个[[Python 2.7版本,但是不用担心,我只需要这段代码的想法,它将如何运行这是我的代码:

if __name__ == '__main__': logging.basicConfig(filename='read.log', level=logging.INFO) logging.getLogger('apscheduler').setLevel(logging.DEBUG) scheduler = BackgroundScheduler() scheduler.add_job(calstk, 'interval', seconds=20) # scheduler.add_job(calmrp, 'interval', seconds=10) # scheduler.add_job(caldisc, 'interval', seconds=15) # leave space only for understanding for which I need to add **start Button** scheduler.start() # for this scheduler.start() print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C')) try: # stock = calstk() #print stock print '************************************************************************************' # This is here to simulate application activity (which keeps the main thread alive). while True: time.sleep(10) except (KeyboardInterrupt, SystemExit): # Not strictly necessary if daemonic mode is enabled but should be done if possible pass # leave space only for understanding for which I need to add **Stop Button** scheduler.shutdown() # for this scheduler.shutdown()
我想为

scheduler.start()]添加开始按钮>和<< scheduler.shutdown()

的停止按钮。我确实需要此代码,几乎可以构建我的项目,并且只需要这两个Button即可处理我的项目。[我想使用tkinter为代码添加启动和停止按钮,我只希望当我单击scheduler.start()的开始按钮时代码将运行,而当我单击调度器的停止按钮时...。
python tkinter
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.