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.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):

def main():

    root = Tk()
    myGUIIntro = Intro(root)

if __name__ =="__main__":

Here is a typical example:

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

    # 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')

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

# start the event loop
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.