Do anyone know how to set a gif image as the background to my coding below? I just want it for my first window and not Demo1? The gif image is nameed "python_wallpaper.gif".

from tkinter import *
import threading
from graphics import *
class Intro():

    def __init__(self,master):

        self.master = master
        self.master.geometry("800x600")
        self.master.title("Welcome")    


        self.label1 = Label(self.master,text ="Event Driven Programming Demonstration", fg = "blue", font = ("Purisa",22)).grid(row =6,column = 7)
        self.label2 = Label(self.master,text ="Program will auto-start in 5 seconds (or press the return key)", fg = "black").grid(row =7, column =7)
        self.master.bind("<Return>", self.goToDemo1)


    def goToDemo1(self):
        threading.Timer(5.0, goToDemo1).start()
        root2 = Toplevel(self.master)
        myGUI = Demo1(root2)

    def goToDemo1(self,event):
        root2 = Toplevel(self.master)
        myGUI = Demo1(root2)

    def finish(self):
        self.master.destroy()

def main():

    root = Tk()
    myGUIIntro = Intro(root)
    root.mainloop()

if __name__ =="__main__":
    main()

Here is a typical example:

''' tk_BGImage1.py
use a Tkinter label as a panel/frame with a background image
(note that Tkinter without PIL reads only GIF and PGM/PPM images)
modified from a vegaseat example
'''

try:
    # for Python2
    import Tkinter as tk
except ImportError:
    # for Python3
    import tkinter as tk

root = tk.Tk()
root.title('background image')

# pick a .gif image file you have in the working directory
# or give full path
image1 = tk.PhotoImage(file="roses.gif")
w = image1.width()
h = image1.height()

root.geometry("%dx%d+0+0" % (w, h))

# tk.Frame has no image argument
# so use a label as a panel/frame
panel1 = tk.Label(root, image=image1)
panel1.pack(side='top', fill='both', expand='yes')

button2 = tk.Button(panel1, text='button2')
button2.pack(side='top')

# save the panel's image from 'garbage collection'
panel1.image = image1

# start the event loop
root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.