×

Tooltip : Attachment 

Tooltip:
I am presently  creating a GUI in python. One of features is when I go on top of any button it should show the name of the button.  Tooltip can do this in python. Unfortunately it doesn’t work with images (My all buttons are made up of images) because it doesn’t consider image as widget. So I have come up with following method to create namebox.

******************************Tooltip for canvas Items ******************************

# Globals
tw = 0
tt_yes = 0
def tooltip_create(text, x,y): # inputs are text = display name; x,y = where should be positioned.
global tw, tt_yes
x -= 5
y += 15
# creates a toplevel window
tw = Toplevel(home_root)
# Leaves only the label and removes the app window
tw.wm_overrideredirect(True)
tw.wm_geometry(“+%d+%d” % (x, y))
label =Label(tw, text=text, justify=’left’,
background=’white’, relief=’solid’, borderwidth=1)
label.pack(ipadx=1)
tt_yes = 1
def tooltip_close(): # close the namebox window
global tw, tt_yes
if tt_yes:
tw.destroy()
def  hover_enter(event):
tooltip_create(“Save”, x,y)
return
def  hover_leave(event):
tooltip_close()
return
# Photoimage ( which requires the tooltip)
image=os.path.abspath(y+’images\\images2\\save.gif’)
img_save = PhotoImage(file = image)
canvas.create_image(x= X, y = Y,image=img_save,tags=”hover_functn”)
canvas.tag_bind(“hover_functn “,’<Any-Enter>‘, hover_enter)
canvas.tag_bind(“hover_functn “,’<Any-Leave>‘, hover_leave)

Author

prathap7618@gmail.com

Related Posts

How to Install WSL and Ubuntu (LTS) on the Windows platform

~Sandhiya.B and Ajay This post consolidates the information needed to set up the Ubuntu terminal on a Win 11 Machine. The Ubuntu terminal...

Read out all

Ambient light sensor using a photoresistor and Arduino Uno

This project is about using a photoresistor along with an Arduino Uno board to determine the brightness of a room which is...

Read out all

Smart dustbin using Arduino

The smart dustbin is built on a microcontroller-based platform Arduino Uno board which is interfaced with the Servo motor and ultrasonic sensor....

Read out all

LOGIC GATES USING ARDUINO UNO

A basic gate is defined as a component with one or more inputs and one output.  The inputs and outputs are all...

Read out all

LAST SCHOOL STUDENTS VISIT STEMLAND

On the 14th of July students from the Last school, Auroville visited STEMLAND. The forty students accompanied by the teachers enjoyed their...

Read out all

Vim Editor Session

Vim Editor Session ~SriBhavani and Bakyalakshmi On 18th Jan 2022, we had a session on vim by HarshaVaradhan from AuraSemiconductors. In this...

Read out all