So I have a notebook with 2 pages. Initially tab1 is disable. Clicking a button in tab0 triggers an external process of creating a file. Only once this file is created should tab1 be enabled again.I can't edit the code that creates this file and creating it take some time so in the meantime my code should constantly check if it is created and then enable the tab... How can I do this is tkinter?
from tkinter import *
from tkinter import ttk
root = Tk()
note = ttk.Notebook(root)
tab0 = ttk.Frame(note)
tab1 = ttk.Frame(note)
note.add(tab0)
note.add(tab1, state="disabled") # tab disabled
note.pack(expand = 1, fill = "both")
# <----------------tab0------------------>
canvas_home = Canvas(tab0,bg='#398FFF')
canvas_home.pack(expand=True,fill=BOTH)
# In my case create_file is being imported...
def create_file():
import time
time.sleep(100) # assume a file is being created
button = Button(canvas_home, text="Create file",command=create_file)
button.grid()
# <----------------tab1------------------>
import os
if os.path.exists('filename'):
note.tab(0, state="normal") # tab enabled
if __name__ == "__main__":
root.mainloop()