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 ?
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.
Much Appreciated,
Fuzzyman http://www.voidspace.org.uk/python/index.shtml 2 8297
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(tex t='bar')
def leaveB(event):
b.configure(tex t='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.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"
Eric Brunel wrote: 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.
Cool, I'll have to look into this and see how they look. Thanks. 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(tex t='bar')
def leaveB(event): b.configure(tex t='foo')
b.bind('<Enter> ', enterB) b.bind('<Leave> ', leaveB)
root.mainloop()
That works like a charm, great.
Much Appreciated
Fuzzyman http://www.voidspace.org.uk/python/index.shtml
--------------------------------
HTH
-- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: srijit |
last post by:
Hello,
Any idea - why the following code crashes on my Win 98 machine with
Python 2.3? Everytime I run this code, I have to reboot my machine.
I also have Win32all-157 installed.
from Tkinter import *
class App:
|
by: mksql |
last post by:
New to Tkinter. Initially, I had some code that was executing button commands at
creation, rather than waiting for user action. Some research here gave me a
solution, but I am not sure why the extra step is necessary.
This causes the "graph" function to execute when the button is created:
Button(root, text='OK', command=graph(canvas)))
However, this waits until the button is pressed (the desired behavior):
def doit():
graph(canvas)
|
by: Paul A. Wilson |
last post by:
I'm new to Tkinter programming and am having trouble creating a
reusable button bar... I want to be able to feed my class a dictionary
of button names and function names, which the class will make.
My button bar is implemented a Frame subclass, which takes the button
dictionary as an argument and displays the buttons on the screen:
class OptionsBar(Frame):
def __init__(self, buttonDict, parent=None)
Frame.__init__(self, parent)
|
by: Elaine Jackson |
last post by:
I've got a script where a button gets pushed over and over: to cut down on the
carpal tunnel syndrome I'd like to have the button respond to presses of the
Enter key as well as mouse clicks; can somebody clue me in regarding how this is
done? Muchas gracias.
Peace
|
by: Harlin Seritt |
last post by:
I was looking at the Tcl/Tk sourceforge page and found that there were
a couple of new widgets being produced for Tcl 8.5. Does anyone know if
there are any Tkinter wrappers somewhere?
thanks,
Harlin
| |
by: Michael Yanowitz |
last post by:
Hello:
Below I have included a stripped down version of the GUI I am working on.
It contains 2 dialog boxes - one main and one settings. It has the following
problems, probably all related, that I am hoping someone knows what I am
doing wrong:
1) Pressing the Settings.. Button multiple times, brings up many instances
of the Settings Panel. I just want it to bring up one. Is there an easy
way to do that?
|
by: dwelch91 |
last post by:
I'm trying unsuccessfully to do something in Tk that I though would be
easy. After Googling this all day, I think I need some help. I am
admittedly very novice with Tk (I started with it yesterday), so I am
sure I am overlooking something simple.
The basic idea is that my application will consist of a series of modal
dialogs, that are chained together in "wizard" fashion. There will be
some processing in between dialogs, but for the most...
|
by: yvesd |
last post by:
hello i want to intercept tkinter python system events like
wm_delete_window
and if possible for any window, but the newest code I've produced give
me
an error :
Traceback (most recent call last):
File "C:\Documents and Settings\yvesd\Bureau\protowin.py", line 36,
in ?
b1 = Tkinter.Button (win1)
|
by: J-Burns |
last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in
programming itself... :P. Need some help here.
Problem 1:
How do I make something appear on 2 separate windows using Tkinter? By
this I mean that the format would be something like this:
You have Page1 : This has 2-3 buttons on it.
Clicking on each button opens up a new window respectively having
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |