Answer the question
In order to leave comments, you need to log in
How to stop a script from running on schedule in tkinter?
How to stop a scheduled task...
import schedule
...
def main():
factories = get_factory()
for factory in factories:
parser_factory = ParserFactory(factory)
parser_factory.update_db_with_parser()
def run_schedule():
schedule.every(10).seconds.do(main)
while True:
schedule.run_pending()
time.sleep(1)
from tkinter import *
import parser
def start():
parser.seller_id = entry.get()
parser.run_schedule()
def delete():
entry.delete(0, END)
root = Tk()
# WxH+X+Y
root.geometry('320x240+720+360')
root.title('Parser GUI')
# поле ввода
entry = Entry(root)
entry.insert(0, 'Введите идентификатор')
entry.pack(side=TOP, expand=YES, fill=X)
# избавить от необходимости выполнять щелчок мышью
entry.focus()
# при нажатии клавиши Enter
entry.bind('<Return>', lambda event: start())
# при двойном щелчке левой кнопки мыши в поле ввода
entry.bind('<Double-1>', lambda event: delete())
# кнопка Start
start_btn = Button(root, text='Начать', command=start)
start_btn.pack(side=LEFT, expand=YES)
# кнопка Stop
stop_btn = Button(root, text='Остановить')
stop_btn.pack(side=RIGHT, expand=YES)
root.mainloop()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question