Tkinter Managing Group of Checkbuttons by Select UnSelect all & limiting number of user selections

preview_player
Показать описание

By using one single Checkbutton we can change the status of a group of Checkbuttons to Check All or Uncheck all.
Each l Checkbuttons are connected to one IntVar() or integer variable.
Similarly if the master button is unchecked then all the Checkbuttons are unchecked by using deselect method.

Limiting maximum number of selection by user
In a group of checkbuttons if the maximum number of selection by user can be restricted. Once the selection reaches the upper limit then balance Checkbuttons ( which are not selected ) will be disabled for any further selection by user.
If the user wants to change the selection then they can un check any of the checked options and then the full group of checkbutton will be available for fresh selection.
Each button will be connected to one function ( my_upd() ) and this function will be called when ever any checkbutton status is changed.
Inside the function one counter is used and this counter is incremented by checking all the checked Checkbuttons. If the counter is reached the maximum value then all the buttons which are not checked is disabled by using state option. For all these changes config() method is used.
User can change the selection by unchecking one of the selected Checkbutton. This will make all the buttons available to user to change the selection.
Each time user changes its choice, the function my_upd() is executed and the data is recalculated to enable or disable the Checkbuttons.
Рекомендации по теме
Комментарии
Автор

you're awesome!
greetings from Colombia!

danielchicaiza