lundi 17 mai 2021

GTK-Python Multiple Checkbutton Behavior

I have a GTK3 GUI run by Python 3.7.There are 4 checkbuttons on the GUI. I need to set them behave like a group. If at least one of the sub-checkbuttons is unchecked, main-checkbutton should be in inconsistent state. If every of the sub-checkbuttons are selected, main-checkbutton should be checked.

Here are some images for better understanding:

enter image description here enter image description here

I could set this behavior by using some counting variables, by disconnecting signals, setting behaviors and connecting signals again in order to avoid running some functions multiple times when user changes state of the one checkbutton. But this code loos very complex. Are there any simpler ways to do that? For example, radiobuttons allow designer to set groups for a similar behavior.




Aucun commentaire:

Enregistrer un commentaire