[Python] TkInter Button Unpressable - No Errors Raised, Not Disabled

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I was working with tkinter in OOP, and I came across an odd bug: the button here goes completely unresponsive, despite being fully active and the mainloop running:

    import tkinter as tk

    def main():
    global root, button
    root = tk.Tk()
    pixel = tk.PhotoImage(width=1, height=1)
    button = tk.Button(root, text="Hmm",
    image=pixel,
    compound="c")

    button.pack()

    main()
    root.mainloop()


    I used the hidden image as I need to set the specific pixel height and width of the button, but when I remove the image=pixel the button works fine.

    This button is unpressable, both with mouse and with tab+enter:

    [​IMG]

    Continue reading...

Compartilhe esta Página