Python Forum
[Tkinter] Why does the image for the button not appear?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Why does the image for the button not appear?
#4
Using global is not a good way to fix it
If you don't want to use classes which is a better way of organising GUI code where you could keep a reference to the image as an attribute of the class instance, you could do the following.
deposit_exit_button_photo = PhotoImage(file = r"Z:\Finley\School\Sixth Form\School Images\CS\exit.png")
deposit_exit_button = Button(deposit_page, text="", image = deposit_exit_button_photo, command = exit_menu)
deposit_exit_button.image = deposit_exit_button_photo
To keep a reference to it on the button object.

Also see Namespace flooding with * imports
Reply


Messages In This Thread
RE: Why does the image for the button not appear? - by Yoriz - Oct-21-2021, 04:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] image inside button rwahdan 4 7,300 Jul-12-2021, 08:49 PM
Last Post: deanhystad
  tkinter showing image in button rwahdan 3 5,749 Jun-16-2021, 06:08 AM
Last Post: Yoriz
  tkinter button image Nick_tkinter 4 4,170 Mar-04-2021, 11:33 PM
Last Post: deanhystad
  Problem about image and button scotesse 5 3,081 Apr-27-2020, 10:09 AM
Last Post: scotesse
  Button with Image Icon Friend 2 6,897 Jul-25-2019, 09:39 AM
Last Post: Friend
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,097 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  Simple Button click on image file to create action? jpezz 4 7,035 Mar-27-2019, 10:08 PM
Last Post: jpezz
  set button background with image of window background gray 3 14,534 Oct-18-2017, 08:22 AM
Last Post: gray

Forum Jump:

User Panel Messages

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