I tried to make a image as background in a frame, the code is as follows,
from tkinter import *
class LoginFrame(Frame):
def __init__(self, parent):
#Frame.__init__(self, parent)
super(LoginFrame, self).__init__()
self.parent = parent
self.initUI()
# initialize the login screen UI
def initUI(self):
# create a background image
photo_bg = PhotoImage(file="building.gif")
building = self.make_label(self.parent, image=photo_bg)
def make_label(self, parent, caption=NONE, side=TOP, **options):
label = Label(parent, text=caption, **options)
if side is not TOP:
label.pack(side=side)
else:
label.pack()
return label
def main():
top = Tk()
app = LoginFrame(top)
top.mainloop()
if __name__ == '__main__':
main()
The image seems to take a place holder on the top frame, but no image is shown, I am wondering how to fix the issue.