Python Forum
Help: Enlarge image on hover
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help: Enlarge image on hover
#1
Hi All!

First of all I am new to this forum as well as to Python. As an example, I am trying to program a very simple UI using Tkinter with a clickable image. I would like to be able to enlarge the image when hovering on it with the cursor. I already tried quite a few examples online but unfortunately to no avail. Does anyone have any ideas on how to do so?

Just to know: I am using Python 2.7

Many thanks in advance!

The code:

from Tkinter import *
from Tkinter import PhotoImage


class RedButton(Button):

def __init__(self, parent, **options):
Button.__init__(self, parent, **options)
self['bg'] = 'red'


window = Tk()
window.geometry('1280x600')

RedButton(window, text="Button #1").pack()


def callback():
print "click!"


photo = PhotoImage(file='notification.gif') # type: PhotoImage
b = Button(window, image=photo, command=callback, height=375, width=289, compound=LEFT)
b.pack()

mainloop()
Reply
#2
Please put your code in Python code tags. You can find help here.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 1,450 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  [Tkinter] Glow text of clickable object on hover with transition andy 6 5,916 May-11-2021, 07:39 AM
Last Post: andy
  [Tkinter] Hover event DT2000 9 7,314 Apr-19-2020, 05:51 AM
Last Post: DT2000
  [PyQt] Ubuntu Taskbar icon shows title as "Unknown" while hover davidmuni 3 3,687 Jan-28-2020, 01:13 PM
Last Post: davidmuni
  bind hover on tkinter.ttk.Treeview Larz60+ 4 14,932 May-20-2017, 10:28 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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