def start(self, gfList, handleSet, event): """start the handler""" self.zoom = self.editor.getZoom() self.composite = Graphics.Composite(gfList, canvas=self.editor.getCanvas(), zoom=self.zoom, eventHandler=self) self.handleSet = handleSet self.previousX = event.x self.previousY = event.y self.relX = 0 self.relY = 0 self.reverseX = 0 self.reverseY = 0 self.totalScaleFactorX = 1. self.totalScaleFactorY = 1.
def compose(self, gfList): if len(gfList) > 1: # create a composite only if it's worth it allGFs = self.getGFs() sortedList = [] for gf in allGFs: if gf in gfList: sortedList.append(gf) indexList = [] for gf in sortedList: indexList.append(self.removeGF(gf)) composite = Graphics.Composite(sortedList, canvas=self.canvas, zoom=self.getZoom(), eventHandler=self.mainHandler) self.insertGF(indexList[len(indexList) - 1], composite) self.undoStack.append((self.undo_compose, [composite, indexList])) return [composite] else: return gfList
def openOLD(self): if (0): return [] elif (1): fileName = os.path.join(self.modelPath, 'graph_' + self.className + '.gf1') if (os.path.exists(fileName)): f = open(fileName, 'r') else: return [] try: gfList = pickle.load(f) except ImportError: print "Failed to load pickled graphic data" return [] # Get the scripting stuff out of the way... self.scripting = gfList[0] if (self.scripting.getRunTimeChange()): self.menuBar.getModelMenu().entryconfigure( 0, label="Changes at run-time ENABLED") else: self.menuBar.getModelMenu().entryconfigure( 0, label="Changes at run-time DISABLED") for gf in gfList[1:]: gf.setCanvas(self.canvas) gf.setEventHandler(self.mainHandler) return gfList[1:] elif (0): return [ Graphics.Rectangle(50, 50, 90, 90, canvas=self.canvas, outline="black", fill="blue", width=2, eventHandler=self.mainHandler), Graphics.Oval(50, 50, 90, 90, canvas=self.canvas, outline="black", fill="green", eventHandler=self.mainHandler), Graphics.Text(70, 90, canvas=self.canvas, zoom=1.00, eventHandler=self.mainHandler, text="text", fill="red"), Graphics.Connector(100, 100, canvas=self.canvas, zoom=1.00, eventHandler=self.mainHandler), Graphics.Polygon([50, 50, 90, 90, 32, 2], canvas=self.canvas, outline="green", fill="purple", width=2, eventHandler=self.mainHandler), Graphics.Line([50, 10, 50, 50, 132, 50], canvas=self.canvas, fill="black", eventHandler=self.mainHandler), Graphics.Composite([ Graphics.Rectangle(50, 20, 140, 100, canvas=self.canvas, outline="black", fill="yellow", width=2, eventHandler=self.mainHandler), Graphics.Rectangle(50, 50, 100, 120, canvas=self.canvas, outline="black", fill="purple", width=2, eventHandler=self.mainHandler), Graphics.Oval(70, 20, 40, 90, canvas=self.canvas, outline="black", fill="green", width=2, eventHandler=self.mainHandler), Graphics.Oval(50, 50, 40, 20, canvas=self.canvas, outline="black", fill="gray", width=2, eventHandler=self.mainHandler) ], canvas=self.canvas, zoom=100, eventHandler=self.mainHandler) ]