Example 1: A Simple Button
Lets say we want to modify the interface to have a button that when pressed will center the display. We could create a new type of object called a dockexample1 in the following way:
import java # import what we need
import javax.swing
import com
class dockexample1(com.hp.hpl.guess.ui.DockableAdapter):
def __init__(self):
# create a new button called center
testButton = JButton("center")
# every time the button is pressed, center the display
testButton.actionPerformed = lambda event: center()
# add the button to the toolbar
self.add(testButton)
# add the toolbar to the main UI window
ui.dock(self)
def getTitle(self):
# define the title in the window
return("dockexample1")
If we save this script to a file called example.py we can make use of it in GUESS by executing the file:
execfile(“example.py”)
and then creating a new dockexample1 object:
dockexample1()



