A Push is a push and hold button that can be drawn on a display and used to control the parameters being given to a particular function via whether the push is on or off, which is controlled by clicking and holding the mouse. A Push is differentiated from a toggle in that once the mouse is no longer holding the button, it is off. As an example, a Push could be used to trigger a note or pattern being played.
A Push is specified by two diagonal corners, the function to call when the user interacts with it, its various colors (background, foreground, and outline) and outline thickness.
To create a Push, you must have a display to draw it on.
d = Display()
When creating a new Push object, you need to store it in a variable (or other memory location) to be able to use it later.
|Push(x1, y1, x2, y2, updateFunction, foreground, background, outline, thickness)||Creates a Push. x1 and y1 specify coordinates of one corner, x2 and y2 specify coordinates of the diagonal corner. updateFunction (default is None) is the function that the Push calls when clicked. foreground is the color of the Push when clicked (default is red), background is the color behind it (default is black), outline specifies the color of the the Push’s outline (default is to be the same color as the foreground), and thickness specifies the thickness in pixels of this outline (default is 3).|
You can create a Push as follows:
p = Push(50, 25, 75, 50, False, None, Color.GREEN, Color.BLACK, Color.BLUE, 1)
and add it to the display:
Once a push and hold button has been created, the following functions are available:
|p.getValue()||Returns the current value (True or False).|
|p.setValue(newValue)||Sets the current value to ‘newValue’.|