Hi everyone !

Inside my program, i have a function which delete all the values in the "Entry" widgets. This function works with a simple button "Reset".
I have also 2 radiobuttons. I would like to know, please, how radiobutton.deselect() works to deselect all the radiobuttons with my buton "Reset".

Could you help me please?
Thank you very much.
Philippe

The function

def effacer():                     
    altdep.delete(0, END)        
    altarr.delete(0, END)
    distcart.delete(0, END)

The button

Button(fenetre, width=10,height=-10,fg="black",  font=("Times",-15,'bold'),text="Reset", command=effacer).grid(row=6, column=2)

And the radiobuttons :

Radiobutton(fenetre, text="HOT 1/2", font=("Times",-15,'bold'), variable=portee, value=4000).grid(row=4, column=1, sticky = E)
Radiobutton(fenetre, text="HOT 3", font=("Times",-15,'bold'), variable=portee, value=3850).grid(row=4, column=2, sticky = E)

Recommended Answers

All 2 Replies

Something like ...

from Tkinter import *

fenetre = Tk()
portee = IntVar()

def effacer():
    rb1.deselect()
    rb2.deselect()

rb1 = Radiobutton(fenetre, text="HOT 1/2", font=("Times",-15,'bold'),
    variable=portee, value=4000)
rb1.grid(row=4, column=1, sticky = E)
rb2 = Radiobutton(fenetre, text="HOT 3", font=("Times",-15,'bold'),
    variable=portee, value=3850)
rb2.grid(row=4, column=2, sticky = E)

# preset rb2
portee.set(3850)

bt1 = Button(fenetre, width=10, height=-10, fg="black",
    font=("Times",-15,'bold'), text="Reset", command=effacer)
bt1.grid(row=6, column=2, pady=10)

fenetre.mainloop()

That's right, thant you !

We must "name" the radiobutton :

Radiobutton(fenetre, text="HOT 1/2", font=("Times",-15,'bold'), variable=portee, value=4000).grid(row=4, column=1, sticky = E)
radiobutton.deselect()

doesn't work

But

rb1=Radiobutton(fenetre, text="HOT 1/2", font=("Times",-15,'bold'), variable=portee, value=4000).grid(row=4, column=1, sticky = E)
rb1.deselect()

works !

Thanks again.
Bye

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.