import java # import what we need import javax.swing import com class diameterbutton(com.hp.hpl.guess.ui.DockableAdapter): def __init__(self): # create a new button called center testButton = JButton("Show Diameters") # every time the button is pressed, center the display testButton.actionPerformed = self.getdiameter # add the button to the toolbar self.add(testButton) # add the toolbar to the main UI window ui.dock(self) def getdiameter(self, evt): # set all edges invisible so only diameter will show g.edges.visible = 0 # find diameter execfile("diameter.py") diam = diameter(g.nodes) # show only the paths that should be shown diameterPaths = diam.getDiameters() g.edges.visible = 0 print 'The diameter paths are: ' for path in diameterPaths: print path path.visible = 1 def getTitle(self): # define the title in the window return("Diameter Finder")