pythonpython-3.xtkintertix

PYTHON 3.7 _tkinter.TclError: invalid command name "tixBalloon"


Hello I am trying to create a button that will show description when hovered. similar to html img tag "alt" I decide to use "tkinter.pix" with Balloon() But I am having an error: _tkinter.TclError: invalid command name "tixBalloon".

from tkinter import *
from tkinter import tix


class MyClass:

    def __init__(self, master):
        self.master = master
        self.btn_1 = Button(self.master, text="Button")
        self.btn_1.pack()

        self.bal = tix.Balloon(self.master)

        self.bal.bind_widget(self.btn_1, balloonmsg="Hello")
root = Tk()
app= MyClass(root)
root.mainloop()

Solution

  • When you use tix widgets, you also need to use the tix version of Tk().
    So replace root = Tk() with:

    root = tix.Tk()