lufee lufee - 8 months ago 21
Python Question

Setting URL gif background but not working with new frame on Python 2

I'm trying to create a program with main frame and three buttons that opens new frame. I was able to get URL .gif image as background for main frame but I'm having difficulty changing URL .gif image for new frame when it is loaded.
I been trying to figure it out but there is not much information regarding new frame window with URL .gif background. Can any one give me a hand? Thank you

from Tkinter import*
import urllib
import base64
import Tkinter

def epl_Window():
epl = Tk()
URL = "h"
epl.a = urllib.urlopen(URL)
raw_input =
c = base64.encodestring(raw_input)
image = PhotoImage(data=c)
label = Label(image=image)


Your program does not work for 2 reasons related to epl_Window() method:

  • You are running more than one instance of Tk()
  • You did not attach label to epl


You can fix those 2 problems respectively by:

  • Using Toplevel() to change the line epl = Tk() to epl = Tkinter.Toplevel()
  • Changing label = Label(image = image) to label = Label(epl, image = image)


Once you apply the modifications above, you will get this (I clicked on the 3 buttons):

enter image description here


  • Follow the standards by running import Tkinter as Tk
  • Respect this way of instantiating your widgets: label = Tk.Label(...)
  • Apply object-oriented concepts
  • Follow PEPs