This class gives a specified Tkinter widget a tooltip that appears as the mouse is above the widget. You can improve the code by putting in a time delay.
This is excellent! Just what I was looking for. I tried Tix, but had no luck. This is simple and it works. I had to sign up just to show my thanks!
Just to mention it ...
''' tix_Balloon102.py Tkinter extension module tix comes with Python27 and Python3+ tix has addtional widgets like ... tix.Balloon (acts like a tooltip) ''' try: # Python2 import Tix as tix except ImportError: # Python3 import tkinter.tix as tix root = tix.Tk() def hello(): label['text'] = 'Hello World' #label.config(text='Hello World') def bye(): label['text'] = 'Bye Cruel World' label = tix.Label(root, width=40, relief=tix.SUNKEN, bd=1) btn1 = tix.Button(root, text="Hello", command=hello) btn2 = tix.Button(root, text="Bye", command=bye) # create balloon (tooltip) instance balloon = tix.Balloon(root) # bind balloon to buttons balloon.bind_widget(btn1, balloonmsg='Click to show Hallo') balloon.bind_widget(btn2, balloonmsg='Click to show Bye') # layout, stack vertically label.pack() btn1.pack(pady=8) btn2.pack(pady=8) root.mainloop()
the code works fine on my windows machine but on ubuntu 14.04 it says it can not find ' tix ' . do I need to install it separately ?
In the 1st class you can add in line 38:
to disappear the label after 1 sec
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.