Python Forum
[Tkinter] Problems - buttons w icons not scrolling
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Problems - buttons w icons not scrolling
#10
I think I know why the button images don't appear. Just yesterday someone was tryin to use image buttons. Their code worked until they created a class for their window. The class/no class code was identical except for one thing; Scope.

The problem was that the images used for the buttons were local variables inside the __init__ method. An image button must not have a reference to the image because as soon as the __init__ method exited and the local image variable went poof, so did the image. Changing the image variables from local to instance variables fixed the problem.

Please don't ask me why that happened because I haven't figured it all out for myself. Using that same logic your images should not have appeared in your earlier code (the one with image buttons that didn't scroll) since your image variables were local to your win1 function. Still a bit of a mystery

Try using self.photo1 instead of photo1 and see if that makes a difference. If so, that is another piece of the puzzle and it may be worth investigating what combinations of classes/functions/globals work with image buttons.
Reply


Messages In This Thread
Problems - buttons w icons not scrolling - by kraco - Apr-27-2020, 12:54 PM
RE: Problems - buttons w icons not scrolling - by deanhystad - Apr-28-2020, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] QStandardItemModel; columns, icons malonn 3 1,301 Aug-12-2023, 12:39 PM
Last Post: malonn
  tkinter touchscreen scrolling - button press makes unwanted scrolling nanok66 1 3,923 Dec-28-2020, 10:00 PM
Last Post: nanok66
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 2,785 Apr-06-2019, 11:15 PM
Last Post: ZenWoR
  Menus and icons changed after upgrade blackclover 0 1,904 May-11-2018, 08:14 PM
Last Post: blackclover
  [Tkinter] scrolling text in tkinter Barrowman 8 18,917 Oct-18-2016, 10:00 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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