On Tue, 27 Jun 2006 14:06:05 +0200, Fuzzyman <fu******@gmail.com> wrote:
Hello all,
I have some Tkinter buttons that display images. I would like to change
these to 'active' images when the mouse is over the button.
I see that the button widget can take an 'overrelief' argument in the
constructor. What values can this take ?
The same as the 'relief' option, i.e the ones described here:
http://www.tcl.tk/man/tcl8.4/TkCmd/options.htm#M-relief
Note that Tkinter contains symbolic constants for these values: 'raised'
is Tkinter.RAISED, 'flat' is Tkinter.FLAT, and so on.
Also - can anyone provide an example of using the equivalent of a
'mouseover' event to change the image used by a button in Tkinter ? I'm
afraid google has not helped me much here.
The events you're after are '<Enter>' and '<Leave>'; see here:
http://www.tcl.tk/man/tcl8.3/TkCmd/bind.htm#M7
Here is an example showing how to change the button text (changing the
image is similar):
--------------------------------
from Tkinter import *
root = Tk()
b = Button(root, width=8, text='foo')
b.pack()
def enterB(event):
b.configure(text='bar')
def leaveB(event):
b.configure(text='foo')
b.bind('<Enter>', enterB)
b.bind('<Leave>', leaveB)
root.mainloop()
--------------------------------
HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"