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.

  • x1 and y1 specify coordinates of the top-left corner, x2 and y2 specify coordinates of the bottom-right corner.
  • updateFunction specifies what to do when clicked.
  • foreground is the color when clicked (default is Color.RED).
  • background is the color behind it (default is Color.BLACK).
  • outline is the outline color (default is the same as foreground).
  • thickness is the outline thickness in pixels (default is 3).

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)


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.