A Push object simulates is a push-and-hold button (i.e., the button is on while you press on it, and off otherwise). A Push object is created using the following function. It is specified by two diagonal corners, the function to call when the user presses it, its various colors (background, foreground, and outline), and outline thickness.
Function | Description |
Push(x1, y1, x2, y2, updateFunction, foreground, background, outline, thickness) | Creates a Push object.
|
You can create a Push button as follows:
# function to specify what happens when button is pressed def printPush( value ): if value: # if value is True, push button is pressed print "Yes" # replace this with whatever you want done when pressed else: # else value is False (i.e., push button is released) print "No" # replace this with whatever you want done when unpressed (if any) push = Push(50, 400, 100, 450, printPush, Color.BLUE, Color.RED) display1.add(push)
Once a push and hold button has been created, the following functions are available:
Function | Description |
push.getValue() | Returns the current value (True or False). |
push.setValue(value) | Sets the current value to value. |