Reference 〉Class

checkGrid( tkinter.Frame parent = None, str text = '', int columns = 3, str fg = '#333', str bg = '#FFF', int padx = 8, int pady = None, tuple(str,int) font = None, bool startOpen = True )

The checkGrid class is an expandableFrame widget filled with textCheck widgets, along with setter and getter methods to interact with the latter by key.

checkGrid is a subclass of expandableFrame, and thus has all the methods and properties of that class as well. These are not listed here.

checkGrid is subscriptable. The value of the textCheck added with the name 'x' can be retrieved with checkGrid['x'], and toggled by setting checkGrid['x']=True or False.

Initialization Parameters

  • parent tkinter.Frame, optional

    The Tkinter frame to which the widget should be attached.

    Default value: None

  • text str, optional

    The title of the frame, clickable to expand and collapse.

    Default value: ''

  • columns int, optional

    The number of columns in which to insert textCheck widgets.

    Default value: 3

  • fg str, optional

    A hex value for the text color.

    Default value: '#333'

  • bg str, optional

    A hex value for the background color.

    Default value: '#FFF'

  • padx int, optional

    The container frame's horizontal padding.

    Default value: 8

  • pady int, optional

    The container frame's vertical padding.

    Default value: None

  • font tuple(str,int), optional

    A font name/size pair.

    Default value: None

  • startOpen bool, optional

    If True, the frame is drawn expanded initially. If False, the frame is drawn collapsed initially.

    Default value: True


Click a method name for more detailed documentation.


  • columns int

    The number of columns in which to insert textCheck widgets.

    Initial value: 3

  • checks dict{str:textCheck}

    The textCheck widgets to be displayed.

    Initial value: {}

Notes and Examples

  1. charwick

    Mar 27, 2020 at 21:34

    Checkgrids can be inserted using GUI hooks where there are lots of values to toggle. This example toggles strategies and puts the checkGrid object in model.strategies for the values to be retrieved later.

    strategies = {
    	'alwaysCooperate': True,
    	'alwaysDefect': True,
    	'randomly': True,
    	'TFT': True,
    	'Tullock': False,
    	'Nydegger': False,
    	'Grofman': False
    #Build the strategies toggle
    def GUIAbovePlotList(gui, bg):
    	gui.model.strategies = checkGrid(parent=gui.parent, text='Strategies', columns=2, bg=bg)
    	for s,v in strategies.items():
    		gui.model.strategies.addCheck(s, s, v)
    	return gui.model.strategies
    heli.addHook('GUIAbovePlotList', GUIAbovePlotList)
    #Use the values later in the model to instantiate breeds
    def modelPreSetup(model):
    	for k,v in model.strategies.items():
    		if v.get(): model.addBreed(k, '#000000')
    heli.addHook('modelPreSetup', modelPreSetup)

    This results in the following panel:

    checkGrid Example

  2. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.