0

I saw few posts about it but dont figure the answer in my case. why do all the radio button are selected ?

pred_win=tkinter.Toplevel (window) #create new window
var_ = StringVar ()
var_.set("All models")
var_2=IntVar
radio_select_model = Radiobutton (pred_win, text="All models", variable=var_ , command=all_model_select,value="All models")
radio_select_model.grid (column=0, row=2, sticky='W', padx=40)
radio_select_model2 = Radiobutton (pred_win, text="Praticular model", variable=var_,value="Praticular model")  # , command=)
radio_select_model2.grid (column=0, row=3, sticky='W', padx=40)
model_select_pls= Radiobutton (pred_win, text="PLS", variable=var_ ,value="PLS")
model_select_pls.grid (column=1, row=0,sticky='S', padx=40)
model_select_rf = Radiobutton (pred_win, text="Random Forest", variable=var_,value="Random Forest")
model_select_rf.grid (column=1, row=1,sticky='S', padx=40)

TNX

shapiro
  • 57
  • 5
  • Does this answer your question? [Why do Tkinter's Radio Buttons all Start Selected When Using StringVar but not IntVar?](https://stackoverflow.com/questions/40684739/why-do-tkinters-radio-buttons-all-start-selected-when-using-stringvar-but-not-i) – astqx Mar 03 '21 at 12:57
  • I saw it and even when I change according to the answer its not working – shapiro Mar 03 '21 at 12:58
  • In your code you have used `var_2=IntVar` which will have no effect, you will need to instantiate it `var_2=IntVar()` – astqx Mar 03 '21 at 13:00
  • After adding missing parts to make your code run, only "All models" radiobutton is selected when it runs. – acw1668 Mar 03 '21 at 15:23

0 Answers0