[Python] Why do my radio buttons change appearance when hovered over?

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I'm using Python 3.11.10 with Spyder 6.0.2.

    I don't know if this is a coding issue, or if it's something to do with the Spyder 6.0.2 platform I'm using, or a glitch in this version of Python, or what it might be. When I run the app, the radio buttons change appearance when I hover over them, even though I don't have any sort of hover code written. If I select one of the options, the whole group goes back to the desired appearance, and it no longer changes the unselected radio buttons in the same group when hovering. It only happens when there's no option selected (in the initialized state of the buttons, which is with no option selected). It's a glitch of some sort, and I can't find anything on the internet to explain why this might be happening.

    The code for some of the radio buttons is here:

    drivewheelbut = tkinter.IntVar(value=0)
    drivewheel1 = tkinter.Radiobutton(master=cstfrm, variable=drivewheelbut, value=1, bg="#b2b4b7", takefocus=False)
    drivewheel1.place(height=20, x=502, y=450)
    drivewheel1.configure(bg="#292d2e")
    drivewheel2 = tkinter.Radiobutton(master=cstfrm, variable=drivewheelbut, value=2, bg="#b2b4b7", takefocus=False)
    drivewheel2.place(height=20, x=502, y=470)
    drivewheel2.configure(bg="#292d2e")
    drivewheel3 = tkinter.Radiobutton(master=cstfrm, variable=drivewheelbut, value=3, bg="#b2b4b7", takefocus=False)
    drivewheel3.place(height=20, x=502, y=490)
    drivewheel3.configure(bg="#292d2e")
    drivewheel4 = tkinter.Radiobutton(master=cstfrm, variable=drivewheelbut, value=4, bg="#b2b4b7", takefocus=False)
    drivewheel4.place(height=20, x=502, y=510)
    drivewheel4.configure(bg="#292d2e")
    drivewheellbl1 = tkinter.Label(master=cstfrm, text="FWD", bg="#292d2e", fg="#b2b4b7")
    drivewheellbl1.place(x=522, y=450)
    drivewheellbl2 = tkinter.Label(master=cstfrm, text="RWD", bg="#292d2e", fg="#b2b4b7")
    drivewheellbl2.place(x=522, y=470)
    drivewheellbl3 = tkinter.Label(master=cstfrm, text="AWD", bg="#292d2e", fg="#b2b4b7")
    drivewheellbl3.place(x=522, y=490)
    drivewheellbl4 = tkinter.Label(master=cstfrm, text="4WD", bg="#292d2e", fg="#b2b4b7")
    drivewheellbl4.place(x=522, y=510)


    All the others are designed the same.

    [​IMG]

    [​IMG]

    I did notice that this phenomenon only happens in the groups of four radio buttons. The group of two buttons (Automatic or Manual) don't do this (even though they are written exactly the same). It's only the two larger groupings of four radio buttons.

    Any ideas what might be causing this?

    Continue reading...

Compartilhe esta Página