Jump to content Jump to content

How to execute multiple tasks while scheduler is working?


RajeshEzrado
 Share

Recommended Posts

I am using the schedule module in python to make a scheduler, the scheduler works, but once it runs my other python programs hang/get stuck..

I am using tkinter to make a UI for the scheduler and schedule module to schedule tasks..

here is the code for my program..

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 omegle.2yu.co = Button(main_win, text="add account", command=lambda:add_account(account_name_entry.get()))
    account_open_button = Button(main_win, text="open account", omeglz echat command=lambda:open_account(account_name_entry.get()))
    account_regiter_button.pack()
    account_open_button.pack()
    account_name_entry.pack()
    main_win.mainloop()

thanks in advance..

Edited by RajeshEzrado
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...