0

I want to make a banner in my window to have at the top. How would I import a image? If it helps here is my code. Also as a side note I deleted the code I tried. And I tried putting the image in the file my code is stored in and then tried to acces it. Is that the wrong approach? I know there are examples of this in here but they don't work for me so I posted my code to get a more direct response

import tkinter

#create new window
window = tkinter.Tk()
#name window
window.title("Basic window")
#window sized
window.geometry("250x200")
#creates label then uses ut
lbl = tkinter.Label(window, text="Please sign up or log in ", bg="green")
#pack label
lbl.pack()
#create username
lbl_username = tkinter.Label(window, text="Username", bg="green")
ent_username = tkinter.Entry(window)
#pack username
lbl_username.pack()
ent_username.pack()
#attempting to get the ent_username info to store
#configure window
window.configure(background="red")
#basic enter for password
lbl_password = tkinter.Label(window, text="Password", bg="green")
ent_password = tkinter.Entry(window)
#pack password
lbl_password.pack()
ent_password.pack()
#def to check if username is valid
def question():
    username = ent_username.get()
    password = ent_password.get()
    if username == "louis":
        print("you know")
    else:
        print("failed")
    if password == "2xfeikis":
        print("it passed for pass")
    else:
        print("it failed for pass")

def sign_up():
    username = ent_username.get()
    password = ent_password.get()
    if len(username) > 0 and len(password) > 0:
        pass
    else:
        print("invalid info")
#will make the sign up button and will call question on click
btn = tkinter.Button(window, text="Log", command=lambda: question(), bg ="grey")
#sign up button
btn_sign_up = tkinter.Button(window, text="Sign up", command= lambda: sign_up(), bg ="grey")
#pack buttons
btn.pack()
btn_sign_up.pack()
#draw window
window.mainloop()

1 Answers1

0

Use Photo Image

Here is documentation http://effbot.org/tkinterbook/photoimage.htm

Jonah Fleming
  • 1,187
  • 4
  • 19
  • 31