0

Original Code:

search_button = Button(Frame3, text="Search", command=lambda: displaySelected(), bg="black", fg="white", font=('Arial', 10),padx=5,pady=5)
search_button.place(x=210, y=190)

How Original Output is like: Click to view for better visualisation (focus on the blue circle, ignore the other features there)

What DisplaySelected() does: Basically show data based on the Country and Institution user selects

What I have tried:

search_pic = PhotoImage(file="search.png")
search_button = Button(Frame3, image=search_pic, command=lambda: displaySelected(), bg="black", fg="white", font=('Arial', 10),padx=5,pady=5)
search_button.place(x=210, y=190)

Basically, I want to do the same function, just that instead of having the button "search", I wish to replace it with a png file instead for better appearance. However, when i run the code, my png is not shown for some reason?

Fumin
  • 33
  • 7
  • 1
    Does this answer your question? [Why does Tkinter image not show up if created in a function?](https://stackoverflow.com/questions/16424091/why-does-tkinter-image-not-show-up-if-created-in-a-function) – acw1668 Oct 28 '20 at 15:17
  • @acw1668 nope hahah, thanks thou!! I tried following youtube tutorials for making an image to have a button function... however they are all showing .pack(). My code require .place() and my image its not in root, but in Frame3. – Fumin Oct 29 '20 at 08:28
  • Is the code inside a function? If yes, it is the same issue as in the link. – acw1668 Oct 29 '20 at 08:55

0 Answers0