954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

splash screen freezes up doesn't return control to main program

import Tkinter as tk
import Image, time, datetime


def splash_screen():

    root = tk.Tk()

    root.overrideredirect(True)
    width = root.winfo_screenwidth()
    height = root.winfo_screenheight()
    root.geometry('%dx%d+%d+%d' % (width*0.8, height*0.8, width*0.1, height*0.1))

    image_file = "NHK.gif"
    image = tk.PhotoImage(file=image_file)
    canvas = tk.Canvas(root, height=height*0.8, width=width*0.8, bg="black")
    canvas.create_image(width*0.8/2, height*0.8/2, image=image)
    canvas.pack()

    
    root.after(10000, root.destroy)
    root.mainloop()
    return

splash_screen()

my_menu()# is defined at beginning of program


When I call the definition the picture NHK.GIF shows on a black background then disappears after 10 seconds.

The problem starts here; the program just stalls and nothing happens. Control is not given back to the main program ie, my menu doesn't print. When I hit close I get the message " The program is still running kill it? "

Please help I am very frustrated. I know the only problem in my code is in the splash_screen() Definition. Everything else runs flawlessly. The main purpose of this program is to teach basic survival skills.

Python Joe
Newbie Poster
4 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

Worked for me I just changed the name of image to one of minds and defind my_menu as simple print message. The message was printed OK.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 


Try replacing root.destroy with root.quit. Possibly the root window is destroyed but Tkinter is still running.

woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 

Is the splash screen supposed to be for a console program?

Lardmeister
Posting Virtuoso
1,749 posts since Mar 2007
Reputation Points: 407
Solved Threads: 44
 
Lardmeister
Posting Virtuoso
1,749 posts since Mar 2007
Reputation Points: 407
Solved Threads: 44
 
Try replacing root.destroy with root.quit. Possibly the root window is destroyed but Tkinter is still running.


OK, I tried that and it did make the program close, but a the black background did not disappear.

Python Joe
Newbie Poster
4 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

Ok, I looked at the example posted. I copied and pasted that one into a window, I get the same error. The Print statement never executes..

Python Joe
Newbie Poster
4 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: