5

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()
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
Evan
  • 2,327
  • 5
  • 31
  • 63

1 Answers1

9

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

root = tix.Tk()
Nouman
  • 6,947
  • 7
  • 32
  • 60
fhdrsdg
  • 10,297
  • 2
  • 41
  • 62
  • And so how will we be using it? Please provide the usage and what will be the full code look like? – Nouman Aug 24 '18 at 10:03
  • I'm afraid I don't understand what you're getting at. There's code in the question that produces an error, I explain the normal `Tk()` should be replaced by the `tix` one and show how that line should look. Replacing that one line in the code from the question makes it work. What more code should I provide? – fhdrsdg Aug 24 '18 at 10:45
  • hello, is it possible to change the background color? I tried self.bal.config(bg="red") but only the border turned red. – Evan Aug 24 '18 at 11:02
  • @Van It is possible, but it's too much to explain in a comment and it's a completely different question. You could ask a new question if you can't find an answer yourself. – fhdrsdg Aug 24 '18 at 12:07