Python Forum
Create image on a Toplevel using tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create image on a Toplevel using tkinter
#1
I'm using tkinter to create a login system. The main window goes as:

my_window=tkinter.Tk()
my_window.title('Welcome To Login System 1.0 !')
my_window.geometry('639x591')

my_canvas=tkinter.Canvas(my_window, height=639, width=591)
welcome_image=ImageTk.PhotoImage(Image.open('welcome2.png'))
image=my_canvas.create_image(0,0, anchor='nw',image=welcome_image)
my_canvas.pack(side='top')
and it works pretty fine.
But when I try to load an image on a Toplevel, the sub-window just keeps blank no matter how I change the pic:

signup_window=tkinter.Toplevel(my_window)
signup_window.geometry('500x400')
signup_window.title('Sign up now')

signup_canvas = tkinter.Canvas(signup_window, height=500, width=400)
signup_image = ImageTk.PhotoImage(Image.open('signup_bg.png'))
image2 = signup_canvas.create_image(0, 0, anchor='nw', image=signup_image)
signup_canvas.pack(side='top')
Don't know what goes wrong. I use the PIL module to load the image.
Reply


Messages In This Thread
Create image on a Toplevel using tkinter - by ViktorWong - Jun-02-2020, 11:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter: An image and label are not appearing. emont 7 625 Mar-21-2024, 03:00 PM
Last Post: deanhystad
  pass a variable between tkinter and toplevel windows janeik 10 2,350 Jan-24-2024, 06:44 AM
Last Post: Liliana
  [Tkinter] Help create scrollbar in chatbot with tkinter on python fenec10 4 1,531 Aug-07-2023, 02:59 PM
Last Post: deanhystad
  My Background Image Is Not Appearing (Python Tkinter) HailyMary 2 4,306 Mar-14-2023, 06:13 PM
Last Post: deanhystad
  simple tkinter question function call not opening image gr3yali3n 5 3,447 Aug-02-2022, 09:13 PM
Last Post: woooee
  [Tkinter] Tkinter don't change the image DQT 2 1,627 Jul-22-2022, 10:26 AM
Last Post: menator01
  [Tkinter] Open tkinter colorchooser at toplevel (so I can select/focus on either window) tabreturn 4 1,912 Jul-06-2022, 01:03 PM
Last Post: deanhystad
  [Tkinter] Toplevel window menator01 5 3,063 Apr-18-2022, 06:01 PM
Last Post: menator01
  [Tkinter] Not able to get image as background in a Toplevel window finndude 4 3,922 Jan-07-2022, 10:10 PM
Last Post: finndude
  How to redraw an existing image to a different image TkInter zazas321 6 5,905 Jul-08-2021, 07:44 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020