def select(self,items,deselect=0): icomLevel = self.vf.ICOMbar.LevelOption._menubutton.config()['text'][-1] if icomLevel == 'Atom': msg = "The selection level is currently ATOM. Continuing will\nchange it to RESIDUE" d = SimpleDialog(self.vf.GUI.ROOT,text=msg, buttons = ["Abort","Continue"], title = "Warning", default=1) if not d.go(): return AlignmentEditor.select(self,items,deselect) lastSelect = self.lastSelect #just been updated by previous line negate=lastSelect[0] selStrings={} for item in lastSelect[1]: resTag,seqTag,uniqTag = self.canvas.gettags(item)[:3] # if the item is part of a sequence linked to a molecule, # the selection can be applied to Pmv. Since the resTag in this case # is the unique object identifier for the residue, this is easy if seqTag in self.vf.Mols.name: molName = seqTag selectionKey = molName+':'+resTag[:1]+':' resnum = resTag[1:] if selectionKey in selStrings.keys(): selStrings[selectionKey]=selStrings[selectionKey]+','+resnum else: selStrings[selectionKey]=','+resnum for selStr in selStrings.keys(): print selStr+selStrings[selStr] self.vf.select(selStr+selStrings[selStr],negate)
def select(self,items,deselect=0): icomLevel = self.vf.ICOMbar.LevelOption._menubutton.config()['text'][-1] if icomLevel == 'Atom': msg = "The selection level is currently ATOM. Continuing will\nchange it to RESIDUE" d = SimpleDialog(self.vf.GUI.ROOT,text=msg, buttons = ["Abort","Continue"], title = "Warning", default=1) if not d.go(): return AlignmentEditor.select(self,items,deselect) lastSelect = self.lastSelect #just been updated by previous line negate=lastSelect[0] selStrings={} for item in lastSelect[1]: resTag,seqTag,uniqTag = self.canvas.gettags(item)[:3] # if the item is part of a sequence linked to a molecule, # the selection can be applied to Pmv. Since the resTag in this case # is the unique object identifier for the residue, this is easy if seqTag in self.vf.Mols.name: molName = seqTag selectionKey = molName+':'+resTag[:1]+':' resnum = resTag[1:] if selectionKey in selStrings.keys(): selStrings[selectionKey]=selStrings[selectionKey]+','+resnum else: selStrings[selectionKey]=','+resnum for selStr in selStrings.keys(): print selStr+selStrings[selStr] self.vf.select(selStr+selStrings[selStr],negate)
def _buttonPress(self, event): if self.orientation is Tk.VERTICAL: crd = event.y else: crd = event.x gapIndex = -1 for i in range(len(self.gapList)): if crd < self.gapList[i]: gapIndex = i break if gapIndex == -1: raise SystemError, 'cannot identify sash gap' paneAbove = None for above in range(gapIndex, -1, -1): pane = self.paneList[above] if not _isCollapsed(pane): paneAbove = pane break if paneAbove is None: d = SimpleDialog(self.winfo_toplevel(), text='There is no adjustable pane above', buttons=['Okay'], title='User Error') d.go() return paneBelow = None for below in range(gapIndex + 1, len(self.paneList)): pane = self.paneList[below] if not _isCollapsed(pane): paneBelow = pane break if paneBelow is None: d = SimpleDialog(self.winfo_toplevel(), text='There is no adjustable pane below', buttons=['Okay'], title='User Error') d.go() return self.adjustAbove = paneAbove self.adjustBelow = paneBelow self.drag = crd self.bind('<Motion>', self._buttonDrag)
def _buttonPress(self, event): if self.orientation is Tk.VERTICAL: crd = event.y else: crd = event.x gapIndex = -1 for i in range(len(self.gapList)): if crd < self.gapList[i]: gapIndex = i break if gapIndex == -1: raise SystemError, 'cannot identify sash gap' paneAbove = None for above in range(gapIndex, -1, -1): pane = self.paneList[above] if not _isCollapsed(pane): paneAbove = pane break if paneAbove is None: d = SimpleDialog(self.winfo_toplevel(), text='There is no adjustable pane above', buttons=['Okay'], title='User Error') d.go() return paneBelow = None for below in range(gapIndex + 1, len(self.paneList)): pane = self.paneList[below] if not _isCollapsed(pane): paneBelow = pane break if paneBelow is None: d = SimpleDialog(self.winfo_toplevel(), text='There is no adjustable pane below', buttons=['Okay'], title='User Error') d.go() return self.adjustAbove = paneAbove self.adjustBelow = paneBelow self.drag = crd self.bind('<Motion>', self._buttonDrag)
def kill_cb(self, event=None): if not mswin: import signal, Tkinter from SimpleDialog import SimpleDialog text = "Do you really want to kill this process?" d = SimpleDialog(Tkinter._default_root, text=text, buttons=["Yes", "No"], default=0, title="Kill process") result = d.go() if result==0: try: os.kill(self.com.pid,signal.SIGKILL) except: pass else: pass
def kill_cb(self, event=None): if not mswin: import signal, Tkinter from SimpleDialog import SimpleDialog text = "Do you really want to kill this process?" d = SimpleDialog(Tkinter._default_root, text=text, buttons=["Yes", "No"], default=0, title="Kill process") result = d.go() if result == 0: try: os.kill(self.com.pid, signal.SIGKILL) except: pass else: pass
def getparams(): rootdir = os.path.abspath( os.path.curdir ) tkroot = Tk() rootdir = askdirectory( initialdir=rootdir, title='Choose Root Directory' ) # NO '-message' on win32 tk # message='Choose root directory to process' ) bb = [_DVD, 'CDR', 'TEST', 'Cancel' ] d = SimpleDialog( tkroot, text="Please choose media type for " + rootdir, buttons=bb, default=bb.index(_DVD), cancel=bb.index('Cancel'), title='Media' ) d.frame.winfo_toplevel().tkraise() media = bb[d.go()] tkroot.destroy() return rootdir, media
def getparams(): rootdir = os.path.abspath(os.path.curdir) tkroot = Tk() rootdir = askdirectory(initialdir=rootdir, title='Choose Root Directory') # NO '-message' on win32 tk # message='Choose root directory to process' ) bb = [_DVD, 'CDR', 'TEST', 'Cancel'] d = SimpleDialog(tkroot, text="Please choose media type for " + rootdir, buttons=bb, default=bb.index(_DVD), cancel=bb.index('Cancel'), title='Media') d.frame.winfo_toplevel().tkraise() media = bb[d.go()] tkroot.destroy() return rootdir, media
def createActor(self, object, propname, variable = None, check = True, addToDirector = True, actorData=None, redraw = True, valueGenerator = None): #if not object.hasBeenCurrent : # self.setCurrentObjectAttrList(object) #if not hasattr(object, 'animatedProperties'): # object.animatedProperties = {} if not hasattr(object, 'animatableProps'): object.animatableProps = getAnimatableAttributes(object) # create an actor for object.propname descr = object.animatableProps[0][propname] actorname = getActorName(object, propname) director = self._director() newactor = True if check: for i, a in enumerate(director.actors): if a.name == actorname: text = "Actor %s exists. Do you want to overwrite it?\n"%actorname d = SimpleDialog(director.gui.root, text=text, buttons=["Yes", "No"], default=1, title="Overwrite Actor Dialog") result = d.go() if result == 1: return None else: newactor = False # actorind = i break #create the actor actorClass, args, kw = descr['actor'] if valueGenerator is not None: kw['interp'] = valueGenerator if actorData is not None: from scenario.actor import FileActor actor = FileActor(*(propname, object, actorClass, actorData)+args, **kw) actorname = actor.name else: actor = actorClass( *(propname, object)+args, **kw ) actor.scenario = self #object.animatedProperties[actorname] = actor self.animatedProperties[actorname] = actor if not newactor: # director already has an actor with name "actorname", # and the user wishes to overwrite it # replace existing actor whith the new one oldactor = director.actors.pop(actorind) director.gui.deleteActor(oldactor) director.actors.insert(actorind, actor) actor._director = weakref.ref(director) posy = oldactor._posy director.gui.drawActor(actor, posy) if oldactor.guiVar: variable = oldactor.guiVar else: if addToDirector: # add actor to the director director.addActor(actor, redraw) if variable: actor.guiVar = variable return actor
def _complain(self, text): d = SimpleDialog(self.winfo_toplevel(), text=text, buttons=['Okay'], title='User Error') d.go()