Я использую модуль расписания в python для создания планировщика, планировщик работает, но как только он запускает другие мои python программы, зависают / застревают ..
Я использую tkinter для создания пользовательский интерфейс для планировщика и модуля расписания для планирования задач ..
вот код моей программы ..
def add_account(name):
with open(f"---{name}.txt",mode="w")as file:
file.close()
def write_data(account_name,data):
with open(f"---{account_name}.txt",mode="a") as file:
file.write(data + "\n")
file.close()
def set_remainder(name , data , time2):
def thing(data, name):
messagebox.showinfo(f"Reminder Alert for user : {name}", f"The remainder for user: {name} is now!! Remainder:{thing}:")
return schedule.CancelJob()
schedule.every(time2).seconds.do(thing, data, time)
while True:
schedule.run_pending()
time.sleep(1)
def open_account(name):
with open(f"---{name}.txt",mode="r") as opened_account:
remainders = opened_account.read()
opened_account.close()
win2 = Tk()
win2.geometry("100x100")
remainders = Label(win2, text=remainders)
remainders.pack()
new_remainder_label = Label(win2, text="remainder:")
new_remainder_label.pack()
new_remainder_entry = Entry(win2)
new_remainder_entry.pack()
time_label = Label(win2, text="time:")
time_label.pack()
time_entry = Entry(win2)
time_entry.pack()
submit_button = Button(win2, text="add reminder", command=lambda:[ write_data(name,new_remainder_entry.get()), set_remainder(name, new_remainder_entry.get(), float(time_entry.get()) ) ])
submit_button.pack()
win2.mainloop()
def main():
main_win = Tk()
main_win.geometry("100x100")
account_name_entry = Entry(main_win)
account_regiter_button = Button(main_win, text="add account", command=lambda:add_account(account_name_entry.get()))
account_open_button = Button(main_win, text="open account", command=lambda:open_account(account_name_entry.get()))
account_regiter_button.pack()
account_open_button.pack()
account_name_entry.pack()
main_win.mainloop()
заранее спасибо ..
- CodeMaster.