PYTHON 3.7 _tkinter.TclError: invalid command name "tixBalloon"
Asked Answered
L

1

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()
Lilley answered 24/8, 2018 at 9:34 Comment(0)
P
9

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

root = tix.Tk()
Padre answered 24/8, 2018 at 9:57 Comment(4)
And so how will we be using it? Please provide the usage and what will be the full code look like?Erigeron
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?Padre
hello, is it possible to change the background color? I tried self.bal.config(bg="red") but only the border turned red.Lilley
@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.Padre

© 2022 - 2024 — McMap. All rights reserved.