0

The code below is simple i am just creating two frames and trying to display progressbar with image in first then after 6 seconds switching two frame 2 but the first frame is completely white for some reason. Hope someone can help :)

from PIL import ImageTk,Image
from tkinter import ttk
import time

frames=['frame1','frame2']
#canvas
root=Tk()
root.title('Anigame Tools V1.0')
root.iconbitmap('anigametoolsicon.ico')

#Frame Functions
frame1= Frame(root)
frame2= Frame(root)
frame1.pack()
frames=[frame1,frame2]
# progress bar
p = ttk.Progressbar(frame1, orient=HORIZONTAL, length=200, mode="determinate", takefocus=True, maximum=100)
p['value'] = 0
p.grid(row=1, column=0)
def start():
    if p['value'] != 80:
        p['value'] += 20
        root.after(1000, start)

    frame1.after(1000, start)
def show_frame(framename):
    for i in frames:
        i.pack_forget()
    framename.pack()

# intro
intimg=Image.open("anigametoolsicon.png")
introimg = ImageTk.PhotoImage(intimg)
intro = Label(frame1,image=introimg)
intro.grid(row=0, column=0)

# frame2
anigametoolsad = Label(frame2, text='Anigame Tools Ver1.0')
anigametoolsad.grid(column=0, row=0, columnspan=3)
root.after(6000, show_frame(frame2))


root.mainloop()
Legend_recalls
  • 264
  • 2
  • 15
  • 3
    Instead of `root.after(6000, show_frame(frame2))` use `root.after(6000, show_frame, frame2)` – TheLizzard Aug 11 '21 at 18:12
  • works like a charm ty can you perhaps tell me why this happens and what happens in my case @TheLizzard – Legend_recalls Aug 11 '21 at 18:16
  • 1
    Think about it. First python does `show_frame(frame2)` then does: `root.after(6000, )`. Instead you should pass in the function (`show_frame`) and the arguments (`frame2`) and let `tkinter` call the function when it's ready. Don't know if [this](https://stackoverflow.com/q/6920302/11106801) is going to be very helpful but it's the same problem. – TheLizzard Aug 11 '21 at 19:09

0 Answers0