Home > Enterprise >  How to remove tkinter radio buttons?
How to remove tkinter radio buttons?

Time:06-17

I using python3 to make tkinter Radiobuttons similar to those at https://www.pythontutorial.net/tkinter/tkinter-radio-button/ to select a name from

all_names = ['Bill', 'Bob', 'Joe', 'Mary', 'Mike']

The list all_names is updated based on other selections in my program. One minute the Radiobuttons allow the user to pick from all_names above. Then all_names is updated to

all_names = ['Ted', 'Joe', 'Mike']

and the Radiobuttons need to reflect the new list all_names which is shorter than before, so two of the previous Radiobuttons need to be removed. The only solution I found is to start by displaying a Label where each previous Radiobutton may have been displayed. Then I display each new Radiobutton over those Labels. I know this is a horrible solution because memory usage keeps increasing needlessly. What is the right way to decrease the number of Radiobuttons displayed?

CodePudding user response:

I just discovered tkinter Combobox which I think is better tool for this. However, I still need to modify the list one can pick from in the Combobox. I was able to get that working by calling destroy on the Combobox and then creating the Combobox with the new list of selections.

Including working code is difficult because I can't get python working on my computer with an internet connection, and my employer doesn't allow the computer with python to connect to the internet.

  • Related