EDIT: I tried to edit it based on one suggestion that it needs to be tied to a function. But still not working properly. Thank you very much!
Hope you can help me. Saw related questions but not exactly the same. Thank you very much!
I have a radiobutton. Based on the selected value, the number of buttons will change. However, the number of buttons dont change. The number just based on the default value of the radiobutton (i tried changing it).
import tkinter
from tkinter import *
root = Tk()
TIME_SUBFRAME = root
#dont mind much this part, this is just the popup window that will show after I click the buttons dependent on the radiobutton
def month():
CAL_WINDOW = Toplevel(TIME_SUBFRAME) #other parts removed
#this is the part that I would want to be dependent on the radiobutton
ONLY_MONTH = Button(TIME_SUBFRAME, text='Month', command=month)
START_MONTH = Button(TIME_SUBFRAME, text='Start Month', command=month)
END_MONTH = Button(TIME_SUBFRAME, text='End Month', command=month)
def sing_month():
START_MONTH.destroy()
END_MONTH.destroy()
ONLY_MONTH.grid(row = 3, column = 2, columnspan = 2)
def mult_month():
ONLY_MONTH.destroy()
START_MONTH.grid(row = 3, column = 2)
END_MONTH.grid(row = 3, column = 3)
#Radiobuttons for timepoint selection type
YRTYPE = IntVar(TIME_SUBFRAME, 1)
SING_MONTH = Radiobutton(TIME_SUBFRAME, text = "Single Month", command = sing_month, variable = YRTYPE, value = 1)
MULT_MONTH = Radiobutton(TIME_SUBFRAME, text = "Multiple Months", command = mult_month, variable = YRTYPE, value = 2)
SING_MONTH.grid(row = 2, column = 2, padx = 10, pady = 10)
MULT_MONTH.grid(row = 2, column = 3, padx = 10, pady = 10)
root.mainloop()