def chooseColor(self, event=None): top = Tkinter.Toplevel() colorChooser = ColorChooser(top, title='library color', immediate=1, commands=[self.setColor]) colorChooser.pack()
def changeColor(self, event=None): #col = self.palette.display(callback=self.color_cb, modal=1) #self.palette.pack(fill='both', expand=1) # Create a ColorChooser. if not hasattr(self, 'palette'): self.palette = ColorChooser(commands=self.color_cb, exitFunction=self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() else: self.palette.master.deiconify()
def onAddCmdToViewer(self): self.verts = [] if self.vf.hasGui: self.initGeom() #from DejaVu.Labels import Labels self.showAll = Tkinter.IntVar() self.showAll.set(1) self.vf.loadModule('labelCommands', 'Pmv', log=0) # Create a ColorChooser. self.palette = ColorChooser(commands=self.color_cb, exitFunction=self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() self.showAll = None self.width = 100 self.height = 100 self.winfo_x = None self.winfo_y = None
def changeColor(self, event=None): #col = self.palette.display(callback=self.color_cb, modal=1) #self.palette.pack(fill='both', expand=1) # Create a ColorChooser. if not hasattr(self, 'palette'): self.palette = ColorChooser(commands=self.color_cb, exitFunction = self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() else: self.palette.master.deiconify()
def onAddCmdToViewer(self): self.verts = [] if self.vf.hasGui: self.initGeom() #from DejaVu.Labels import Labels self.showAll = Tkinter.IntVar() self.showAll.set(1) self.vf.loadModule('labelCommands', 'Pmv', log=0) # Create a ColorChooser. self.palette = ColorChooser(commands=self.color_cb, exitFunction = self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() self.showAll = None self.width = 100 self.height = 100 self.winfo_x = None self.winfo_y = None
class DisplayStruts(MVCommand): """ * Display and Return a vector of support posts for rapid prototyping models * along the lines of George Phillips for Pymol except on actual molecular * segments (biopolymers), not PDB chains (which may or may not be * continuous). => work actually on chain \nPackage : Pmv \nModule : strutsCommands \nClass : DisplayStruts \nCommand : displayStruts \nSynopsis:\n None <--- displayStruts(node) """ def __init__(self, func=None): MVCommand.__init__(self, func) self.flag = self.flag | self.objArgOnly def initGeom(self): #initialize: # self.geom # self.hasGeom pass def onAddCmdToViewer(self): self.verts = [] if self.vf.hasGui: self.initGeom() #from DejaVu.Labels import Labels self.showAll = Tkinter.IntVar() self.showAll.set(1) self.vf.loadModule('labelCommands', 'Pmv', log=0) # Create a ColorChooser. self.palette = ColorChooser(commands=self.color_cb, exitFunction=self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() self.showAll = None self.width = 100 self.height = 100 self.winfo_x = None self.winfo_y = None def hidePalette_cb(self, event=None): self.palette.hide() def reset(self): self.geom.Set(vertices=[], tagModified=False) self.vf.GUI.VIEWER.Redraw() self.hasGeom = 0 def update(self, event=None): self.radii = self.radii_esw.get() self.hasGeom = 0 self.showAllStruts() def color_cb(self, colors): from DejaVu import colorTool self.geom.Set(materials=(colors[:3], ), tagModified=False) self.vf.GUI.VIEWER.Redraw() def changeColor(self, event=None): #col = self.palette.display(callback=self.color_cb, modal=1) #self.palette.pack(fill='both', expand=1) # Create a ColorChooser. if not hasattr(self, 'palette'): self.palette = ColorChooser(commands=self.color_cb, exitFunction=self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() else: self.palette.master.deiconify() def getIfd(self, atNames): #base class pass def setUpWidgets(self, atNames): if not hasattr(self, 'ifd'): self.getIfd(atNames) self.radii_esw = self.ifd.entryByName['radii']['widget'] self.lb = self.ifd.entryByName['atsLC']['widget'].lb def doit(self, ats): #DisplayStruts base class self.reset() hbats = AtomSet(ats.get(lambda x: hasattr(x, 'struts'))) if not hbats: self.warningMsg('no struts bonds found, please compute them') return 'ERROR' self.hats = hbats self.showAllHBonds() def updateQuality(self, event=None): # asSpheres self.quality = self.quality_sl.get() self.geom.Set(quality=quality, tagModified=False) self.showAllHBonds() def dismiss_cb(self, event=None, **kw): # base class self.reset() try: self.width = str(self.toplevel.winfo_width()) self.height = str(self.toplevel.winfo_height()) self.winfo_x = str(self.toplevel.winfo_x()) self.winfo_y = str(self.toplevel.winfo_y()) except: pass self.vf.GUI.VIEWER.Redraw() if hasattr(self, 'ifd'): delattr(self, 'ifd') if hasattr(self, 'form2'): self.form2.destroy() delattr(self, 'form2') if hasattr(self, 'form'): self.form.destroy() delattr(self, 'form') if hasattr(self, 'palette'): #self.palette.exit() self.palette.hide() def setupDisplay(self): #draw geom between hAts OR donAts and accAts self.geom.Set(vertices=self.verts, radius=self.radius, tagModified=False) self.vf.GUI.VIEWER.Redraw() def interpolate(self, pt1, pt2): # self.spacing = .4 length = dist(pt1, pt2) c1 = Numeric.array(pt1) c2 = Numeric.array(pt2) n = length / self.spacing npts = int(math.floor(n)) # use floor of npts to set distance between > spacing delta = (c2 - c1) / (1.0 * npts) ##spacing = length/floor(npts) vertList = [] for i in range(npts): vertList.append((c1 + i * delta).tolist()) vertList.append(pt2.tolist()) return vertList def setDVerts(self, entries, event=None): if not hasattr(self, 'ifd2'): self.changeDVerts() lb = self.ifd2.entryByName['datsLC']['widget'].lb if lb.curselection() == (): return atName = lb.get(lb.curselection()) ind = int(lb.curselection()[0]) for h in self.hats: for b in h.hbonds: ats = b.donAt.parent.atoms.get( lambda x, atName=atName: x.name == atName) if ats is None or len(ats) == 0: if b.hAt is not None: at = b.hAt else: at = b.donAt else: at = ats[0] b.spVert1 = at self.hasGeom = 0 self.showAllHBonds() def setAVerts(self, entries, event=None): if not hasattr(self, 'ifd2'): self.changeDVerts() lb = self.ifd2.entryByName['aatsLC']['widget'].lb if lb.curselection() == (): return atName = lb.get(lb.curselection()) ind = int(lb.curselection()[0]) for h in self.hats: for b in h.hbonds: ats = b.accAt.parent.atoms.get( lambda x, atName=atName: x.name == atName) if ats is None or len(ats) == 0: at = b.accAt else: at = ats[0] b.spVert2 = at self.hasGeom = 0 self.showAllHBonds() def changeDVerts(self, event=None): #for all residues in hbonds, pick new donorAttachment # and new acceptorAttachment entries = [] ns = ['N', 'C', 'O', 'CA', 'reset'] for n in ns: entries.append((n, None)) if hasattr(self, 'form2'): self.form2.root.tkraise() return ifd2 = self.ifd2 = InputFormDescr(title='Set Anchor Atoms') ifd2.append({ 'name': 'datsLC', 'widgetType': ListChooser, 'wcfg': { 'entries': entries, 'mode': 'single', 'title': 'Donor Anchor', 'command': CallBackFunction(self.setDVerts, entries), 'lbwcfg': { 'height': 5, 'selectforeground': 'red', 'exportselection': 0, #'lbpackcfg':{'fill':'both', 'expand':1}, 'width': 30 }, }, 'gridcfg': { 'sticky': 'wens', 'columnspan': 2 } }) ifd2.append({ 'name': 'aatsLC', 'widgetType': ListChooser, 'wcfg': { 'entries': entries, 'mode': 'single', 'title': 'Acceptor Anchor', 'command': CallBackFunction(self.setAVerts, entries), 'lbwcfg': { 'height': 5, 'selectforeground': 'red', #'lbpackcfg':{'fill':'both', 'expand':1}, 'exportselection': 0, 'width': 30 }, }, 'gridcfg': { 'sticky': 'wens', 'columnspan': 2 } }) ifd2.append({ 'name': 'doneBut', 'widgetType': Tkinter.Button, 'wcfg': { 'text': 'Done', 'command': self.closeChangeDVertLC }, 'gridcfg': { 'sticky': 'wens' } }) self.form2 = self.vf.getUserInput(self.ifd2, modal=0, blocking=0) self.form2.root.protocol('WM_DELETE_WINDOW', self.closeChangeDVertLC) def closeChangeDVertLC(self, event=None): if hasattr(self, 'ifd2'): delattr(self, 'ifd2') if hasattr(self, 'form2'): self.form2.destroy() delattr(self, 'form2') def showAllHBonds(self, event=None): pass #self.geom.Set(vertices = self.verts, radii = self.radii, # tagModified=False) #self.vf.GUI.VIEWER.Redraw() def guiCallback(self): #showHbonds if not len(self.vf.Mols): self.warningMsg('no molecules in viewer') return sel = self.vf.getSelection() #put a selector here if len(sel): ats = sel.findType(Atom) apply(self.doitWrapper, (ats, ), {})
class DisplayStruts(MVCommand): """ * Display and Return a vector of support posts for rapid prototyping models * along the lines of George Phillips for Pymol except on actual molecular * segments (biopolymers), not PDB chains (which may or may not be * continuous). => work actually on chain \nPackage : Pmv \nModule : strutsCommands \nClass : DisplayStruts \nCommand : displayStruts \nSynopsis:\n None <--- displayStruts(node) """ def __init__(self, func=None): MVCommand.__init__(self, func) self.flag = self.flag | self.objArgOnly def initGeom(self): #initialize: # self.geom # self.hasGeom pass def onAddCmdToViewer(self): self.verts = [] if self.vf.hasGui: self.initGeom() #from DejaVu.Labels import Labels self.showAll = Tkinter.IntVar() self.showAll.set(1) self.vf.loadModule('labelCommands', 'Pmv', log=0) # Create a ColorChooser. self.palette = ColorChooser(commands=self.color_cb, exitFunction = self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() self.showAll = None self.width = 100 self.height = 100 self.winfo_x = None self.winfo_y = None def hidePalette_cb(self, event=None): self.palette.hide() def reset(self): self.geom.Set(vertices=[], tagModified=False) self.vf.GUI.VIEWER.Redraw() self.hasGeom = 0 def update(self, event=None): self.radii = self.radii_esw.get() self.hasGeom =0 self.showAllStruts() def color_cb(self, colors): from DejaVu import colorTool self.geom.Set(materials = (colors[:3],), tagModified=False) self.vf.GUI.VIEWER.Redraw() def changeColor(self, event=None): #col = self.palette.display(callback=self.color_cb, modal=1) #self.palette.pack(fill='both', expand=1) # Create a ColorChooser. if not hasattr(self, 'palette'): self.palette = ColorChooser(commands=self.color_cb, exitFunction = self.hidePalette_cb) # pack self.palette.pack(fill='both', expand=1) # hide it self.palette.hide() else: self.palette.master.deiconify() def getIfd(self, atNames): #base class pass def setUpWidgets(self, atNames): if not hasattr(self, 'ifd'): self.getIfd(atNames) self.radii_esw = self.ifd.entryByName['radii']['widget'] self.lb = self.ifd.entryByName['atsLC']['widget'].lb def doit(self, ats): #DisplayStruts base class self.reset() hbats = AtomSet(ats.get(lambda x: hasattr(x, 'struts'))) if not hbats: self.warningMsg('no struts bonds found, please compute them') return 'ERROR' self.hats = hbats self.showAllHBonds() def updateQuality(self, event=None): # asSpheres self.quality = self.quality_sl.get() self.geom.Set(quality=quality, tagModified=False) self.showAllHBonds() def dismiss_cb(self, event=None, **kw): # base class self.reset() try: self.width = str(self.toplevel.winfo_width()) self.height = str(self.toplevel.winfo_height()) self.winfo_x = str(self.toplevel.winfo_x()) self.winfo_y = str(self.toplevel.winfo_y()) except: pass self.vf.GUI.VIEWER.Redraw() if hasattr(self, 'ifd'): delattr(self, 'ifd') if hasattr(self, 'form2'): self.form2.destroy() delattr(self, 'form2') if hasattr(self, 'form'): self.form.destroy() delattr(self, 'form') if hasattr(self, 'palette'): #self.palette.exit() self.palette.hide() def setupDisplay(self): #draw geom between hAts OR donAts and accAts self.geom.Set(vertices = self.verts, radius = self.radius, tagModified=False) self.vf.GUI.VIEWER.Redraw() def interpolate(self, pt1, pt2): # self.spacing = .4 length = dist(pt1, pt2) c1 = Numeric.array(pt1) c2 = Numeric.array(pt2) n = length/self.spacing npts = int(math.floor(n)) # use floor of npts to set distance between > spacing delta = (c2-c1)/(1.0*npts) ##spacing = length/floor(npts) vertList = [] for i in range(npts): vertList.append((c1+i*delta).tolist()) vertList.append(pt2.tolist()) return vertList def setDVerts(self, entries, event=None): if not hasattr(self, 'ifd2'): self.changeDVerts() lb = self.ifd2.entryByName['datsLC']['widget'].lb if lb.curselection() == (): return atName = lb.get(lb.curselection()) ind = int(lb.curselection()[0]) for h in self.hats: for b in h.hbonds: ats = b.donAt.parent.atoms.get(lambda x, atName=atName: x.name==atName) if ats is None or len(ats) == 0: if b.hAt is not None: at = b.hAt else: at = b.donAt else: at = ats[0] b.spVert1 = at self.hasGeom = 0 self.showAllHBonds() def setAVerts(self, entries, event=None): if not hasattr(self, 'ifd2'): self.changeDVerts() lb = self.ifd2.entryByName['aatsLC']['widget'].lb if lb.curselection() == (): return atName = lb.get(lb.curselection()) ind = int(lb.curselection()[0]) for h in self.hats: for b in h.hbonds: ats = b.accAt.parent.atoms.get(lambda x, atName=atName: x.name==atName) if ats is None or len(ats) == 0: at = b.accAt else: at = ats[0] b.spVert2 = at self.hasGeom = 0 self.showAllHBonds() def changeDVerts(self, event=None): #for all residues in hbonds, pick new donorAttachment # and new acceptorAttachment entries = [] ns = ['N','C','O','CA','reset'] for n in ns: entries.append((n, None)) if hasattr(self, 'form2'): self.form2.root.tkraise() return ifd2 = self.ifd2=InputFormDescr(title = 'Set Anchor Atoms') ifd2.append({'name': 'datsLC', 'widgetType':ListChooser, 'wcfg':{ 'entries': entries, 'mode': 'single', 'title': 'Donor Anchor', 'command': CallBackFunction(self.setDVerts, entries), 'lbwcfg':{'height':5, 'selectforeground': 'red', 'exportselection': 0, #'lbpackcfg':{'fill':'both', 'expand':1}, 'width': 30}, }, 'gridcfg':{'sticky':'wens', 'columnspan':2}}) ifd2.append({'name': 'aatsLC', 'widgetType':ListChooser, 'wcfg':{ 'entries': entries, 'mode': 'single', 'title': 'Acceptor Anchor', 'command': CallBackFunction(self.setAVerts, entries), 'lbwcfg':{'height':5, 'selectforeground': 'red', #'lbpackcfg':{'fill':'both', 'expand':1}, 'exportselection': 0, 'width': 30}, }, 'gridcfg':{'sticky':'wens', 'columnspan':2}}) ifd2.append({'name':'doneBut', 'widgetType':Tkinter.Button, 'wcfg': { 'text':'Done', 'command': self.closeChangeDVertLC}, 'gridcfg':{'sticky':'wens'}}) self.form2 = self.vf.getUserInput(self.ifd2, modal=0, blocking=0) self.form2.root.protocol('WM_DELETE_WINDOW',self.closeChangeDVertLC) def closeChangeDVertLC(self, event=None): if hasattr(self, 'ifd2'): delattr(self, 'ifd2') if hasattr(self, 'form2'): self.form2.destroy() delattr(self, 'form2') def showAllHBonds(self, event=None): pass #self.geom.Set(vertices = self.verts, radii = self.radii, # tagModified=False) #self.vf.GUI.VIEWER.Redraw() def guiCallback(self): #showHbonds if not len(self.vf.Mols): self.warningMsg('no molecules in viewer') return sel = self.vf.getSelection() #put a selector here if len(sel): ats = sel.findType(Atom) apply(self.doitWrapper, (ats,), {})