A Tkinter toggle control semantically similar to a checkbox, but draws as an overlay on top of the label, rather than a box beside the label, in order to at the same time be more compact and provide a larger clickable area. Used as part of the checkGrid
class, in the plot list in the control panel.
textCheck
is a subclass of tkinter.Label
, so all the properties and methods available to that class are also available here. These are not listed.
Note that this is a Tkinter widget and thus will not work in other frontends like Jupyter notebooks. The recommended way to use textChecks
within a checkGrid
is with the higher-level Params.add()
instead, setting the type
parameter to 'checkgrid'
and the opts
parameter to a dict
of name-label pairs.
WARNING: This is an internal class. Its use in user code is not recommended or supported, and its signature can change in future updates without warning. Use one of the suggested functions above instead, if applicable.
Initialization Parameters
parent — tkinter.Frame, optional
The Tkinter frame to which the text check should be attached.
Default value: None
text — str, optional
The label to be used for the text check.
Default value: None
bg — tuple(str,str), optional
A pair of hex colors corresponding to the background colors for the active and inactive states, respectively.
Default value: ('#FFFFFF','#419BF9')
fg — tuple(str,str), optional
A pair of hex colors corresponding to the text colors for the active and inactive states, respectively.
Default value: ('#333333','#FFFFFF')
font — tuple(str,int), optional
A font name/size pair.
Default value: ('Lucida Grande',12)
defaultValue — bool, optional
The initial value of the text check.
Default value: False
anchor — str, optional
The cardinal direction toward which the element should be anchored.
Default value: 'w'
desc — str, optional
The text to display in a tooltip.
Default value: None
Methods
Click a method name for more detailed documentation.
disable( )
Disable the
textCheck
element so it cannot be interacted with by the user.disabled( disable )
Enables or disables the
textCheck
element. This function is aliased by bothtextCheck.enable()
andtextCheck.disable()
.enable( )
Enables the
textCheck
element so that it can be interacted with by the user.get( )
Returns the boolean value of the text check element. This function is equivalent to checking the value of
textCheck.value
.set( value )
Sets the value of the text check element. This function does nothing if the text check is disabled. See
textCheck.enabled
.toggle( )
Activates the text check if it is deactivated, or deactivates it if it is active.
Note that the function signature takes one optional argument, a Tkinter event string, in order to be used as a callback for a click event. This argument is not used in the function.
Object Properties
bg — tuple(Color,Color)
A pair of background colors corresponding to the active and inactive states for an enabled element, respectively.
fg — tuple(Color,Color)
A pair of text colors corresponding to the active and inactive states for an enabled element, respectively.
disabledbg — tuple(Color,Color)
A pair of background colors corresponding to the active and inactive states for a disabled element, respectively.
disabledfg — tuple(Color,Color)
A pair of text colors corresponding to the active and inactive states for a disabled element, respectively.
value — bool
The activation state of the element.
enabled — bool
Whether or not the user can currently interact with the element.
Notes and Examples