def __init__(self): """ Clipboard object constructor clipbardObject <- Clipboard() """ EventHandler.__init__(self) self.maas = []
def __init__(self): EventHandler.__init__(self) self.maas = [] # will hold the list of [MAA, position] pairs self.currentFrame = 0 self.endFrame = 0 # frame after the last frame for which there is a value self.maxFrame = 0 # these are used internally self.moveForward = True # truwe when palying forward self.needsRedraw = False self.redrawActors = {} # {Viewer Object: RedrawActor}
def __init__(self, master, root, iconsManager=None, selectionMode='single', idleRedraw=True, nodeHeight=15, headerHeight=30, **kw): """Tree( master, root, idleRedraw=True, kw = {}, **opts) - Master can be a Tk frame in which the tree is displayed - root has to be a Node object - iconsManageer has to be an instance of an IconManager object or None. If None is passed, an IconManager with the default icons directory will be created. If an IconManager is passed we expect to find ... - selection mode cane be 'single' or 'multiple'. In multiple mode, the shift modifier is use to select/deselect ranges (ranges can only be defined on sibling nodes) and the Control modifier is used to add/remove to the current selection. Node are selected by click withthe left mouse button on the node's label or icon. - Set idleRedraw to False to disable background drawing. - nodeHeight is the heigh of a node int he Tree in pixels - kw can contain any keywork allowable for a Pmw.ScrolledCanvas """ assert isinstance(root, Node) assert selectionMode in ['single', 'multiple'] EventHandler.__init__(self) self.master = master self.selectionMode = selectionMode self.lastPickedNode = None self.idleRedraw = idleRedraw # when set to true redraw operation # occur when CPU is idle if iconsManager is None: iconsManager = IconsManager( ['gui', 'BasicWidgets', 'Tk', 'trees', 'Icons'], 'mglutil') assert isinstance(iconsManager, IconsManager) self.iconsManager = iconsManager fs = self.fontSize = 10 self.font = "Arial %d" % fs # cache the icons use to expand and collapse since we will # use them for each node mod = __import__('mglutil') packagePath = mod.__path__[0] path = ['gui', 'BasicWidgets', 'Tk', 'trees', 'Icons'] directory = os.path.join(packagePath, os.path.join(*path)) self.collapsedIcon = self.iconsManager.get("1rightarrow.png", directory=directory) self.expandedIcon = self.iconsManager.get("1downarrow.png", directory=directory) self.iconHalfWidth = self.collapsedIcon.width() / 2 self.selectedNodes = [] self.selectionHistory = [] # used to undo selection operations self.nodeHeight = nodeHeight self.headerHeight = headerHeight self.firstVisibleNodeLineNum = 0 # height of the first visible node # i.e. how many nodes drown above, 0 for root self.firstVisibleNode = root # first node visible in window self.displayedNodes = [ ] # list of nodes having a graphical represenation self.pending_draw = None self.suspendRedraw = False self.root = root root.currenty = 0 root.tree = ref(self) root.childNumber = 0 self.nbLines = 1 # height of the tree (i.e. how many lines in canvas) # build the GUI if not kw.has_key('vscrollmode'): kw['vscrollmode'] = 'dynamic' if not kw.has_key('hscrollmode'): kw['hscrollmode'] = 'dynamic' if not kw.has_key('hull_width'): kw['hull_width'] = 550 if not kw.has_key('hull_height'): kw['hull_height'] = 100 if not kw.has_key('background') and not kw.has_key('bg') and \ not kw.has_key('canvas_bg'): kw['canvas_bg'] = 'white' if not kw.has_key('usehullsize'): kw['usehullsize'] = 1 self.nbLinesPerPage = (kw['hull_height'] - self.headerHeight) / nodeHeight if not kw.has_key('yscrollincrement'): kw['canvas_yscrollincrement'] = nodeHeight kw['horizscrollbar_command'] = self.xview kw['vertscrollbar_command'] = self.yview kw['borderframe'] = 5 #kw['canvasmargin'] = 10 #kw['hscrollmode'] = 'none' apply(ScrolledCanvas.__init__, (self, master), kw) canvas = self.canvas = self.component('canvas') KeySelectable.__init__(self, canvas) self.ctrlModCallback = self.handleControlKey canvas.bind("<Configure>", self.configure_cb) canvas.bind("<Key-Prior>", self.pageUp) canvas.bind("<Key-Next>", self.pageDown) canvas.bind("<Key-Up>", self.lineUp) canvas.bind("<Key-Down>", self.lineDown) if os.name == 'nt': #sys.platform == 'win32': canvas.bind("<MouseWheel>", self.lineUpDown) else: canvas.bind("<Button-4>", self.lineUp) canvas.bind("<Button-5>", self.lineDown) canvas.bind("<Enter>", self.enter_cb) self.isControl = False self.isShift = False self.isAlt = False if widgetsOnBackWindowsCanGrabFocus is False: lActiveWindow = canvas.focus_get() if lActiveWindow is not None \ and ( lActiveWindow.winfo_toplevel() != canvas.winfo_toplevel() ): return canvas.focus_set()
assert callable(addingMethod) self.targetNames.append(name) self.targetsByName[name] = (target, addingMethod) def addToTarget(self, name, maa): target, addingMethod = self.targetsByName[name] addingMethod(target, maa) _MAATargets = ScenarioMAATargets() from mglutil.util.callback import CallBackFunction def addTargetsToMenu(menu, maa): for name in _MAATargets.targetNames: cb = CallBackFunction(_MAATargets.addToTarget, name, maa) menu.add_command(label='Add to ' + name, command=cb) # create a default clipboard object that can be shared accros applications # using scenario _clipboard = Clipboard() # # create an event handle for scenario events from mglutil.events import EventHandler _eventHandler = EventHandler()
def __init__(self, master, root, iconsManager=None, selectionMode='single', idleRedraw=True, nodeHeight=15, headerHeight=30, **kw): """Tree( master, root, idleRedraw=True, kw = {}, **opts) - Master can be a Tk frame in which the tree is displayed - root has to be a Node object - iconsManageer has to be an instance of an IconManager object or None. If None is passed, an IconManager with the default icons directory will be created. If an IconManager is passed we expect to find ... - selection mode cane be 'single' or 'multiple'. In multiple mode, the shift modifier is use to select/deselect ranges (ranges can only be defined on sibling nodes) and the Control modifier is used to add/remove to the current selection. Node are selected by click withthe left mouse button on the node's label or icon. - Set idleRedraw to False to disable background drawing. - nodeHeight is the heigh of a node int he Tree in pixels - kw can contain any keywork allowable for a Pmw.ScrolledCanvas """ assert isinstance(root, Node) assert selectionMode in ['single', 'multiple'] EventHandler.__init__(self) self.master = master self.selectionMode = selectionMode self.lastPickedNode = None self.idleRedraw = idleRedraw # when set to true redraw operation # occur when CPU is idle if iconsManager is None: iconsManager = IconsManager( ['gui','BasicWidgets','Tk','trees','Icons'], 'mglutil') assert isinstance(iconsManager, IconsManager) self.iconsManager = iconsManager fs = self.fontSize = 10 self.font = "Arial %d"%fs # cache the icons use to expand and collapse since we will # use them for each node mod = __import__('mglutil') packagePath = mod.__path__[0] path = ['gui','BasicWidgets','Tk','trees','Icons'] directory = os.path.join( packagePath, os.path.join(*path)) self.collapsedIcon = self.iconsManager.get("1rightarrow.png", directory=directory) self.expandedIcon = self.iconsManager.get("1downarrow.png", directory=directory) self.iconHalfWidth = self.collapsedIcon.width()/2 self.selectedNodes = [] self.selectionHistory = [] # used to undo selection operations self.nodeHeight = nodeHeight self.headerHeight = headerHeight self.firstVisibleNodeLineNum = 0 # height of the first visible node # i.e. how many nodes drown above, 0 for root self.firstVisibleNode = root # first node visible in window self.displayedNodes = [] # list of nodes having a graphical represenation self.pending_draw = None self.suspendRedraw = False self.root = root root.currenty = 0 root.tree = ref(self) root.childNumber = 0 self.nbLines = 1 # height of the tree (i.e. how many lines in canvas) # build the GUI if not kw.has_key('vscrollmode'): kw['vscrollmode'] ='dynamic' if not kw.has_key('hscrollmode'): kw['hscrollmode'] ='dynamic' if not kw.has_key('hull_width'): kw['hull_width'] = 550 if not kw.has_key('hull_height'): kw['hull_height'] = 100 if not kw.has_key('background') and not kw.has_key('bg') and \ not kw.has_key('canvas_bg'): kw['canvas_bg']='white' if not kw.has_key('usehullsize'): kw['usehullsize'] = 1 self.nbLinesPerPage = (kw['hull_height']-self.headerHeight) / nodeHeight if not kw.has_key('yscrollincrement'): kw['canvas_yscrollincrement'] = nodeHeight kw['horizscrollbar_command'] = self.xview kw['vertscrollbar_command'] = self.yview kw['borderframe'] = 5 #kw['canvasmargin'] = 10 #kw['hscrollmode'] = 'none' apply( ScrolledCanvas.__init__, (self, master), kw) canvas = self.canvas = self.component('canvas') KeySelectable.__init__(self, canvas) self.ctrlModCallback = self.handleControlKey canvas.bind("<Configure>", self.configure_cb) canvas.bind("<Key-Prior>", self.pageUp) canvas.bind("<Key-Next>", self.pageDown) canvas.bind("<Key-Up>", self.lineUp) canvas.bind("<Key-Down>", self.lineDown) if os.name == 'nt': #sys.platform == 'win32': canvas.bind("<MouseWheel>", self.lineUpDown) else: canvas.bind("<Button-4>", self.lineUp) canvas.bind("<Button-5>", self.lineDown) canvas.bind("<Enter>", self.enter_cb) self.isControl = False self.isShift = False self.isAlt = False if widgetsOnBackWindowsCanGrabFocus is False: lActiveWindow = canvas.focus_get() if lActiveWindow is not None \ and ( lActiveWindow.winfo_toplevel() != canvas.winfo_toplevel() ): return canvas.focus_set()
def __init__(self): EventHandler.__init__(self)