def body(self, guiFrame): self.geometry('500x500') guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(1, weight=1) frame = LabelFrame(guiFrame, text='RDC protocol settings') frame.grid(row=1, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) self.floatEntry = FloatEntry(self, returnCallback=self.setValue) headingList = ['Parameter', 'Value', 'Description'] justifyList = ['center', 'center', 'left'] editWidgets = [None, self.floatEntry, None] editGetCallbacks = [None, self.getValue, None] editSetCallbacks = [None, self.setValue, None] self.rdcMatrix = ScrolledMatrix(frame, headingList=headingList, justifyList=justifyList, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, multiSelect=False, initialRows=10, passSelfToCallback=True, callback=self.selectRdc) self.rdcMatrix.grid(row=0, column=0, sticky='nsew') self.rdcMatrix.refreshFunc = self.updateRdcSet self.updateRdcSet()
def body(self, guiParent): guiParent.grid_columnconfigure(0, weight=1) row = 0 guiParent.grid_rowconfigure(row, weight=1) inputFrame = LabelFrame(guiParent, text='Inputs:') inputFrame.grid(row=row, column=0, sticky=Tkinter.NSEW) label = Label(inputFrame, text='NOESY:') label.grid(row=0, column=0, sticky=Tkinter.NW) self.hNoesyPulldown = PulldownMenu(inputFrame,callback=self.setHNoesy) self.hNoesyPulldown.grid(row=0, column=1, sticky=Tkinter.NW) label = Label(inputFrame, text='15N NOESY:') label.grid(row=1, column=0, sticky=Tkinter.NW) self.nNoesyPulldown = PulldownMenu(inputFrame,callback=self.setNNoesy) self.nNoesyPulldown.grid(row=1, column=1, sticky=Tkinter.NW) label = Label(inputFrame, text='13C NOESY:') label.grid(row=2, column=0, sticky=Tkinter.NW) self.cNoesyPulldown = PulldownMenu(inputFrame,callback=self.setCNoesy) self.cNoesyPulldown.grid(row=2, column=1, sticky=Tkinter.NW) label = Label(inputFrame, text='Shift List:') label.grid(row=3, column=0, sticky=Tkinter.NW) self.shiftListPulldown = PulldownMenu(inputFrame,callback=self.setShiftList) self.shiftListPulldown.grid(row=3, column=1, sticky=Tkinter.NW) label = Label(inputFrame, text='2d BACUS executable:') label.grid(row=4, column=0, sticky=Tkinter.NW) self.executableEntry = Entry(inputFrame, text='/home/tjs23/clouds/justin/SpiBacusMidge/bacus/bacus_tjs.exe') self.executableEntry.grid(row=4, column=1, sticky=Tkinter.NW) self.executableButton = Button(inputFrame, text='Choose file', command=self.chooseExecutable) self.executableButton.grid(row=5, column=1, sticky=Tkinter.EW) row += 1 outputFrame = LabelFrame(guiParent, text='Output:') outputFrame.grid(row=row, column=0, sticky=Tkinter.NSEW) row += 1 texts = ['Run BACUS 2d','Run BACUS 3d'] commands = [self.runBacus,self.runBacus3d] self.bottomButtons = createDismissHelpButtonList(guiParent,texts=texts,commands=commands,expands=0,help_url=None) self.bottomButtons.grid(row=row, column=0, sticky=Tkinter.EW) self.update()
def body(self, guiFrame): guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(1, weight=1) frame = LabelFrame(guiFrame, text='Options') frame.grid(row=0,column=0,sticky='ew') frame.grid_columnconfigure(5, weight=1) # Choose type of symmetry set to define or change (if allready present in the model) self.molLabel = Label(frame, text='Symmetry Operator:') self.molLabel.grid(row=0,column=2,sticky='w') self.symmCodePulldown = PulldownMenu(frame, callback=self.setSymmCode, entries=['NCS','C2','C3','C5'], do_initial_callback=False) self.symmCodePulldown.grid(row=0,column=3,sticky='w') frame = LabelFrame(guiFrame, text='Symmetry Operations') frame.grid(row=1,column=0,sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) self.molSysPulldown = PulldownMenu(self, callback=self.setMolSystem, do_initial_callback=False) self.chainSelect = MultiWidget(self, CheckButton, callback=self.setChains, minRows=0, useImages=False) self.segStartEntry = IntEntry(self, returnCallback=self.setSegStart, width=6) self.segLengthEntry = IntEntry(self, returnCallback=self.setSegLength, width=6) headings = ['#','Symmetry\noperator','Mol System','Chains','Start\nresidue','Segment\nlength'] editWidgets = [None, None, self.molSysPulldown, self.chainSelect, self.segStartEntry, self.segLengthEntry] editGetCallbacks = [None, None, self.getMolSystem, self.getChains, self.getSegStart, self.getSegLength] editSetCallbacks = [None, self.setSymmCode, self.setMolSystem, self.setChains, self.setSegStart, self.setSegLength] self.symmetryMatrix = ScrolledMatrix(frame,headingList=headings, callback=self.selectSymmetry, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks) self.symmetryMatrix.grid(row=0,column=0,sticky='nsew') texts = ['Add Symmetry Set','Remove Symmetry Set'] commands = [self.addSymmetrySet,self.removeSymmetrySet] self.buttonList = createDismissHelpButtonList(guiFrame, texts=texts, commands=commands, expands=True) self.buttonList.grid(row=2,column=0,sticky='ew') self.updateMolPartners() self.notify(self.registerNotify) #Temporary report of parameters print self.molSystem print self.molecules print self.symmetrySet print self.symmetryOp print self.symmetryCode
def body(self, guiFrame): guiFrame.grid_rowconfigure(0, weight=1) guiFrame.grid_columnconfigure(0, weight=1) row = 0 frame = LabelFrame(guiFrame, text='Matched Peak Groups') frame.grid_rowconfigure(0, weight=1) frame.grid_columnconfigure(0, weight=1) frame.grid(row=row, sticky='nsew') headingList, tipTexts = self.getHeadingList() self.scrolledMatrix = ScrolledMatrix(frame, initialRows=15, multiSelect=True, headingList=headingList, tipTexts=tipTexts, grid=(0,0), gridSpan=(1,3)) tipTexts = ['Remove the selected peak groups from the table', 'Show 1D positional ruler lines for the selected groups', 'Remove any ruler lines previously added for peak group', 'Display selected peak groups within strips of selected window'] texts = ['Remove\nGroups','Show\nRulers', 'Delete\nRulers','Display Groups\nIn Strips'] commands = [self.removeGroups,self.addRulers, self.removeRulers,self.stripGroups] self.buttons = ButtonList(frame, texts=texts, commands=commands, tipTexts=tipTexts) self.buttons.grid(row=1, column=0, sticky='ew') tipText = 'Selects the spectrum window in which to display strips & ruler lines' label = Label(frame, text='Target window:', grid=(1,1)) self.windowPulldown = PulldownList(frame, callback=None, grid=(1,2), tipText=tipText) row+= 1 bottomButtons = UtilityButtonList(guiFrame, helpUrl=self.help_url, expands=True, doClone=False) bottomButtons.grid(row = row, sticky = 'ew') self.update() for func in ('__init__', 'delete', 'setName'): self.registerNotify(self.updateWindowsAfter, 'ccpnmr.Analysis.SpectrumWindow', func)
def body(self, guiFrame): '''This method describes the outline of the body of the application. args: guiFrame: frame the body should live in. ''' self.geometry('800x530') guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(0, weight=0) guiFrame.grid_rowconfigure(1, weight=2) guiFrame.grid_rowconfigure(2, weight=1) isotopeFrame = LabelFrame(guiFrame, text='Isotope Shift Correction CA and CB') isotopeFrame.grid(row=0, column=0, sticky='nsew') frameA = LabelFrame(guiFrame, text='Spin Systems') frameA.grid(row=1, column=0, sticky='nsew') frameA.grid_rowconfigure(0, weight=1) frameA.grid_columnconfigure(0, weight=1) frameA.grid_columnconfigure(1, weight=1) frameA1 = LabelFrame(frameA, text='Spin System 1') frameA1.grid(row=0, column=0, sticky='nsew') frameA1.grid_columnconfigure(0, weight=1) frameA1.grid_rowconfigure(0, weight=1) frameA2 = LabelFrame(frameA, text='Spin System 2') frameA2.grid(row=0, column=1, sticky='nsew') frameA2.grid_columnconfigure(0, weight=1) frameA2.grid_rowconfigure(0, weight=1) frameB = LabelFrame(guiFrame, text='Comparison') frameB.grid(row=2, column=0, sticky='nsew') frameB.grid_rowconfigure(0, weight=1) frameB.grid_columnconfigure(0, weight=1) frameB.grid_columnconfigure(1, weight=2) frameB.grid_columnconfigure(2, weight=1) frameB1 = LabelFrame(frameB, text='Unique to Spin System 1') frameB1.grid(row=0, column=0, sticky='nsew') frameB1.expandGrid(0, 0) frameB2 = LabelFrame(frameB, text='Intersection') frameB2.grid(row=0, column=1, sticky='nsew') frameB2.expandGrid(0, 0) frameB3 = LabelFrame(frameB, text='Unique to Spin System 2') frameB3.grid(row=0, column=2, sticky='nsew') frameB3.expandGrid(0, 0) # Settings for isotope shift correction shiftLists = getShiftLists(self.nmrProject) self.protonatedShiftList = shiftLists[0] self.deuteratedShiftList = shiftLists[1] shiftListNames = ['{}: {}'.format(shiftList.serial, shiftList.name) for shiftList in shiftLists] Label(isotopeFrame, text='Correct for isotope shift:', grid=(0, 0)) self.correctCheck = CheckButton(isotopeFrame, selected=True, callback=self.setCorrection, grid=(0, 1)) Label(isotopeFrame, text='Protonated shift list:', grid=(1, 0)) self.protonatedPulldown = PulldownList(isotopeFrame, callback=self.setProtonatedShiftList, texts=shiftListNames, objects=shiftLists, grid=(1, 1), index=0) Label(isotopeFrame, text='Deuterated shift list:', grid=(2, 0)) self.deuteratedPulldown = PulldownList(isotopeFrame, callback=self.setDeuteratedShiftList, texts=shiftListNames, objects=shiftLists, grid=(2, 1), index=1) # Table A1 headingList = ['#', 'shift lists', 'Assignment'] tipTexts = ['Spin System Serial', 'shift lists', 'The residue (tentatively) assigned to this spin system', 'The amount of spin systems that overlap with this spin system and have no violations'] editGetCallbacks = [self.setSpinSystem1]*3 editSetCallbacks = [None]*3 self.tableA1 = ScrolledMatrix(frameA1, headingList=headingList, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA1.grid(row=0, column=0, sticky='nsew') # Table A2 headingList = ['#', 'shift lists', 'Assignment', 'offset'] tipTexts = ['Spin System Serial', 'The residue (tentatively) assigned to this spin system', 'Root mean squared deviation of this spin system to the spin system selected in the table on the left.'] editGetCallbacks = [self.setSpinSystem2]*4 editSetCallbacks = [None]*4 self.tableA2 = ScrolledMatrix(frameA2, headingList=headingList, #editWidgets=editWidgets, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA2.grid(row=0, column=0, sticky='nsew') # Table B1 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift'] self.tableB1 = ScrolledMatrix(frameB1, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB1.grid(row=0, column=0, sticky='nsew') # Table B 2 headingList = ['atom', 'c.s. 1', 'c.s. 2', 'delta c.s.'] tipTexts = ['name of the atom', 'chemical shift of atom with this name in spin system 1', 'chemical shift of atom with this name in spin system 2', 'difference between the chemical shift of spin systems 1 and 2'] self.tableB2 = ScrolledMatrix(frameB2, headingList=headingList, tipTexts=tipTexts) self.tableB2.grid(row=0, column=0, sticky='nsew') # Table B 3 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift.'] self.tableB3 = ScrolledMatrix(frameB3, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB3.grid(row=0, column=0, sticky='nsew') self.matchMatrix = {} self.amountOfMatchesPerSpinSystem = {} self.updateTableA1()
def body(self): '''Describes the body of this tab. It consists out of a number of radio buttons, check buttons and number entries that allow the user to indicate which assignments should be transferred. ''' # self.frame.expandColumn(0) self.frame.expandGrid(8, 0) self.frame.expandGrid(8, 1) typeOfAssignmentFrame = LabelFrame( self.frame, text='type of assignment') typeOfAssignmentFrame.grid(row=0, column=0, sticky='nesw') # typeOfAssignmentFrame.expandGrid(0,5) peakSelectionFrame = LabelFrame( self.frame, text='which peaks to assign') peakSelectionFrame.grid(row=0, column=1, sticky='nesw', rowspan=2) spinSystemSelectionFrame = LabelFrame(self.frame, text='Which spin-systems to use') spinSystemSelectionFrame.grid(row=2, column=0, sticky='nesw') tipText = 'What to do when a residue has already a spin system assigned to it.' assignedResidueFrame = LabelFrame(self.frame, text='if residue already has spin-system', tipText=tipText) assignedResidueFrame.grid(row=2, column=1, sticky='nesw') spectrumSelectionFrame = LabelFrame(self.frame, text='spectra') spectrumSelectionFrame.grid(row=1, column=0, sticky='nesw') row = 0 Label(typeOfAssignmentFrame, text='Resonances to Peak Dimensions', grid=(row, 0)) self.peaksCheckButton = CheckButton(typeOfAssignmentFrame, selected=True, grid=(row, 1)) row += 1 Label(typeOfAssignmentFrame, text='SpinSystems to Residues', grid=(row, 0)) self.residuesCheckButton = CheckButton( typeOfAssignmentFrame, selected=True, grid=(row, 1)) row = 0 Label(peakSelectionFrame, text='Intra-Residual', grid=(row, 0)) self.intraCheckButton = CheckButton( peakSelectionFrame, selected=True, grid=(row, 1)) row += 1 Label(peakSelectionFrame, text='Sequential', grid=(row, 0)) self.sequentialCheckButton = CheckButton( peakSelectionFrame, selected=True, grid=(row, 1)) row += 1 Label(peakSelectionFrame, text='Do not assign diagonal peaks', grid=(row, 0)) self.noDiagonalCheckButton = CheckButton( peakSelectionFrame, selected=True, grid=(row, 1)) entries = ['Only assigned spin systems', 'All that have a score of at least: ', 'User Defined', 'Solution number:'] tipTexts = ['Only assign resonances of spin systems that already have a sequential assignment for the assignment of peak dimensions. Spin system to residue assignment is not relevant in this case.', 'Assign all spin systems that have a score of at least a given percentage. 50% or lower is not possible, because than spin systems might have to be assigned to more than 1 residue, which is impossible.', "As defined in the lower row of buttons in the 'results' tab.", 'One of the single solutions of the annealing.'] self.spinSystemTypeSelect = RadioButtons(spinSystemSelectionFrame, entries=entries, grid=(0, 0), select_callback=None, direction=VERTICAL, gridSpan=(4, 1), tipTexts=tipTexts) tipText = 'The minimal amount of colabelling the different nuclei should have in order to still give rise to a peak.' self.minScoreEntry = FloatEntry(spinSystemSelectionFrame, grid=(1, 1), width=7, text=str(self.minScore), returnCallback=self.changeMinScore, tipText=tipText) self.minScoreEntry.bind('<Leave>', self.changeMinScore, '+') self.solutionNumberEntry = IntEntry(spinSystemSelectionFrame, grid=(3, 1), width=7, text=1, returnCallback=self.solutionUpdate, tipText=tipText) self.solutionNumberEntry.bind('<Leave>', self.solutionUpdate, '+') #self.solutionPullDown = PulldownList(spinSystemSelectionFrame, None, grid=(3,1), sticky='w') entries = ['all spectra', 'only:'] tipTexts = ['Assign peaks in all the spectra that where selected before the annealing ran.', 'Only assign peaks in one particular spectrum. You can of course repeat this multiple times for different spectra.'] self.spectrumSelect = RadioButtons(spectrumSelectionFrame, entries=entries, grid=(0, 0), select_callback=None, direction=VERTICAL, gridSpan=(2, 1), tipTexts=tipTexts) self.spectraPullDown = PulldownList(spectrumSelectionFrame, self.changeSpectrum, grid=(1, 1), sticky='w') entries = ['skip this residue', 'de-assign old spin system from residue', 'assign, but never merge', 'warn to merge'] tipTexts = ["Don't assign the new spin system to the residue. The residue is not skipped when the old spin system does not contain any resonances", "De-assign old spin system from residue, unless the old spin system is a spin system without any resonances.", "Don't merge any spin systems, merging can be performed later if nescesary in the Resonance --> SpinSystems window.", "Ask to merge individually for each spin system, this might result in clicking on a lot of popups."] self.assignedResidueStrategySelect = RadioButtons(assignedResidueFrame, entries=entries, grid=(0, 0), select_callback=None, direction=VERTICAL, gridSpan=(2, 1), tipTexts=tipTexts) texts = ['Transfer Assignments'] commands = [self.transferAssignments] self.transferButton = ButtonList( self.frame, commands=commands, texts=texts) self.transferButton.grid(row=5, column=0, sticky='nsew', columnspan=2)
def body(self, guiFrame): self.geometry('600x350') guiFrame.expandGrid(0, 0) tipTexts = ['', '', '', ''] options = [ 'Find Parameters', 'Spectrum Widths', 'Diagonal Exclusions', 'Region Peak Find' ] tabbedFrame = TabbedFrame(guiFrame, options=options, grid=(0, 0)) frameA, frameB, frameC, frameD = tabbedFrame.frames self.tabbedFrame = tabbedFrame # Find Params frameA.expandGrid(2, 0) row = 0 label = LabelFrame(frameA, text='Extrema to search for:', grid=(row, 0), gridSpan=(1, 2)) label.expandGrid(0, 1) entries = ['positive and negative', 'positive only', 'negative only'] tipTexts = [ 'Sets whether peak picking within spectra find intensity maxima, minima or both maxima and minima', ] self.extrema_buttons = RadioButtons(label, entries=entries, select_callback=self.apply, direction='horizontal', grid=(0, 0), tipTexts=tipTexts) row += 1 label = LabelFrame(frameA, text='Nearby points to check:', grid=(row, 0), gridSpan=(1, 2)) label.expandGrid(None, 1) entries = ['+-1 in at most one dim', '+-1 allowed in any dim'] tipTexts = [ 'Sets how permissive the peak picking in when searching for intensity extrema; by adding extra points to the selected search region', ] self.adjacent_buttons = RadioButtons(label, entries=entries, select_callback=self.apply, direction='horizontal', grid=(0, 0), tipTexts=tipTexts) row += 1 labelFrame = LabelFrame(frameA, text='Other parameters:', grid=(row, 0), gridSpan=(1, 2)) labelFrame.expandGrid(5, 2) frow = 0 label = Label(labelFrame, text='Scale relative to contour levels:', grid=(frow, 0), sticky='e') tipText = 'Threshold above which peaks are picked, relative to the lowest displayed contour; 1.0 means picking exactly what is visible' self.scale_entry = FloatEntry(labelFrame, grid=(frow, 1), tipText=tipText, returnCallback=self.apply, width=10) self.scale_entry.bind('<Leave>', self.apply, '+') frow += 1 label = Label(labelFrame, text='Exclusion buffer around peaks (in points):', grid=(frow, 0), sticky='e') tipText = 'The size of the no-pick region, in data points, around existing picked peaks; eliminates duplicate picking' self.buffer_entry = IntEntry(labelFrame, returnCallback=self.apply, grid=(frow, 1), width=10, tipText=tipText) self.buffer_entry.bind('<Leave>', self.apply, '+') frow += 1 label = Label(labelFrame, text='Extra thickness in orthogonal dims (in points):', grid=(frow, 0), sticky='e') tipText = 'Sets whether to consider any additional planes (Z dimension) when calculating peak volume integrals' self.thickness_entry = IntEntry(labelFrame, returnCallback=self.apply, width=10, grid=(frow, 1), tipText=tipText) self.thickness_entry.bind('<Leave>', self.apply, '+') frow += 1 label = Label(labelFrame, text='Minimum drop factor (0.0-1.0):', grid=(frow, 0), sticky='e') tipText = '' self.drop_entry = FloatEntry(labelFrame, returnCallback=self.apply, width=10, grid=(frow, 1), tipText=tipText) self.drop_entry.bind('<Leave>', self.apply, '+') frow += 1 label = Label(labelFrame, text='Volume method:', grid=(frow, 0), sticky='e') tipText = 'Selects which method to use to calculate peak volume integrals when peaks are picked; box sizes are specified in "Spectrum Widths"' self.method_menu = PulldownList(labelFrame, texts=PeakBasic.PEAK_VOLUME_METHODS, grid=(frow, 1), callback=self.apply, tipText=tipText) # Spectrum widths frameB.expandGrid(1, 1) label = Label(frameB, text='Spectrum: ') label.grid(row=0, column=0, sticky='e') tipText = 'The spectrum which determines the widths being shown' self.expt_spectrum = PulldownList(frameB, tipText=tipText, callback=self.setSpectrumProperties) self.expt_spectrum.grid(row=0, column=1, sticky='w') self.editLinewidthEntry = FloatEntry(self, text='', returnCallback=self.setLinewidth, width=10) self.editBoxwidthEntry = FloatEntry(self, text='', returnCallback=self.setBoxwidth, width=10) tipTexts = [ 'The number of the spectrum dimension to which the settings apply', 'The nuclear isotope measures in the spectrum dimension', 'The smallest value for the linewidth of a peak for it to be picked', 'The size of the spectrum region to perform the volume integral over' ] headingList = [ 'Dimension', 'Isotope', 'Minimum Linewidth (Hz)', 'Boxwidth' ] editSetCallbacks = [None, None, self.setLinewidth, self.setBoxwidth] editGetCallbacks = [None, None, self.getLinewidth, self.getBoxwidth] editWidgets = [ None, None, self.editLinewidthEntry, self.editBoxwidthEntry ] self.spectrumMatrix = ScrolledMatrix(frameB, initialRows=6, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, headingList=headingList, callback=self.selectCell, tipTexts=tipTexts) self.spectrumMatrix.grid(row=1, column=0, columnspan=2, sticky='nsew') # Diagonal Exclusions frameC.expandGrid(0, 0) tipTexts = [ 'The isotope as measures on the axis of a spectrum window', 'The distance from the homonuclear diagonal line within which no peak picking can occur' ] self.exclusionEntry = FloatEntry(self, text='', returnCallback=self.setExclusion, width=10) headingList = ['Isotope', 'Diagonal Exclusion (ppm)'] editSetCallbacks = [None, self.setExclusion] editGetCallbacks = [None, self.getExclusion] editWidgets = [None, self.exclusionEntry] self.isotopeMatrix = ScrolledMatrix(frameC, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, headingList=headingList, grid=(0, 0), tipTexts=tipTexts) # Region peak find self.regionFindPeakList = None self.regionCondition = None self.regionConditions = [] self.regionCol = 1 row = 0 label = Label(frameD, text='Peak List: ', grid=(0, 0)) tipText = 'Selects which peak list to perform region-wide peak picking for' self.regionPeakListPulldown = PulldownList( frameD, callback=self.changeRegionPeakList, grid=(0, 1), tipText=tipText) row += 1 frameD.expandGrid(row, 1) self.regionEntry = FloatEntry(self, text='', returnCallback=self.setRegion, width=10) self.conditionMenu = PulldownList(self, texts=('include', 'exclude'), callback=self.setCondition) tipTexts = [ 'Whether to include or exclude the states region from region-wide peak picking', ] headingList = ['Condition'] editSetCallbacks = [None] editGetCallbacks = [None] editWidgets = [self.conditionMenu] self.regionFindMatrix = ScrolledMatrix( frameD, headingList=headingList, callback=self.selectRegionCell, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, grid=(row, 0), gridSpan=(1, 2)) row += 1 tipTexts = [ 'Sets the currently selected region row to cover the whole spectrum', 'Add a new region row, which may them be set for exclusion or inclusion when peak picking large areas', 'Remove the selected region specification', 'Go to the panel for setting the parameters that control how peaks extrema are picked', 'Using the stated regions and parameters, perform region-wide peak picking' ] texts = [ 'Whole Region', 'Add Region', 'Delete Region', 'Adjust Params', 'Find Peaks!' ] commands = [ self.wholeRegion, self.addCondition, self.deleteCondition, self.adjustParams, self.regionFindPeaks ] buttons = ButtonList(frameD, texts=texts, commands=commands, grid=(row, 0), gridSpan=(1, 2), tipTexts=tipTexts) buttons.buttons[4].config(bg='#B0FFB0') utilButtons = UtilityButtonList(tabbedFrame.sideFrame, grid=(0, 0), helpUrl=self.help_url, sticky='e') self.dataDim = None self.setParamsEntries() self.updateSpectrum() self.setIsotopeProperties() self.updateRegionPeakLists() self.administerNotifiers(self.registerNotify)
def body(self, guiFrame): self.geometry('700x500') guiFrame.expandGrid(1, 0) row = 0 # TOP LEFT FRAME frame = LabelFrame(guiFrame, text='Options') frame.grid(row=row, column=0, sticky='nsew') frame.columnconfigure(7, weight=1) label = Label(frame, text='Chain') label.grid(row=0, column=0, sticky='w') self.chainPulldown = PulldownList( frame, callback=self.changeChain, tipText='Choose the molecular system chain to make predictions for' ) self.chainPulldown.grid(row=0, column=1, sticky='w') label = Label(frame, text='Shift List') label.grid(row=0, column=2, sticky='w') self.shiftListPulldown = PulldownList( frame, callback=self.changeShiftList, tipText='Select the shift list to take input chemical shifts from') self.shiftListPulldown.grid(row=0, column=3, sticky='w') label = Label(frame, text='Type') label.grid(row=0, column=4, sticky='w') self.scriptPulldown = PulldownList( frame, texts=SCRIPT_TEXTS, callback=self.changeScript, tipText='Select the algorithm script for this chain') self.scriptPulldown.grid(row=0, column=5, sticky='w') self.pHLabel = Label(frame, text='pH') self.pHLabel.grid(row=0, column=6, sticky='w') self.pHPulldown = PulldownList( frame, texts=SCRIPT_PHS, tipText='Select the pH to make the prediction for') self.pHPulldown.grid(row=0, column=7, sticky='w') row += 1 # BOTTOM LEFT FRAME frame = LabelFrame(guiFrame, text='Chemical Shift Predictions') frame.grid(row=row, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) tipTexts = [ 'Residue number in chain', 'Residue type code', 'Atom name', 'Actual shift (first one it finds for atom in chosen shiftList)', 'CamCoil predicted shift', 'Predicted - Actual' ] headingList = [ 'Res\nNum', 'Res\nType', 'Atom\nName', 'Actual\nShift', 'Predicted\nShift', 'Difference' ] n = len(headingList) editWidgets = n * [None] editGetCallbacks = n * [None] editSetCallbacks = n * [None] self.predictionMatrix = ScrolledMatrix( frame, headingList=headingList, tipTexts=tipTexts, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks) self.predictionMatrix.grid(row=0, column=0, sticky='nsew') row += 1 tipTexts = [ 'Run the CamCoil method to predict chemical shifts from sequence' ] texts = ['Run CamCoil Prediction!'] commands = [self.runCamCoil] self.buttonList = createDismissHelpButtonList(guiFrame, texts=texts, commands=commands, help_url=self.help_url, expands=True, tipTexts=tipTexts) self.buttonList.grid(row=row, column=0) self.update() self.notify(self.registerNotify)
def body(self, guiFrame): guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(1, weight=1) frame = LabelFrame(guiFrame, text='Options') frame.grid(row=0, column=0, sticky='ew') frame.grid_columnconfigure(5, weight=1) label = Label(frame, text='MolSystem:') label.grid(row=0, column=0, sticky='w') self.molSystemPulldown = PulldownMenu(frame, callback=self.selectMolSystem) self.molSystemPulldown.grid(row=0, column=1, sticky='w') self.molLabel = Label(frame, text='Molecule:') self.molLabel.grid(row=0, column=2, sticky='w') self.moleculePulldown = PulldownMenu(frame, callback=self.selectMolecule) self.moleculePulldown.grid(row=0, column=3, sticky='w') label = Label(frame, text='Same Molecule Symmetry:') label.grid(row=0, column=4, sticky='w') self.molSelect = CheckButton(frame, callback=self.toggleSingleMolecule) self.molSelect.grid(row=0, column=5, sticky='w') self.molSelect.set(self.singleMolecule) frame = LabelFrame(guiFrame, text='Symmetry Operations') frame.grid(row=1, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) self.symmCodePulldown = PulldownMenu(self, callback=self.setSymmCode, do_initial_callback=False) self.segLengthEntry = IntEntry(self, returnCallback=self.setSegLength, width=6) self.setChainMulti = MultiWidget(self, CheckButton, callback=self.setChains, minRows=0, useImages=False) self.setSegmentMulti = MultiWidget(self, IntEntry, callback=self.setSegments, minRows=0, useImages=False) editWidgets = [ None, self.symmCodePulldown, self.segLengthEntry, self.setChainMulti, self.setSegmentMulti ] editGetCallbacks = [ None, self.getSymmCode, self.getSegLength, self.getChains, self.getSegments ] editSetCallbacks = [ None, self.setSymmCode, self.setSegLength, self.setChains, self.setSegments ] headings = [ '#', 'Symmetry\nType', 'Segment\nLength', 'Chains', 'Segment\nPositions' ] self.symmetryMatrix = ScrolledMatrix(frame, headingList=headings, callback=self.selectSymmetry, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks) self.symmetryMatrix.grid(row=0, column=0, sticky='nsew') texts = ['Add Symmetry Op', 'Remove Symmetrey Op'] commands = [self.addSymmOp, self.removeSymmOp] buttonList = createDismissHelpButtonList(guiFrame, texts=texts, commands=commands, expands=True) buttonList.grid(row=2, column=0, sticky='ew') self.updateMolSystems() self.updateMolecules() self.updateSymmetriesAfter() self.notify(self.registerNotify)
def body(self, guiFrame): '''This method describes the outline of the body of the application. args: guiFrame: frame the body should live in. ''' self.geometry('800x530') guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(0, weight=0) guiFrame.grid_rowconfigure(1, weight=2) guiFrame.grid_rowconfigure(2, weight=1) isotopeFrame = LabelFrame(guiFrame, text='Isotope Shift Correction CA and CB') isotopeFrame.grid(row=0, column=0, sticky='nsew') frameA = LabelFrame(guiFrame, text='Spin Systems') frameA.grid(row=1, column=0, sticky='nsew') frameA.grid_rowconfigure(0, weight=1) frameA.grid_columnconfigure(0, weight=1) frameA.grid_columnconfigure(1, weight=1) frameA1 = LabelFrame(frameA, text='Spin System 1') frameA1.grid(row=0, column=0, sticky='nsew') frameA1.grid_columnconfigure(0, weight=1) frameA1.grid_rowconfigure(0, weight=1) frameA2 = LabelFrame(frameA, text='Spin System 2') frameA2.grid(row=0, column=1, sticky='nsew') frameA2.grid_columnconfigure(0, weight=1) frameA2.grid_rowconfigure(0, weight=1) frameB = LabelFrame(guiFrame, text='Comparison') frameB.grid(row=2, column=0, sticky='nsew') frameB.grid_rowconfigure(0, weight=1) frameB.grid_columnconfigure(0, weight=1) frameB.grid_columnconfigure(1, weight=2) frameB.grid_columnconfigure(2, weight=1) frameB1 = LabelFrame(frameB, text='Unique to Spin System 1') frameB1.grid(row=0, column=0, sticky='nsew') frameB1.expandGrid(0, 0) frameB2 = LabelFrame(frameB, text='Intersection') frameB2.grid(row=0, column=1, sticky='nsew') frameB2.expandGrid(0, 0) frameB3 = LabelFrame(frameB, text='Unique to Spin System 2') frameB3.grid(row=0, column=2, sticky='nsew') frameB3.expandGrid(0, 0) # Settings for isotope shift correction shiftLists = getShiftLists(self.nmrProject) self.protonatedShiftList = shiftLists[0] self.deuteratedShiftList = shiftLists[1] shiftListNames = [ '{}: {}'.format(shiftList.serial, shiftList.name) for shiftList in shiftLists ] Label(isotopeFrame, text='Correct for isotope shift:', grid=(0, 0)) self.correctCheck = CheckButton(isotopeFrame, selected=True, callback=self.setCorrection, grid=(0, 1)) Label(isotopeFrame, text='Protonated shift list:', grid=(1, 0)) self.protonatedPulldown = PulldownList( isotopeFrame, callback=self.setProtonatedShiftList, texts=shiftListNames, objects=shiftLists, grid=(1, 1), index=0) Label(isotopeFrame, text='Deuterated shift list:', grid=(2, 0)) self.deuteratedPulldown = PulldownList( isotopeFrame, callback=self.setDeuteratedShiftList, texts=shiftListNames, objects=shiftLists, grid=(2, 1), index=1) # Table A1 headingList = ['#', 'shift lists', 'Assignment'] tipTexts = [ 'Spin System Serial', 'shift lists', 'The residue (tentatively) assigned to this spin system', 'The amount of spin systems that overlap with this spin system and have no violations' ] editGetCallbacks = [self.setSpinSystem1] * 3 editSetCallbacks = [None] * 3 self.tableA1 = ScrolledMatrix(frameA1, headingList=headingList, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA1.grid(row=0, column=0, sticky='nsew') # Table A2 headingList = ['#', 'shift lists', 'Assignment', 'offset'] tipTexts = [ 'Spin System Serial', 'The residue (tentatively) assigned to this spin system', 'Root mean squared deviation of this spin system to the spin system selected in the table on the left.' ] editGetCallbacks = [self.setSpinSystem2] * 4 editSetCallbacks = [None] * 4 self.tableA2 = ScrolledMatrix( frameA2, headingList=headingList, #editWidgets=editWidgets, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA2.grid(row=0, column=0, sticky='nsew') # Table B1 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift'] self.tableB1 = ScrolledMatrix(frameB1, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB1.grid(row=0, column=0, sticky='nsew') # Table B 2 headingList = ['atom', 'c.s. 1', 'c.s. 2', 'delta c.s.'] tipTexts = [ 'name of the atom', 'chemical shift of atom with this name in spin system 1', 'chemical shift of atom with this name in spin system 2', 'difference between the chemical shift of spin systems 1 and 2' ] self.tableB2 = ScrolledMatrix(frameB2, headingList=headingList, tipTexts=tipTexts) self.tableB2.grid(row=0, column=0, sticky='nsew') # Table B 3 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift.'] self.tableB3 = ScrolledMatrix(frameB3, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB3.grid(row=0, column=0, sticky='nsew') self.matchMatrix = {} self.amountOfMatchesPerSpinSystem = {} self.updateTableA1()
def body(self, guiFrame): self.fileSelect = None names, objects = self.getShiftLists() self.shiftListPulldown = PulldownList(self, callback=self.setShiftList, texts=names, objects=objects) self.windowPulldown = PulldownList(self, texts=WINDOW_OPTS, callback=self.setWindow) self.experimentEntry = Entry(self, width=16, returnCallback=self.setExperiment) self.spectrumEntry = Entry(self, width=16, returnCallback=self.setSpectrum) guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(0, weight=1) guiFrame.grid_rowconfigure(1, weight=1) leftFrame = LabelFrame(guiFrame, text='File Selection') leftFrame.grid(row=0, column=0, sticky='nsew') leftFrame.grid_columnconfigure(3, weight=1) row = 0 label = Label(leftFrame, text='File format:') label.grid(row=row, column=0, sticky='w') tipText = 'Selects which kind of spectrum file is being loaded; what its data matrix format is' self.formatPulldown = PulldownList(leftFrame, callback=self.chooseFormat, texts=file_formats, tipText=tipText, grid=(row, 1)) self.detailsLabel = Label(leftFrame, text='Show details:') tipText = 'Whether to show an annotation that describes the spectrum in the file selection; currently only uses comment fields from Bruker spectra' self.detailsSelect = CheckButton(leftFrame, selected=False, callback=self.showDetails, tipText=tipText) self.titleRow = row self.detailsSelected = False row = row + 1 leftFrame.grid_rowconfigure(row, weight=1) file_types = [FileType('All', ['*'])] self.fileSelect = FileSelect(leftFrame, multiSelect=True, file_types=file_types, single_callback=self.chooseFiles, extraHeadings=('Details', ), extraJustifies=('left', ), displayExtra=False, getExtraCell=self.getDetails, manualFileFilter=True) self.fileSelect.grid(row=row, column=0, columnspan=6, sticky='nsew') rightFrame = LabelFrame(guiFrame, text='Spectra To Open') rightFrame.grid(row=1, column=0, sticky='nsew') rightFrame.grid_columnconfigure(3, weight=1) row = 0 label = Label(rightFrame, text='Skip verification dialogs:', grid=(row, 0)) tipText = 'Whether to allow the user to check file interpretation and referencing information before the spectrum is loaded' self.verifySelect = CheckButton(rightFrame, selected=False, grid=(row, 1), tipText=tipText) label = Label(rightFrame, text='Use shared experiment:', grid=(row, 2)) tipText = 'When selecting multiple spectrum files, whether the loaded spectra will all belong to (derive from) the same experiment; useful for projection spectra etc.' self.sharedExpSelect = CheckButton(rightFrame, selected=False, tipText=tipText, callback=self.useShared, grid=(row, 3)) row = row + 1 rightFrame.grid_rowconfigure(row, weight=1) tipTexts = [ 'A short textual name for the experiment record that the loaded spectrum will belong to; may be a new experiment or the name of an existing one', 'A short textual name to identify the spectrum within its experiment; typically a few characters or spectrum number, rather than a repeat of the experiment name', 'The location of the file, relative to the current directory, that the spectrum data will be loaded from', 'Sets which window or windows the spectrum will initially appear within once loaded', 'Sets which shift list the experiment (and hence loaded spectrum) will use to curate chemical shift information; can be changed after load time' ] headingList = [ 'Experiment', 'Spectrum', 'File', 'Windows', 'Shift List' ] editWidgets = [ self.experimentEntry, self.spectrumEntry, None, self.windowPulldown, self.shiftListPulldown ] editGetCallbacks = [ self.getExperiment, self.getSpectrum, None, self.getWindow, self.getShiftList ] editSetCallbacks = [ self.setExperiment, self.setSpectrum, None, self.setWindow, self.setShiftList ] self.scrolledMatrix = ScrolledMatrix(rightFrame, headingList=headingList, callback=self.selectCell, editWidgets=editWidgets, multiSelect=True, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts, grid=(row, 0), gridSpan=(1, 4)) row = row + 1 tipTexts = [ 'Load spectrum or spectra into the CCPN project using the selected file(s)', ] texts = ['Open Spectrum'] commands = [self.openSpectra] bottomButtons = UtilityButtonList(guiFrame, texts=texts, tipTexts=tipTexts, doClone=False, commands=commands, helpUrl=self.help_url) bottomButtons.grid(row=row, column=0, columnspan=1, sticky='ew') self.openButton = bottomButtons.buttons[0] self.chooseFormat('Azara') self.message()
def body(self, guiFrame): guiFrame.grid_columnconfigure(0, weight=1) row = 0 frame = LabelFrame(guiFrame, text='Options') frame.grid(row=row, column=0, sticky='ew') frame.grid_columnconfigure(1, weight=1) frame.grid_rowconfigure(1, weight=1) label = Label(frame, text='Window:') label.grid(row=0, column=0, sticky='nw') self.windowPulldown = PulldownList(frame, callback=self.changeWindow) self.windowPulldown.grid(row=0, column=1, sticky='nw') label = Label(frame, text='Multiplet Pattern:') label.grid(row=1, column=0, columnspan=2, sticky='nw') self.multipletButtons = PartitionedSelector(frame, callback=self.setMultiplet, radio=True) self.multipletButtons.grid(row=2, column=0, columnspan=2, sticky='ew') row += 1 frame = LabelFrame(guiFrame, text='Active Peak Lists') frame.grid(row=row, column=0, sticky='ew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) headingList = [ 'Experiment', 'Spectrum', 'List', 'Coupled Dims', 'Experiment Type' ] self.peakListMatrix = ScrolledMatrix(frame, headingList=headingList, callback=None, multiSelect=False) self.peakListMatrix.grid(row=0, column=0, sticky='nsew') row += 1 guiFrame.grid_rowconfigure(row, weight=1) frame = LabelFrame(guiFrame, text='Multiplet Peak Clusters') frame.grid(row=row, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) headingList = [ '#', 'Main\nAssignment', 'Num\nPeaks', 'Coupling\nAssignment', 'Value', 'Value' ] self.clusterMatrix = ScrolledMatrix(frame, headingList=headingList, callback=self.selectCluster, multiSelect=True) self.clusterMatrix.grid(row=0, column=0, sticky='nsew') row += 1 texts = [ 'Cluster Selected\nPeaks', 'Assign\nCouplings', 'List\nPeaks', 'Find\nPeaks', 'Delete\nClusters' ] commands = [ self.clusterSelectedPeaks, self.assignCouplings, self.showPeaks, self.findPeaks, self.deleteClusters ] self.bottomButtons = UtilityButtonList(guiFrame, texts=texts, expands=True, commands=commands, helpUrl=self.help_url) self.bottomButtons.grid(row=row, column=0, sticky='ew') self.administerNotifiers(self.registerNotify)
class EditContourLevelsPopup(BasePopup): """ **Change Levels in Spectrum Contour Displays** This popup window is used to specify which contour levels (lines of constant intensity) are drawn for spectra within the spectrum windows of Analysis. A spectrum can have both positive and negative levels, and the user can set these on an individual basis or as a regular incremental (usually geometric) series. It should be noted that spectrum contour colours, which may be different for positive and negative levels, is set elsewhere, in the main Spectra_ table. In normal operation the user first selects the spectrum to change the contours for in the upper left pulldown menu. Although contour levels are specified for individual spectra, if there are several spectra that share the same levels (for example if they form a series of some kind) then the user may spread the contour level information from one to many via the [Propagate Contours] function within the "Display Options" of the main Spectra_ table. The user may also affect the contour levels of multiple spectra by changing the "Global scale" settings. This global scale will affect *all spectra* in the project; the scale value multiplies all of the contour levels for all spectra, although in practice it is rarely changed. Using a global scale gives the advantage of being able to specify smaller numbers for the levels. The individual contour levels for a spectrum are listed in the "positive levels" and "Negative levels" fields. They are multiplied by the global scale factor when they are used for spectrum display. The user may type in values for the levels directly into these field, or they can be filled using the "Auto contour levels" mechanism. If manual levels are specified the user should press [Apply manual Levels] when done to commit the changes and see the results. The [Apply Auto Levels] function differs in that it always applies a regular series of levels, according to the settings, and these will overwrite any manual specifications when committed; the actual levels applied are always displayed in the levels field. The setting of "Auto" levels using a series involves choosing a base level, which represents the first contour (closest to zero). This base level is usually set according to the level of noise in the spectrum. Typically it is a value just above most of the noise, so the noise is not seen, but it may be set lower in some instances to show weak signals. The base level applies to both positive and negative contour series, although for the negative side it is naturally used with negative sign. The user sets how many levels there should be in total; the subsequent levels start from the base level and move away from zero. Normally this involves a geometric series, with a constant multiplication factor applied to a value to generate the next in the series. This factor is set in the "Level multiplier", although some of the commonly used values are quickly set via the adjacent buttons. Under a few special circumstances it is helpful to have a constant difference between levels, in which case "Add levels" may be used instead of "Multiply levels". **Caveats & Tips** Often it is useful to initially setup contours using an "Auto" series, but then manually remove some of the levels. For example having all the positive levels but only the first negative level may be helpful to show where peaks are truncated. Note this system sets the levels that would be used to make any contour files (an optional way of working, especially for 4D spectra etc.). However, once contour files are made then this system will not affect the levels within the files. .. _Spectra: EditSpectrumPopup.html """ def __init__(self, parent, *args, **kw): BasePopup.__init__(self, parent=parent, title='Spectrum Contour Levels', **kw) def body(self, guiFrame): self.doUpdateForm = True self.spectrum = None guiFrame.grid_columnconfigure(1, weight=1) row = 0 specFrame = LabelFrame(guiFrame, text='Spectrum', grid=(row, 0)) tipText = 'The spectrum for which you are setting the contour levels' self.expt_spectrum = PulldownList(specFrame, grid=(0, 0), tipText=tipText, callback=self.setSpectrumDetails) tipText = 'Open the edit spectrum table to view and change other properties associated with the selected spectrum' button = Button(specFrame, text='Spectrum Properties', command=self.editProperties, borderwidth=1, grid=(1, 0), sticky='ew', tipText=tipText) globalFrame = LabelFrame(guiFrame, text='Global scale') globalFrame.grid(row=row, column=1, sticky='nsew') globalFrame.grid_columnconfigure(0, weight=1) tipText = 'The value by which all contour levels in all spectra are multiplied; to give the actual contour level in terms of the stored spectrum data' self.global_entry = FloatEntry( globalFrame, width=10, tipText=tipText, text=self.analysisProject.globalContourScale, returnCallback=self.applyAuto, grid=(0, 0), gridSpan=(1, 2), sticky='ew') tipText = 'Divide the global scaling factor by two; moving all contour for all spectra levels closer to zero' button = Button(globalFrame, borderwidth=1, text='/2', sticky='ew', tipText=tipText, command=lambda: self.changeGlobalScale(0.5), grid=(0, 2)) tipText = 'Multiple the global scaling factor by two; moving all contour for all spectra levels away from zero' button = Button(globalFrame, borderwidth=1, text='*2', sticky='ew', tipText=tipText, command=lambda: self.changeGlobalScale(2.0), grid=(0, 3)) tipText = 'Set the global contour scale for all spectra to the default of 100,000' button = Button(globalFrame, borderwidth=1, text='10^5', tipText=tipText, command=self.defaultGlobalScale, grid=(1, 0)) tipText = 'Click to decrease "-" or increase "+" the global contour scale by small amounts' frame = ValueRamp(globalFrame, callback=self.changeGlobalScale, tipText=tipText) frame.grid(row=1, column=1, columnspan=3, sticky='e') row += 1 self.autoFrame = LabelFrame(guiFrame, text='Auto contour levels') self.autoFrame.grid(row=row, column=0, columnspan=5, sticky='nsew') self.autoFrame.grid_columnconfigure(1, weight=1) frow = 0 label = Label(self.autoFrame, text='Base level:', grid=(frow, 0), sticky='e') tipText = 'The first contour level (closest to zero) for an automated series of levels: the start of a geometric or arithmetic series defining levels' self.base_entry = FloatEntry(self.autoFrame, returnCallback=self.applyAuto, width=10, grid=(frow, 1), sticky='ew', tipText=tipText) command = lambda: self.changeBaseLevel(0.5) tipText = 'Lower the base contour level so that it is half of the previous value; moving the series of contour levels closer to zero' button = Button(self.autoFrame, borderwidth=1, text='/2', tipText=tipText, command=command, grid=(frow, 2), sticky='ew') command = lambda: self.changeBaseLevel(2.0) tipText = 'Raise the base contour level so that it is double the previous value; moving the series of contour levels further from zero' button = Button(self.autoFrame, borderwidth=1, text='*2', tipText=tipText, command=command, grid=(frow, 3), sticky='ew') tipText = 'Click to decrease "-" or increase "+" the base contour level by small amounts' frame = ValueRamp(self.autoFrame, callback=self.changeBaseLevel, tipText=tipText) frame.grid(row=frow, column=4, columnspan=3, sticky='ew') frow += 1 label = Label(self.autoFrame, text='Number of levels:', grid=(frow, 0), sticky='e') #self.numberEntry = IntEntry(guiFrame, text=numberLevels, # returnCallback=self.applyAuto) tipText = 'The number of contour levels to make in the automated series' self.numberEntry = IntEntry(self.autoFrame, returnCallback=self.applyAuto, width=10, grid=(frow, 1), sticky='ew', tipText=tipText) command = lambda w=-1: self.changeNumberLevels(w) tipText = 'Decrease the number of contour levels in the series by one' button = Button(self.autoFrame, borderwidth=1, text='-1', tipText=tipText, command=command, grid=(frow, 2), sticky='ew') command = lambda w=1: self.changeNumberLevels(w) tipText = 'Increase the number of contour levels in the series by one' button = Button(self.autoFrame, borderwidth=1, text='+1', tipText=tipText, command=command, grid=(frow, 3), sticky='ew') n = 4 for w in (5, 10, 15, 20): tipText = 'Set the number of contour levels in the series to %d' % w command = lambda w=w: self.setNumberLevels(w) button = Button(self.autoFrame, borderwidth=1, text='%d' % w, command=command, grid=(frow, n), sticky='ew', tipText=tipText) n += 1 frow += 1 self.change_label = Label(self.autoFrame, text='%s:' % multiplier_text, grid=(frow, 0), sticky='e') tipText = 'The multiplication factor (or increment if adding levels) to repetitively apply to the base level to generate the series of levels' self.change_entry = FloatEntry(self.autoFrame, returnCallback=self.applyAuto, width=10, grid=(frow, 1), sticky='ew', tipText=tipText) self.change_level_buttons = [] n = 2 for w in multiplier_changes: tipText = 'Set the automated series multiplication factor or increment to %f' % w command = lambda w=w: self.setChange(w) button = Button(self.autoFrame, borderwidth=1, text=str(w), command=command, grid=(frow, n), sticky='ew', tipText=tipText) self.change_level_buttons.append(button) n += 1 frow += 1 frame = Frame(self.autoFrame, grid=(frow, 0), gridSpan=(1, 7), sticky='ew') tipTexts = [ 'Toggles whether positive contour levels from the automated series will be used. Overrides any manual settings', 'Toggles whether negative contour levels from the automated series will be used. Overrides any manual settings' ] entries = ('Positive', 'Negative') selected = (True, False) self.which_buttons = CheckButtons(frame, entries, selected=selected, select_callback=self.applyAuto, grid=(0, 0), sticky='w', tipTexts=tipTexts) tipTexts = [ 'Set the contour level generation to use a geometric series, starting from the base level and using the specified factor', 'Set the contour level generation to use an arithmetic series, starting from the base level and using the specified increment' ] entries = ('Multiply levels', 'Add levels') self.change_mode_buttons = RadioButtons( frame, entries, grid=(0, 1), sticky='ew', select_callback=self.modeChanged, tipTexts=tipTexts) row += 1 manualFrame = LabelFrame(guiFrame, text='Positive levels', grid=(row, 0), gridSpan=(1, 2)) manualFrame.expandGrid(None, 0) tipText = 'The positive contour levels that will be used for the spectrum; filled in by the automation or set/modified manually' self.posLevelsEntry = FloatEntry(manualFrame, isArray=True, width=60, returnCallback=self.applyManual, tipText=tipText, grid=(0, 0), sticky='ew') row += 1 manualFrame = LabelFrame(guiFrame, text='Negative levels', grid=(row, 0), gridSpan=(1, 2)) manualFrame.expandGrid(None, 0) tipText = 'The negative contour levels that will be used for the spectrum; filled in by the automation or set/modified manually' self.negLevelsEntry = FloatEntry(manualFrame, isArray=True, width=60, returnCallback=self.applyManual, tipText=tipText, grid=(0, 0), sticky='ew') row += 1 tipTexts = [ 'Set the spectrum contour levels, updating the display, to the automated series, ignoring any manual edits.', 'Set the spectrum contour levels, updating the display, to the values displayed in the level entry fields' ] texts = ['Apply Auto Levels', 'Apply Manual Edits'] commands = [self.applyAuto, self.applyManual] self.buttons = UtilityButtonList(guiFrame, texts=texts, commands=commands, helpUrl=self.help_url, grid=(row, 0), gridSpan=(1, 2), tipTexts=tipTexts) guiFrame.grid_rowconfigure(row, weight=1) self.curateNotifiers(self.registerNotify) self.update() def update(self, spectrum=None): if not spectrum: spectrum = self.spectrum spectra = self.parent.getSpectra() if spectra: if spectrum not in spectra: spectrum = spectra[0] index = spectra.index(spectrum) names = ['%s:%s' % (x.experiment.name, x.name) for x in spectra] else: index = 0 names = [] self.expt_spectrum.setup(names, spectra, index) self.setSpectrumDetails(spectrum) def updateNotifier(self, *extra): self.update() def open(self): self.updateForm() BasePopup.open(self) def modeChanged(self, *entry): spectrum = self.spectrum if not spectrum or spectrum.isDeleted: return analysisSpectrum = spectrum.analysisSpectrum changeMode = self.change_mode_buttons.getIndex( ) and 'add' or 'multiply' if changeMode == 'add': text = adder_text changes = adder_changes else: text = multiplier_text changes = multiplier_changes self.change_label.set('%s:' % text) n = 0 for button in self.change_level_buttons: w = changes[n] command = lambda w=w: self.setChange(w) button.config(command=command) button.setText(str(w)) n = n + 1 levelChanger = changes[2] self.doUpdateForm = False analysisSpectrum.autoLevelChanger = levelChanger analysisSpectrum.autoLevelMode = changeMode self.doUpdateForm = True self.setContourLevels() def defaultGlobalScale(self): self.global_entry.set(100000) self.applyAuto() def close(self): self.applyManual() BasePopup.close(self) def destroy(self): self.curateNotifiers(self.unregisterNotify) BasePopup.destroy(self) def curateNotifiers(self, notifyFunc): notifyFunc(self.updateContourLevels, 'ccpnmr.Analysis.AnalysisSpectrum', 'setPosLevels') notifyFunc(self.updateContourLevels, 'ccpnmr.Analysis.AnalysisSpectrum', 'setNegLevels') notifyFunc(self.updateForm, 'ccpnmr.Analysis.AnalysisSpectrum', 'setAutoLevelChanger') notifyFunc(self.updateForm, 'ccpnmr.Analysis.AnalysisSpectrum', 'setAutoLevelMode') notifyFunc(self.updateForm, 'ccpnmr.Analysis.AnalysisSpectrum', 'setAutoNumLevels') notifyFunc(self.updateForm, 'ccpnmr.Analysis.AnalysisSpectrum', 'setAutoBaseLevel') notifyFunc(self.updateForm, 'ccpnmr.Analysis.AnalysisProject', 'setGlobalContourScale') for clazz in ('Experiment', 'DataSource'): for func in ('__init__', 'delete', 'setName'): notifyFunc(self.updateNotifier, 'ccp.nmr.Nmr.%s' % clazz, func) def editProperties(self): self.parent.editSpectrum(self.spectrum) def updateForm(self, *extra): #print 'updateForm' if (not self.doUpdateForm): return self.global_entry.set(self.analysisProject.globalContourScale) spectrum = self.spectrum if spectrum and not spectrum.isDeleted: analysisSpectrum = spectrum.analysisSpectrum self.base_entry.set(analysisSpectrum.autoBaseLevel) self.numberEntry.set(analysisSpectrum.autoNumLevels) self.change_entry.set(analysisSpectrum.autoLevelChanger) if analysisSpectrum.autoLevelMode == 'add': i = 1 else: i = 0 self.change_mode_buttons.setIndex(i) def updateContourLevels(self, analysisSpectrum): spectrum = self.spectrum if spectrum and not spectrum.isDeleted: analysisSpectrum = spectrum.analysisSpectrum posLevels = list(analysisSpectrum.posLevels) negLevels = list(analysisSpectrum.negLevels) self.posLevelsEntry.set(posLevels) self.negLevelsEntry.set(negLevels) self.doUpdateForm = False updateSpectrumLevelParams(analysisSpectrum, posLevels, negLevels) self.doUpdateForm = True self.base_entry.set(analysisSpectrum.autoBaseLevel) self.numberEntry.set(analysisSpectrum.autoNumLevels) self.change_entry.set(analysisSpectrum.autoLevelChanger) self.setWhichLevels(spectrum) if analysisSpectrum.autoLevelMode == 'add': i = 1 else: i = 0 self.change_mode_buttons.setIndex(i) def setWhichLevels(self, spectrum): analysisSpectrum = spectrum.analysisSpectrum posLevels = analysisSpectrum.posLevels negLevels = analysisSpectrum.negLevels if posLevels: isSelected = True else: isSelected = False self.which_buttons.setIndexSelection(0, isSelected) if negLevels: isSelected = True else: isSelected = False self.which_buttons.setIndexSelection(1, isSelected) def setSpectrum(self, spectrum): if spectrum is not self.spectrum: self.update(spectrum) #if (spectrum and not spectrum.isDeleted): # self.setWhichLevels(spectrum) speed_scale = 6.0 speed_delay = 50 # msec def changeGlobalScale(self, multiplier): self.analysisProject.globalContourScale = multiplier * self.analysisProject.globalContourScale def changeBaseLevel(self, multiplier): spectrum = self.spectrum if (not spectrum or spectrum.isDeleted is True): return analysisSpectrum = spectrum.analysisSpectrum baseLevel = multiplier * analysisSpectrum.autoBaseLevel self.base_entry.set(baseLevel) self.doUpdateForm = False analysisSpectrum.autoBaseLevel = abs(baseLevel) self.doUpdateForm = True self.setContourLevels() def changeNumberLevels(self, change): spectrum = self.spectrum if not spectrum or spectrum.isDeleted is True: return analysisSpectrum = spectrum.analysisSpectrum numberLevels = analysisSpectrum.autoNumLevels + change self.numberEntry.set(numberLevels) self.doUpdateForm = False analysisSpectrum.autoNumLevels = numberLevels self.doUpdateForm = True self.setContourLevels() def setChange(self, levelChanger): spectrum = self.spectrum if not spectrum or spectrum.isDeleted: return self.doUpdateForm = False analysisSpectrum = spectrum.analysisSpectrum analysisSpectrum.autoLevelChanger = levelChanger self.doUpdateForm = True self.setContourLevels() def setNumberLevels(self, numberLevels): spectrum = self.spectrum if (not spectrum or spectrum.isDeleted is True): return self.doUpdateForm = False analysisSpectrum = spectrum.analysisSpectrum analysisSpectrum.autoNumLevels = numberLevels self.doUpdateForm = True self.setContourLevels() def setSpectrumDetails(self, spectrum): if spectrum is self.spectrum: return self.spectrum = spectrum if spectrum and not spectrum.isDeleted: analysisSpectrum = spectrum.analysisSpectrum posLevels = list(analysisSpectrum.posLevels) negLevels = list(analysisSpectrum.negLevels) self.posLevelsEntry.set(posLevels) self.negLevelsEntry.set(negLevels) self.doUpdateForm = False updateSpectrumLevelParams(analysisSpectrum, posLevels, negLevels) self.doUpdateForm = True self.base_entry.set(analysisSpectrum.autoBaseLevel) self.numberEntry.set(analysisSpectrum.autoNumLevels) self.change_entry.set(analysisSpectrum.autoLevelChanger) self.autoFrame.setText('Auto contour levels - %s:%s' % (spectrum.experiment.name, spectrum.name)) self.setWhichLevels(spectrum) else: self.posLevelsEntry.set('') self.negLevelsEntry.set('') self.autoFrame.setText('Auto contour levels') def setContourLevels(self): spectrum = self.spectrum if not spectrum or spectrum.isDeleted is True: return try: analysisSpectrum = spectrum.analysisSpectrum baseLevel = analysisSpectrum.autoBaseLevel numberLevels = analysisSpectrum.autoNumLevels levelChanger = analysisSpectrum.autoLevelChanger changeMode = analysisSpectrum.autoLevelMode posLevels = [] if self.which_buttons.isIndexSelected(0): posLevels.extend( calcContourLevels(baseLevel, numberLevels, levelChanger, changeMode)) negLevels = [] if self.which_buttons.isIndexSelected(1): if changeMode == 'add': levelChanger = -levelChanger negLevels.extend( calcContourLevels(-baseLevel, numberLevels, levelChanger, changeMode)) self.posLevelsEntry.set(posLevels) self.negLevelsEntry.set(negLevels) analysisSpectrum.posLevels = posLevels analysisSpectrum.negLevels = negLevels except Implementation.ApiError, e: showError('Contour levels error', e.error_msg, parent=self)
def body(self, guiFrame): self.doUpdateForm = True self.spectrum = None guiFrame.grid_columnconfigure(1, weight=1) row = 0 specFrame = LabelFrame(guiFrame, text='Spectrum', grid=(row, 0)) tipText = 'The spectrum for which you are setting the contour levels' self.expt_spectrum = PulldownList(specFrame, grid=(0, 0), tipText=tipText, callback=self.setSpectrumDetails) tipText = 'Open the edit spectrum table to view and change other properties associated with the selected spectrum' button = Button(specFrame, text='Spectrum Properties', command=self.editProperties, borderwidth=1, grid=(1, 0), sticky='ew', tipText=tipText) globalFrame = LabelFrame(guiFrame, text='Global scale') globalFrame.grid(row=row, column=1, sticky='nsew') globalFrame.grid_columnconfigure(0, weight=1) tipText = 'The value by which all contour levels in all spectra are multiplied; to give the actual contour level in terms of the stored spectrum data' self.global_entry = FloatEntry( globalFrame, width=10, tipText=tipText, text=self.analysisProject.globalContourScale, returnCallback=self.applyAuto, grid=(0, 0), gridSpan=(1, 2), sticky='ew') tipText = 'Divide the global scaling factor by two; moving all contour for all spectra levels closer to zero' button = Button(globalFrame, borderwidth=1, text='/2', sticky='ew', tipText=tipText, command=lambda: self.changeGlobalScale(0.5), grid=(0, 2)) tipText = 'Multiple the global scaling factor by two; moving all contour for all spectra levels away from zero' button = Button(globalFrame, borderwidth=1, text='*2', sticky='ew', tipText=tipText, command=lambda: self.changeGlobalScale(2.0), grid=(0, 3)) tipText = 'Set the global contour scale for all spectra to the default of 100,000' button = Button(globalFrame, borderwidth=1, text='10^5', tipText=tipText, command=self.defaultGlobalScale, grid=(1, 0)) tipText = 'Click to decrease "-" or increase "+" the global contour scale by small amounts' frame = ValueRamp(globalFrame, callback=self.changeGlobalScale, tipText=tipText) frame.grid(row=1, column=1, columnspan=3, sticky='e') row += 1 self.autoFrame = LabelFrame(guiFrame, text='Auto contour levels') self.autoFrame.grid(row=row, column=0, columnspan=5, sticky='nsew') self.autoFrame.grid_columnconfigure(1, weight=1) frow = 0 label = Label(self.autoFrame, text='Base level:', grid=(frow, 0), sticky='e') tipText = 'The first contour level (closest to zero) for an automated series of levels: the start of a geometric or arithmetic series defining levels' self.base_entry = FloatEntry(self.autoFrame, returnCallback=self.applyAuto, width=10, grid=(frow, 1), sticky='ew', tipText=tipText) command = lambda: self.changeBaseLevel(0.5) tipText = 'Lower the base contour level so that it is half of the previous value; moving the series of contour levels closer to zero' button = Button(self.autoFrame, borderwidth=1, text='/2', tipText=tipText, command=command, grid=(frow, 2), sticky='ew') command = lambda: self.changeBaseLevel(2.0) tipText = 'Raise the base contour level so that it is double the previous value; moving the series of contour levels further from zero' button = Button(self.autoFrame, borderwidth=1, text='*2', tipText=tipText, command=command, grid=(frow, 3), sticky='ew') tipText = 'Click to decrease "-" or increase "+" the base contour level by small amounts' frame = ValueRamp(self.autoFrame, callback=self.changeBaseLevel, tipText=tipText) frame.grid(row=frow, column=4, columnspan=3, sticky='ew') frow += 1 label = Label(self.autoFrame, text='Number of levels:', grid=(frow, 0), sticky='e') #self.numberEntry = IntEntry(guiFrame, text=numberLevels, # returnCallback=self.applyAuto) tipText = 'The number of contour levels to make in the automated series' self.numberEntry = IntEntry(self.autoFrame, returnCallback=self.applyAuto, width=10, grid=(frow, 1), sticky='ew', tipText=tipText) command = lambda w=-1: self.changeNumberLevels(w) tipText = 'Decrease the number of contour levels in the series by one' button = Button(self.autoFrame, borderwidth=1, text='-1', tipText=tipText, command=command, grid=(frow, 2), sticky='ew') command = lambda w=1: self.changeNumberLevels(w) tipText = 'Increase the number of contour levels in the series by one' button = Button(self.autoFrame, borderwidth=1, text='+1', tipText=tipText, command=command, grid=(frow, 3), sticky='ew') n = 4 for w in (5, 10, 15, 20): tipText = 'Set the number of contour levels in the series to %d' % w command = lambda w=w: self.setNumberLevels(w) button = Button(self.autoFrame, borderwidth=1, text='%d' % w, command=command, grid=(frow, n), sticky='ew', tipText=tipText) n += 1 frow += 1 self.change_label = Label(self.autoFrame, text='%s:' % multiplier_text, grid=(frow, 0), sticky='e') tipText = 'The multiplication factor (or increment if adding levels) to repetitively apply to the base level to generate the series of levels' self.change_entry = FloatEntry(self.autoFrame, returnCallback=self.applyAuto, width=10, grid=(frow, 1), sticky='ew', tipText=tipText) self.change_level_buttons = [] n = 2 for w in multiplier_changes: tipText = 'Set the automated series multiplication factor or increment to %f' % w command = lambda w=w: self.setChange(w) button = Button(self.autoFrame, borderwidth=1, text=str(w), command=command, grid=(frow, n), sticky='ew', tipText=tipText) self.change_level_buttons.append(button) n += 1 frow += 1 frame = Frame(self.autoFrame, grid=(frow, 0), gridSpan=(1, 7), sticky='ew') tipTexts = [ 'Toggles whether positive contour levels from the automated series will be used. Overrides any manual settings', 'Toggles whether negative contour levels from the automated series will be used. Overrides any manual settings' ] entries = ('Positive', 'Negative') selected = (True, False) self.which_buttons = CheckButtons(frame, entries, selected=selected, select_callback=self.applyAuto, grid=(0, 0), sticky='w', tipTexts=tipTexts) tipTexts = [ 'Set the contour level generation to use a geometric series, starting from the base level and using the specified factor', 'Set the contour level generation to use an arithmetic series, starting from the base level and using the specified increment' ] entries = ('Multiply levels', 'Add levels') self.change_mode_buttons = RadioButtons( frame, entries, grid=(0, 1), sticky='ew', select_callback=self.modeChanged, tipTexts=tipTexts) row += 1 manualFrame = LabelFrame(guiFrame, text='Positive levels', grid=(row, 0), gridSpan=(1, 2)) manualFrame.expandGrid(None, 0) tipText = 'The positive contour levels that will be used for the spectrum; filled in by the automation or set/modified manually' self.posLevelsEntry = FloatEntry(manualFrame, isArray=True, width=60, returnCallback=self.applyManual, tipText=tipText, grid=(0, 0), sticky='ew') row += 1 manualFrame = LabelFrame(guiFrame, text='Negative levels', grid=(row, 0), gridSpan=(1, 2)) manualFrame.expandGrid(None, 0) tipText = 'The negative contour levels that will be used for the spectrum; filled in by the automation or set/modified manually' self.negLevelsEntry = FloatEntry(manualFrame, isArray=True, width=60, returnCallback=self.applyManual, tipText=tipText, grid=(0, 0), sticky='ew') row += 1 tipTexts = [ 'Set the spectrum contour levels, updating the display, to the automated series, ignoring any manual edits.', 'Set the spectrum contour levels, updating the display, to the values displayed in the level entry fields' ] texts = ['Apply Auto Levels', 'Apply Manual Edits'] commands = [self.applyAuto, self.applyManual] self.buttons = UtilityButtonList(guiFrame, texts=texts, commands=commands, helpUrl=self.help_url, grid=(row, 0), gridSpan=(1, 2), tipTexts=tipTexts) guiFrame.grid_rowconfigure(row, weight=1) self.curateNotifiers(self.registerNotify) self.update()
def body(self, guiFrame): guiFrame.grid_columnconfigure(0, weight=1, minsize=500) row = 0 frame = LabelFrame(guiFrame, text='General Options') frame.grid(row=row, column=0, sticky='nsew') frame.grid_columnconfigure(1, weight=1) label = Label(frame, text='Molecular System:') label.grid(row=0, column=0, sticky='w') self.molSystemPulldown = PulldownMenu(frame, self.changeMolSystem, do_initial_callback=False) self.molSystemPulldown.grid(row=0, column=1, sticky='w') label = Label(frame, text='Measured J coupling list:') label.grid(row=0, column=2, sticky='w') self.measureCouplingListPulldown = PulldownMenu( frame, self.changeMeasureCouplingList) self.measureCouplingListPulldown.grid(row=0, column=3, sticky='w') label = Label(frame, text='Predicted J coupling list:') label.grid(row=0, column=4, sticky='w') self.predictCouplingListPulldown = PulldownMenu( frame, self.changePredictCouplingList) self.predictCouplingListPulldown.grid(row=0, column=5, sticky='w') row += 1 guiFrame.grid_rowconfigure(row, weight=1) frame = LabelFrame(guiFrame, text='Angles & 3J Couplings') frame.grid(row=row, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) headingList = ['Residue', 'Phi', 'Chi^2'] editWidgets = [None, None, None] editGetCallbacks = [None, None, None] editSetCallbacks = [None, None, None] self.jCouplingEntry = FloatEntry( self, width=8, returnCallback=lambda event: self.setJCoupling()) i = 0 for names in couplingAtoms: headingList.extend( ['Pred\nJ(%s,%s)' % names, 'Expt\nJ(%s,%s)' % names]) editWidgets.extend([None, self.jCouplingEntry]) editGetCallbacks.extend( [None, lambda obj, i=i: self.getJCoupling(obj, i)]) editSetCallbacks.extend( [None, lambda event, i=i: self.setJCoupling(i)]) i += 1 self.couplingMatrix = ScrolledMatrix(frame, headingList=headingList, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, callback=self.selectJCoupling, multiSelect=False) self.couplingMatrix.grid(row=0, column=0, sticky='nsew') self.couplingMatrix.doEditMarkExtraRules = self.doEditMarkExtraRules row += 1 frame = LabelFrame(guiFrame, text='Karplus Coefficients') frame.grid(row=row, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) headingList = ['Phase'] editWidgets = [ None, ] editGetCallbacks = [ None, ] editSetCallbacks = [ None, ] self.coefficientEntry = FloatEntry( self, width=8, returnCallback=lambda event: self.setCoefficient()) for names in couplingAtoms: headingList.append('J(%s,%s)' % names) editWidgets.append(self.coefficientEntry) editGetCallbacks.append( lambda obj, n=names: self.getCoefficient(obj, n)) editSetCallbacks.append( lambda event, n=names: self.setCoefficient(n)) headingList = [ 'Phase', 'J(H,HA)', 'J(H,C)', 'J(H,CB)', 'J(C,HA)', 'J(C,C)', 'J(C,CB)' ] self.coefficientMatrix = ScrolledMatrix( frame, headingList=headingList, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, callback=self.selectCoefficient, maxRows=3, multiSelect=False) self.coefficientMatrix.grid(row=0, column=0, sticky='nsew') row += 1 texts = [] commands = [] self.bottomButtons = UtilityButtonList(guiFrame, commands=commands, texts=texts, helpUrl=self.help_url) self.bottomButtons.grid(row=row, column=0, sticky='ew') for func in ('__init__', 'delete', 'setValue', 'setError'): for clazz in ('ccp.nmr.Nmr.JCoupling', ): self.registerNotify(self.updateAfter, clazz, func) for func in ('__init__', 'delete'): for clazz in ('ccp.nmr.Nmr.JCouplingList', ): self.registerNotify(self.updateJCouplingLists, clazz, func)
def body(self, guiParent): now = datetime.date.today().strftime('%y%m%d') filePrefix = '%s_%s' % (self.project.name, now) projDir = getUserDataPath(self.project) directory = os.path.dirname(projDir) guiParent.grid_rowconfigure(0, weight=1) guiParent.grid_columnconfigure(1, weight=1) row = 0 label = Label(guiParent, text='Archive File:') label.grid(row=row, column=0, sticky=Tkinter.E) tipText = 'File name (excluding .tgz ending) for archive' self.fileEntry = Entry(guiParent, text=filePrefix, tipText=tipText) self.fileEntry.grid(row=row, column=1, sticky=Tkinter.EW) label = Label(guiParent, text='.tgz (automatically appended)') label.grid(row=row, column=2, sticky=Tkinter.W) row = row + 1 self.backupCheck = CheckButton( guiParent, text='Include *.xml.bak files', tipText='If checked include *.xml.bak files') self.backupCheck.grid(row=row, column=1, columnspan=2, sticky=Tkinter.W) row = row + 1 self.dataCheck = CheckButton( guiParent, text='Include data files which are in project directory', tipText= 'If checked include data files if they are located in project directory' ) self.dataCheck.grid(row=row, column=1, columnspan=2, sticky=Tkinter.W) row = row + 1 labelFrame = LabelFrame(guiParent, text='Archive Location') labelFrame.grid(row=row, column=0, columnspan=3, sticky=Tkinter.NSEW) labelFrame.grid_rowconfigure(0, weight=1) labelFrame.grid_columnconfigure(0, weight=1) self.dirSelect = FileSelect(labelFrame, directory=directory, show_file=False) self.dirSelect.grid(row=0, column=0, sticky=Tkinter.NSEW) guiParent.grid_rowconfigure(row, weight=1) row = row + 1 texts = ['Save'] tipTexts = ['Create archive file'] commands = [self.save] buttons = createDismissHelpButtonList(guiParent, texts=texts, tipTexts=tipTexts, commands=commands, help_msg=self.help_msg, help_url=self.help_url, dismiss_text=self.dismiss_text, expands=True) buttons.grid(row=row, column=0, columnspan=3, sticky=Tkinter.EW)
def body(self): frame = self.frame self.resultsResidueNumber = 1 frame.expandGrid(5, 0) resultTopFrame = LabelFrame(frame, text='Which results to show') resultTopFrame.grid(row=0, column=0, sticky='ew') self.resultsResidueNumber = 3 texts = [' < '] commands = [self.resultsPrevResidue] self.resultsPreviousButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsPreviousButton.grid(row=0, column=1, sticky='nsew') tipText = 'The Number of the residue in the sequence to display results for' self.resultsResidueNumberEntry = IntEntry( resultTopFrame, grid=(0, 2), width=7, text=3, returnCallback=self.resultsUpdateAfterEntry, tipText=tipText) #self.resultsResidueNumberEntry.bind('<Leave>', self.resultsUpdateAfterEntry, '+') texts = [' > '] commands = [self.resultsNextResidue] self.resultsNextButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsNextButton.grid(row=0, column=3, sticky='nsew') selectCcpCodes = ['residue'] + AMINO_ACIDS self.resultsSelectedCcpCode = 'residue' tipText = 'Instead of going through the sequence residue by residue, jump directly to next amino acid of a specific type.' resultsSelectCcpCodeLabel = Label( resultTopFrame, text='Directly jump to previous/next:', grid=(0, 4)) self.resultsSelectCcpCodePulldown = PulldownList( resultTopFrame, callback=self.resultsChangeSelectedCcpCode, texts=selectCcpCodes, index=selectCcpCodes.index(self.resultsSelectedCcpCode), grid=(0, 5), tipText=tipText) self.selectedSolution = 1 runLabel = Label(resultTopFrame, text='run:') runLabel.grid(row=0, column=6) texts = [' < '] commands = [self.resultsPrevSolution] self.resultsPreviousSolutionButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsPreviousSolutionButton.grid(row=0, column=7, sticky='nsew') tipText = 'If you ran the algorithm more than once, you can select the solution given by the different runs.' self.resultsSolutionNumberEntry = IntEntry( resultTopFrame, grid=(0, 8), width=7, text=1, returnCallback=self.solutionUpdateAfterEntry, tipText=tipText) #self.resultsSolutionNumberEntry.bind('<Leave>', self.solutionUpdateAfterEntry, '+') texts = [' > '] commands = [self.resultsNextSolution] self.resultsNextSolutionButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsNextSolutionButton.grid(row=0, column=9, sticky='nsew') self.energyLabel = Label(resultTopFrame, text='energy:') self.energyLabel.grid(row=0, column=10) texts = ['template for puzzling'] commands = [self.adoptSolution] self.adoptButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.adoptButton.grid(row=0, column=11, sticky='nsew') # LabelFrame(frame, text='Spin Systems') resultsSecondFrame = Frame(frame) resultsSecondFrame.grid(row=2, column=0, sticky='nsew') resultsSecondFrame.grid_columnconfigure(0, weight=1) resultsSecondFrame.grid_columnconfigure(1, weight=1) resultsSecondFrame.grid_columnconfigure(2, weight=1) resultsSecondFrame.grid_columnconfigure(3, weight=1) resultsSecondFrame.grid_columnconfigure(4, weight=1) headingList = ['#', '%'] tipTexts = [ 'Spinsystem number {} indicates serial of the spinsystem. If the spinsystem was already assigned to a residue, the residue number is shown aswell', 'percentage of the solutions that connected this spinsystem to this residue' ] editWidgets = [None, None, None] self.displayResultsTables = [] self.residueLabels = [] for i in range(5): label = Label(resultsSecondFrame, text='residue') label.grid(row=0, column=i) #editGetCallbacks = [createCallbackFunction(i)]*3 displayResultsTable = ScrolledMatrix( resultsSecondFrame, headingList=headingList, multiSelect=False, tipTexts=tipTexts, callback=self.selectSpinSystemForTable, passSelfToCallback=True) displayResultsTable.grid(row=2, column=i, sticky='nsew') displayResultsTable.sortDown = False self.residueLabels.append(label) self.displayResultsTables.append(displayResultsTable) # LabelFrame(frame, text='Sequence Fragment') resultsFirstFrame = Frame(resultsSecondFrame) resultsFirstFrame.grid(row=1, column=0, sticky='ew', columnspan=5) resultsFirstFrame.grid_rowconfigure(0, weight=1) resultsFirstFrame.grid_rowconfigure(1, weight=1) resultsFirstFrame.grid_columnconfigure(0, weight=1) texts = [ ' res 1 ', ' links ', ' res 2 ', ' links ', ' res 3 ', ' links ', ' res 4 ', ' links ', ' res 5 ' ] commands = [ lambda: self.selectRelativeResidue(1, True), lambda: self.selectLink(1, True), lambda: self.selectRelativeResidue(2, True), lambda: self.selectLink(2, True), lambda: self.selectRelativeResidue(3, True), lambda: self.selectLink(3, True), lambda: self.selectRelativeResidue(4, True), lambda: self.selectLink(4, True), lambda: self.selectRelativeResidue(5, True) ] self.sequenceButtons = ButtonList(resultsFirstFrame, commands=commands, texts=texts) self.sequenceButtons.grid(row=0, column=0, sticky='nsew') for n, button in enumerate(self.sequenceButtons.buttons): if n % 2: button.grid(column=n, sticky='ns') self.sequenceButtons.grid_columnconfigure(n, weight=0) else: self.sequenceButtons.grid_columnconfigure(n, uniform=2) spacer = Spacer(resultsFirstFrame) spacer.grid(row=1, column=0, sticky='nsew') texts = [ ' res 1 ', ' links ', ' res 2 ', ' links ', ' res 3 ', ' links ', ' res 4 ', ' links ', ' res 5 ' ] commands = commands = [ lambda: self.selectRelativeResidue(1, False), lambda: self.selectLink(1, False), lambda: self.selectRelativeResidue(2, False), lambda: self.selectLink(2, False), lambda: self.selectRelativeResidue(3, False), lambda: self.selectLink(3, False), lambda: self.selectRelativeResidue(4, False), lambda: self.selectLink(4, False), lambda: self.selectRelativeResidue(5, False) ] self.sequenceButtonsB = ButtonList(resultsFirstFrame, commands=commands, texts=texts) self.sequenceButtonsB.grid(row=2, column=0, sticky='nsew') for n, button in enumerate(self.sequenceButtonsB.buttons): if n % 2: button.grid(column=n, sticky='ns') self.sequenceButtonsB.grid_columnconfigure(n, weight=0) else: self.sequenceButtonsB.grid_columnconfigure(n, uniform=2) frame.grid_rowconfigure(3, weight=2) resultsThirdFrame = Frame(frame) resultsThirdFrame.grid(row=3, column=0, sticky='nsew') resultsThirdFrame.grid_rowconfigure(0, weight=1) resultsThirdFrame.grid_columnconfigure(0, weight=1) tabbedFrameB = TabbedFrame(resultsThirdFrame, options=['Peaks', 'Spin System'], callback=self.toggleTab, grid=(0, 0)) #self.tabbedFrameB = tabbedFrame PeakFrame, SpinSystemFrame = tabbedFrameB.frames SpinSystemFrame.grid_rowconfigure(0, weight=1) PeakFrame.grid_rowconfigure(1, weight=1) SpinSystemFrame.grid_columnconfigure(0, weight=1) PeakFrame.grid_columnconfigure(0, weight=1) headingList = [ 'residue', 'assigned to in project', 'user defined sequence', 'selected annealing result', '%' ] tipTexts = [None, None, None, None, None] editWidgets = [None, None, None, None, None] editGetCallbacks = [None, None, None, None, None] editSetCallbacks = [None, None, None, None, None] self.spinSysTable = ScrolledMatrix(SpinSystemFrame, headingList=headingList, editWidgets=editWidgets, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.spinSysTable.grid(row=0, column=0, sticky='nsew') buttonFrameinPeakFrame = Frame(PeakFrame) buttonFrameinPeakFrame.grid(sticky='ew') self.findButton = Button( buttonFrameinPeakFrame, text=' Go to Peak ', borderwidth=1, padx=2, pady=1, command=self.findPeak, tipText='Locate the currently selected peak in the specified window' ) self.findButton.grid(row=0, column=0, sticky='e') label = Label(buttonFrameinPeakFrame, text='in window:') label.grid(row=0, column=1, sticky='w') self.windowPulldown = PulldownList( buttonFrameinPeakFrame, callback=self.selectWindowPane, tipText='Choose the spectrum window for locating peaks or strips') self.windowPulldown.grid(row=0, column=2, sticky='w') self.assignSelectedPeaksButton = Button( buttonFrameinPeakFrame, text='Assign Resonances to Peak(s)', borderwidth=1, padx=2, pady=1, command=self.assignSelectedPeaks, tipText= 'Assign resonances to peak dimensions, this of course only works when the peak is found in the spectrum.' ) self.assignSelectedPeaksButton.grid(row=0, column=3, sticky='ew') self.assignSelectedSpinSystemsToResiduesButton = Button( buttonFrameinPeakFrame, text='Assign Spinsystems to Residues', borderwidth=1, padx=2, pady=1, command=self.assignSelectedSpinSystemsToResidues, tipText='Assign spinsystems to residues') self.assignSelectedSpinSystemsToResiduesButton.grid(row=0, column=4, sticky='ew') headingList = [ '#', 'spectrum', 'Dim1', 'Dim2', 'Dim3', 'c.s. dim1', 'c.s. dim2', 'c.s. dim3', 'colabelling' ] tipTexts = [ 'Peak number, only present when the peak was actually found in the spectrum.', 'Name of the spectrum', 'Name of atomSet measured in this dimension. Dimension number corresponds to Ref Exp Dim as indicated by going in the main menu to Experiment-->Experiments-->Experiment Type', 'Name of atomSet measured in this dimension. Dimension number corresponds to Ref Exp Dim as indicated by going in the main menu to Experiment-->Experiments-->Experiment Type', 'Name of atomSet measured in this dimension. Dimension number corresponds to Ref Exp Dim as indicated by going in the main menu to Experiment-->Experiments-->Experiment Type', 'Chemical Shift', 'Chemical Shift', 'Chemical Shift', 'Colabbeling fraction over all nuclei that are on the magnetization transfer pathway during the experiment that gave rise to the peak, including visited nuclei that were not measured in any of the peak dimensions' ] #editWidgets = [None, None, None, None, None, None, None, None, None] editGetCallbacks = [ None, None, None, None, None, None, None, None, None ] #editGetCallbacks = [self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak] editSetCallbacks = [ None, None, None, None, None, None, None, None, None ] self.displayPeakTable = ScrolledMatrix(PeakFrame, headingList=headingList, multiSelect=True, tipTexts=tipTexts) #editWidgets=editWidgets, multiSelect=True, # editGetCallbacks=editGetCallbacks, # editSetCallbacks=editSetCallbacks, # tipTexts=tipTexts) self.displayPeakTable.grid(row=1, column=0, sticky='nsew') self.windowPane = None self.updateWindows()
def __init__(self, guiParent, project, callback=None, help_msg='', help_url='', dismiss_text='', modal=False, *args, **kw): self.project = project self.callback = callback self.help_msg = help_msg self.help_url = help_url self.dismiss_text = dismiss_text self.modal = modal self.did_save = False Frame.__init__(self, guiParent, *args, **kw) projDir = Io.getUserDataPath(self.project) guiParent.grid_columnconfigure(1, weight=1) row = 0 label = Label(guiParent, text='Project Name:') label.grid(row=row, column=0, sticky=Tkinter.E) self.proj_name_entry = Entry( guiParent, text=self.project.name, returnCallback=self.updateInfo, leaveCallback=self.updateInfo, tipText='The name used for the project save directory') self.proj_name_entry.grid(row=row, column=1, sticky=Tkinter.EW) row = row + 1 label = Label(guiParent, text='Project Directory:') label.grid(row=row, column=0, sticky=Tkinter.E) label = self.proj_dir_label = Label(guiParent, text=projDir) label.grid(row=row, column=1, sticky=Tkinter.W) row = row + 1 label = Label( guiParent, text='Note: Project Directory = Save Location + Project Name') label.grid(row=row, column=1, sticky=Tkinter.W) text = 'Save binary data with project' tipText = 'Copy data files (e.g. for spectra) into new project directory if not already in current project directory: careful, this can take some time' row = row + 1 self.dataCheckButton = CheckButton(guiParent, text=text, tipText=tipText) self.dataCheckButton.grid(row=row, column=0, columnspan=2, sticky=Tkinter.W) row = row + 1 guiParent.grid_rowconfigure(row, weight=1) labelFrame = LabelFrame(guiParent, text='Save Location') labelFrame.grid(row=row, column=0, columnspan=2, sticky=Tkinter.NSEW) labelFrame.grid_rowconfigure(0, weight=1) labelFrame.grid_columnconfigure(0, weight=1) directory = os.path.dirname(projDir) self.proj_dir_select = FileSelect( labelFrame, directory=directory, select_dir_callback=self.selectDir, change_dir_callback=self.updateInfo, should_change_dir_callback=self.shouldChangeDir, getRowColor=self.getEntryColor, show_file=False) self.proj_dir_select.grid(row=0, column=0, sticky=Tkinter.NSEW) row = row + 1 texts = ['Save'] tipTexts = ['Save project with specified name in specified directory'] commands = [self.save] buttons = createDismissHelpButtonList(guiParent, texts=texts, tipTexts=tipTexts, commands=commands, help_msg=self.help_msg, help_url=self.help_url, dismiss_text=self.dismiss_text, expands=True) buttons.grid(row=row, column=0, columnspan=2, sticky=Tkinter.EW)
def body(self, guiFrame): self.specFreqEntry = IntEntry(self, text=self.specFreq, width=8, returnCallback=self.setSpecFreq) self.maxIterEntry = IntEntry(self, text=self.maxIter, width=8, returnCallback=self.setMaxIter) self.mixTimeEntry = FloatEntry(self, text=self.mixTime, width=8, returnCallback=self.setMixTime) self.corrTimeEntry = FloatEntry(self, text=self.corrTime, width=8, returnCallback=self.setCorrTime) self.leakRateEntry = FloatEntry(self, text=self.leakRate, width=8, returnCallback=self.setLeakRate) self.maxIntensEntry = IntEntry(self, text=self.maxIntens, width=8, returnCallback=self.setMaxIntens) self.mdInitTempEntry = FloatEntry(self, text='', returnCallback=self.setMdInitTemp) self.mdFinTempEntry = FloatEntry(self, text='', returnCallback=self.setMdFinTemp) self.mdCoolStepsEntry = IntEntry(self, text='', returnCallback=self.setMdCoolSteps) self.mdSimStepsEntry = IntEntry(self, text='', returnCallback=self.setMdSimSteps) self.mdTauEntry = FloatEntry(self, text='', returnCallback=self.setMdTau) self.mdRepScaleEntry = FloatEntry(self, text='', returnCallback=self.setMdRepScale) guiFrame.grid_columnconfigure(0, weight=1) row = 0 frame0 = LabelFrame(guiFrame, text='Setup peak lists') frame0.grid(row=row, column=0, sticky=Tkinter.NSEW) frame0.grid(row=row, column=0, sticky=Tkinter.NSEW) frame0.grid_columnconfigure(1, weight=1) f0row = 0 label00 = Label(frame0, text='1H-1H NOESY spectrum') label00.grid(row=f0row, column=0, sticky=Tkinter.NW) self.noesyPulldown = PulldownMenu(frame0, entries=self.getNoesys(), callback=self.setNoesy, selected_index=0, do_initial_callback=0) self.noesyPulldown.grid(row=f0row, column=1, sticky=Tkinter.NW) f0row += 1 label01 = Label(frame0, text='15N HSQC spectrum') label01.grid(row=f0row, column=0, sticky=Tkinter.NW) self.hsqcPulldown = PulldownMenu(frame0, entries=self.getHsqcs(), callback=self.setHsqc, selected_index=0, do_initial_callback=0) self.hsqcPulldown.grid(row=f0row, column=1, sticky=Tkinter.NW) f0row += 1 label02 = Label(frame0, text='15N HSQC TOCSY spectrum') label02.grid(row=f0row, column=0, sticky=Tkinter.NW) self.tocsyPulldown = PulldownMenu(frame0, entries=self.getTocsys(), callback=self.setTocsy, selected_index=0, do_initial_callback=0) self.tocsyPulldown.grid(row=f0row, column=1, sticky=Tkinter.NW) f0row += 1 label02 = Label(frame0, text='15N HSQC NOESY spectrum') label02.grid(row=f0row, column=0, sticky=Tkinter.NW) self.noesy3dPulldown = PulldownMenu(frame0, entries=self.getNoesy3ds(), callback=self.setNoesy3d, selected_index=0, do_initial_callback=0) self.noesy3dPulldown.grid(row=f0row, column=1, sticky=Tkinter.NW) f0row += 1 texts = ['Setup resonances & peaks', 'Show Peaks', 'Show resonances'] commands = [self.setupResonances, self.showPeaks, self.showResonances] self.setupButtons = ButtonList(frame0, expands=1, texts=texts, commands=commands) self.setupButtons.grid(row=f0row, column=0, columnspan=2, sticky=Tkinter.NSEW) f0row += 1 self.label03a = Label(frame0, text='Resonances found: 0') self.label03a.grid(row=f0row, column=0, sticky=Tkinter.NW) self.label03b = Label(frame0, text='NOESY peaks found: 0') self.label03b.grid(row=f0row, column=1, sticky=Tkinter.NW) row += 1 frame1 = LabelFrame(guiFrame, text='Calculate distance constraints') frame1.grid(row=row, column=0, sticky=Tkinter.NSEW) frame1.grid_columnconfigure(3, weight=1) f1row = 0 frame1.grid_rowconfigure(f1row, weight=1) data = [ self.specFreq, self.maxIter, self.mixTime, self.corrTime, self.leakRate, self.maxIntens ] colHeadings = [ 'Spectrometer\nfrequency', 'Max\niterations', 'Mixing\ntime (ms)', 'Correl.\ntime (ns)', 'Leak\nrate', 'Max\nintensity' ] editWidgets = [ self.specFreqEntry, self.maxIterEntry, self.mixTimeEntry, self.corrTimeEntry, self.leakRateEntry, self.maxIntensEntry, ] editGetCallbacks = [ self.getSpecFreq, self.getMaxIter, self.getMixTime, self.getCorrTime, self.getLeakRate, self.getMaxIntens, ] editSetCallbacks = [ self.setSpecFreq, self.setMaxIter, self.setMixTime, self.setCorrTime, self.setLeakRate, self.setMaxIntens, ] self.midgeParamsMatrix = ScrolledMatrix( frame1, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, maxRows=1, initialCols=5, headingList=colHeadings, callback=None, objectList=[ 'None', ], textMatrix=[ data, ]) self.midgeParamsMatrix.grid(row=f1row, column=0, columnspan=4, sticky=Tkinter.NSEW) f1row += 1 label10 = Label(frame1, text='Benchmark structure') label10.grid(row=f1row, column=0, sticky=Tkinter.NW) self.structurePulldown = PulldownMenu(frame1, entries=self.getStructures(), callback=self.setStructure, selected_index=0, do_initial_callback=0) self.structurePulldown.grid(row=f1row, column=1, sticky=Tkinter.NW) label11 = Label(frame1, text='ADC atom types:') label11.grid(row=f1row, column=2, sticky=Tkinter.NW) self.adcAtomsPulldown = PulldownMenu(frame1, entries=self.getAdcAtomTypes(), callback=self.setAdcAtomTypes, selected_index=0, do_initial_callback=0) self.adcAtomsPulldown.grid(row=f1row, column=3, sticky=Tkinter.NW) f1row += 1 texts = [ 'Calculate distances', 'Show distance\nconstraints', 'Show anti-distance\nconstraints' ] commands = [ self.calculateDistances, self.showConstraints, self.showAntiConstraints ] self.midgeButtons = ButtonList(frame1, expands=1, texts=texts, commands=commands) self.midgeButtons.grid(row=f1row, column=0, columnspan=4, sticky=Tkinter.NSEW) f1row += 1 self.distConstrLabel = Label(frame1, text='Distance constraints:') self.distConstrLabel.grid(row=f1row, column=0, columnspan=2, sticky=Tkinter.NW) self.antiConstrLabel = Label(frame1, text='Anti-distance constraints:') self.antiConstrLabel.grid(row=f1row, column=2, columnspan=2, sticky=Tkinter.NW) row += 1 guiFrame.grid_rowconfigure(row, weight=1) frame2 = LabelFrame(guiFrame, text='Proton cloud molecular dynamics') frame2.grid(row=row, column=0, sticky=Tkinter.NSEW) frame2.grid_columnconfigure(1, weight=1) f2row = 0 frame2.grid_rowconfigure(f2row, weight=1) data = [ self.specFreq, self.maxIter, self.mixTime, self.corrTime, self.leakRate ] colHeadings = [ 'Step', 'Initial temp.', 'Final temp.', 'Cooling steps', 'MD steps', 'MD tau', 'Rep. scale' ] editWidgets = [ None, self.mdInitTempEntry, self.mdFinTempEntry, self.mdCoolStepsEntry, self.mdSimStepsEntry, self.mdTauEntry, self.mdRepScaleEntry ] editGetCallbacks = [ None, self.getMdInitTemp, self.getMdFinTemp, self.getMdCoolSteps, self.getMdSimSteps, self.getMdTau, self.getMdRepScale ] editSetCallbacks = [ None, self.setMdInitTemp, self.setMdFinTemp, self.setMdCoolSteps, self.setMdSimSteps, self.setMdTau, self.setMdRepScale ] self.coolingSchemeMatrix = ScrolledMatrix( frame2, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, maxRows=9, initialRows=12, headingList=colHeadings, callback=self.selectCoolingStep, objectList=self.coolingScheme, textMatrix=self.coolingScheme) self.coolingSchemeMatrix.grid(row=f2row, column=0, columnspan=4, sticky=Tkinter.NSEW) f2row += 1 texts = ['Move earlier', 'Move later', 'Add step', 'Remove step'] commands = [ self.moveStepEarlier, self.moveStepLater, self.addCoolingStep, self.removeCoolingStep ] self.coolingSchemeButtons = ButtonList(frame2, expands=1, commands=commands, texts=texts) self.coolingSchemeButtons.grid(row=f2row, column=0, columnspan=4, sticky=Tkinter.EW) f2row += 1 label20 = Label(frame2, text='Number of clouds:') label20.grid(row=f2row, column=0, sticky=Tkinter.NW) self.numCloudsEntry = FloatEntry(frame2, text=100, returnCallback=self.setNumClouds, width=10) self.numCloudsEntry.grid(row=f2row, column=1, sticky=Tkinter.NW) label21 = Label(frame2, text='Cloud file prefix:') label21.grid(row=f2row, column=2, sticky=Tkinter.NW) self.filePrefixEntry = Entry(frame2, text='cloud_', returnCallback=self.setFilePrefix, width=10) self.filePrefixEntry.grid(row=f2row, column=3, sticky=Tkinter.NW) f2row += 1 texts = ['Start molecular dynamics', 'Show dynamics progress'] commands = [self.startMd, self.showMdProgress] self.mdButtons = ButtonList(frame2, expands=1, commands=commands, texts=texts) self.mdButtons.grid(row=f2row, column=0, columnspan=4, sticky=Tkinter.NSEW) row += 1 self.bottomButtons = createDismissHelpButtonList(guiFrame, expands=0, help_url=None) self.bottomButtons.grid(row=row, column=0, sticky=Tkinter.EW) self.setButtonStates()
def body(self, guiFrame): guiFrame.grid_columnconfigure(0, weight=1) row = 0 strucGenFrame = LabelFrame(guiFrame, text='Generation Runs') strucGenFrame.grid(row=row, column=0, columnspan=1, sticky='nsew') strucGenFrame.grid_columnconfigure(0, weight=1) strucGenFrame.grid_rowconfigure(0, weight=1) guiFrame.grid_rowconfigure(row, weight=0) #self.editDetailsEntry = Entry(self,text='',returnCallback = self.setDetails, width=12) #editWidgets = [None, None, None, None, None, self.editDetailsEntry] #editGetCallbacks = [None, None, None, None, None, self.getDetails] #editSetCallbacks = [None, None, None, None, None, self.setDetails] colHeadings = [ '#', 'Constraint\nLists', 'Violation\nLists', 'Structures', 'Fixed\nAtom Sets', 'Fixes\nResonance Sets', 'Chain\nStates', 'Database\nEntries', 'Resonance\nClouds' ] editWidgets = [None, None, None, None, None, None, None, None, None] editGetCallbacks = [ None, None, None, None, None, None, None, None, None ] editSetCallbacks = [ None, None, None, None, None, None, None, None, None ] self.structGenMatrix = ScrolledMatrix( strucGenFrame, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, initialRows=3, initialCols=6, headingList=colHeadings, callback=self.selectStructGenCell, objectList=[], textMatrix=[ [], ]) self.structGenMatrix.grid(row=0, column=0, sticky='nsew') texts = ['View Structures', 'Delete'] commands = [self.viewStructures, self.deleteStrucGen] self.structGenButtons = ButtonList(strucGenFrame, texts=texts, expands=True, commands=commands) self.structGenButtons.grid(row=1, column=0, sticky='ew') row += 1 constrFrame = LabelFrame(guiFrame, text='Constraint Lists') constrFrame.grid(row=row, column=0, columnspan=1, sticky='nsew') constrFrame.grid_columnconfigure(0, weight=1) constrFrame.grid_rowconfigure(0, weight=1) guiFrame.grid_rowconfigure(row, weight=1) colHeadings = [ '#', 'Type', 'Name', 'Constraints', 'Experiments', 'Details', 'Unit' ] editWidgets = [None, None, None, None, None, None, None] editGetCallbacks = [None, None, None, None, None, None, None] editSetCallbacks = [None, None, None, None, None, None, None] self.constrListMatrix = ScrolledMatrix( constrFrame, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, initialRows=10, headingList=colHeadings, callback=self.selectConstrListCell, objectList=[], textMatrix=[ [], ]) self.constrListMatrix.grid(row=0, column=0, sticky='nsew') texts = ['View Constraints', 'Create List', 'Delete List'] commands = [ self.viewConstraints, self.createConstraints, self.deleteConstraints ] self.constrListButtons = ButtonList(constrFrame, texts=texts, expands=True, commands=commands) self.constrListButtons.grid(row=1, column=0, sticky='ew') self.constrListButtons.buttons[1].disable() row += 1 violFrame = LabelFrame(guiFrame, text='Violation Lists') violFrame.grid(row=row, column=0, columnspan=1, sticky='nsew') violFrame.grid_columnconfigure(0, weight=1) violFrame.grid_rowconfigure(0, weight=1) guiFrame.grid_rowconfigure(row, weight=1) colHeadings = [ '#', 'Violations', 'Structures', 'Details', ] editWidgets = [None, None, None, None] editGetCallbacks = [None, None, None, None] editSetCallbacks = [None, None, None, None] self.violListMatrix = ScrolledMatrix(violFrame, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, initialRows=10, headingList=colHeadings, callback=self.selectViolListCell, objectList=[], textMatrix=[ [], ]) self.violListMatrix.grid(row=0, column=0, sticky='nsew') texts = ['View Violations', 'Delete List'] commands = [self.viewViolations, self.deleteViolations] self.violListButtons = ButtonList(violFrame, texts=texts, expands=True, commands=commands) self.violListButtons.grid(row=1, column=0, sticky='ew') row += 1 self.bottomButtons = UtilityButtonList(guiFrame, helpUrl=self.help_url) self.bottomButtons.grid(row=row, column=0, columnspan=1, sticky='ew') self.update() for func in ('__init__', 'delete', 'setName', 'setDetails', 'setUnit', 'setExperiments', 'addExperiment', 'removeExperiment'): for clazz in ('ccp.nmr.Nmr.ChemShiftConstraintList', 'ccp.nmr.Nmr.DihedralConstraintList', 'ccp.nmr.Nmr.DistanceConstraintList', 'ccp.nmr.Nmr.HBondConstraintList', 'ccp.nmr.Nmr.JCouplingConstraintList', 'ccp.nmr.Nmr.RdcConstraintList'): self.registerNotify(self.updateAfter, clazz, func) for func in ( '__init__', 'delete', ): for clazz in ('ccp.nmr.Nmr.ChemShiftConstraint', 'ccp.nmr.Nmr.DihedralConstraint', 'ccp.nmr.Nmr.DistanceConstraint', 'ccp.nmr.Nmr.HBondConstraint', 'ccp.nmr.Nmr.JCouplingConstraint', 'ccp.nmr.Nmr.RdcConstraint'): self.registerNotify(self.updateAfter, clazz, func) for func in ('__init__', 'delete', 'setChainStates', 'addChainState', 'removeChainState', 'addEntry', 'removeEntry', 'setResStructures', 'addResStructure', 'setEntries', 'removeResStructure', 'setStructures', 'addStructure', 'removeStructure'): self.registerNotify(self.updateAfter, 'ccp.nmr.Nmr.StructureGeneration', func) for func in ('__init__', 'delete', 'setDetails'): for clazz in ('ccp.nmr.Nmr.ViolationList', ): self.registerNotify(self.updateAfter, clazz, func) for func in ( '__init__', 'delete', ): for clazz in ('ccp.nmr.Nmr.Violation', ): self.registerNotify(self.updateAfter, clazz, func)
def body(self): '''Describes the body of this tab. It consists out of a number of radio buttons, check buttons and number entries that allow the user to indicate which assignments should be transferred. ''' # self.frame.expandColumn(0) self.frame.expandGrid(8, 0) self.frame.expandGrid(8, 1) typeOfAssignmentFrame = LabelFrame(self.frame, text='type of assignment') typeOfAssignmentFrame.grid(row=0, column=0, sticky='nesw') # typeOfAssignmentFrame.expandGrid(0,5) peakSelectionFrame = LabelFrame(self.frame, text='which peaks to assign') peakSelectionFrame.grid(row=0, column=1, sticky='nesw', rowspan=2) spinSystemSelectionFrame = LabelFrame(self.frame, text='Which spin-systems to use') spinSystemSelectionFrame.grid(row=2, column=0, sticky='nesw') tipText = 'What to do when a residue has already a spin system assigned to it.' assignedResidueFrame = LabelFrame( self.frame, text='if residue already has spin-system', tipText=tipText) assignedResidueFrame.grid(row=2, column=1, sticky='nesw') spectrumSelectionFrame = LabelFrame(self.frame, text='spectra') spectrumSelectionFrame.grid(row=1, column=0, sticky='nesw') row = 0 Label(typeOfAssignmentFrame, text='Resonances to Peak Dimensions', grid=(row, 0)) self.peaksCheckButton = CheckButton(typeOfAssignmentFrame, selected=True, grid=(row, 1)) row += 1 Label(typeOfAssignmentFrame, text='SpinSystems to Residues', grid=(row, 0)) self.residuesCheckButton = CheckButton(typeOfAssignmentFrame, selected=True, grid=(row, 1)) row = 0 Label(peakSelectionFrame, text='Intra-Residual', grid=(row, 0)) self.intraCheckButton = CheckButton(peakSelectionFrame, selected=True, grid=(row, 1)) row += 1 Label(peakSelectionFrame, text='Sequential', grid=(row, 0)) self.sequentialCheckButton = CheckButton(peakSelectionFrame, selected=True, grid=(row, 1)) row += 1 Label(peakSelectionFrame, text='Do not assign diagonal peaks', grid=(row, 0)) self.noDiagonalCheckButton = CheckButton(peakSelectionFrame, selected=True, grid=(row, 1)) entries = [ 'Only assigned spin systems', 'All that have a score of at least: ', 'User Defined', 'Solution number:' ] tipTexts = [ 'Only assign resonances of spin systems that already have a sequential assignment for the assignment of peak dimensions. Spin system to residue assignment is not relevant in this case.', 'Assign all spin systems that have a score of at least a given percentage. 50% or lower is not possible, because than spin systems might have to be assigned to more than 1 residue, which is impossible.', "As defined in the lower row of buttons in the 'results' tab.", 'One of the single solutions of the annealing.' ] self.spinSystemTypeSelect = RadioButtons(spinSystemSelectionFrame, entries=entries, grid=(0, 0), select_callback=None, direction=VERTICAL, gridSpan=(4, 1), tipTexts=tipTexts) tipText = 'The minimal amount of colabelling the different nuclei should have in order to still give rise to a peak.' self.minScoreEntry = FloatEntry(spinSystemSelectionFrame, grid=(1, 1), width=7, text=str(self.minScore), returnCallback=self.changeMinScore, tipText=tipText) self.minScoreEntry.bind('<Leave>', self.changeMinScore, '+') self.solutionNumberEntry = IntEntry(spinSystemSelectionFrame, grid=(3, 1), width=7, text=1, returnCallback=self.solutionUpdate, tipText=tipText) self.solutionNumberEntry.bind('<Leave>', self.solutionUpdate, '+') #self.solutionPullDown = PulldownList(spinSystemSelectionFrame, None, grid=(3,1), sticky='w') entries = ['all spectra', 'only:'] tipTexts = [ 'Assign peaks in all the spectra that where selected before the annealing ran.', 'Only assign peaks in one particular spectrum. You can of course repeat this multiple times for different spectra.' ] self.spectrumSelect = RadioButtons(spectrumSelectionFrame, entries=entries, grid=(0, 0), select_callback=None, direction=VERTICAL, gridSpan=(2, 1), tipTexts=tipTexts) self.spectraPullDown = PulldownList(spectrumSelectionFrame, self.changeSpectrum, grid=(1, 1), sticky='w') entries = [ 'skip this residue', 'de-assign old spin system from residue', 'assign, but never merge', 'warn to merge' ] tipTexts = [ "Don't assign the new spin system to the residue. The residue is not skipped when the old spin system does not contain any resonances", "De-assign old spin system from residue, unless the old spin system is a spin system without any resonances.", "Don't merge any spin systems, merging can be performed later if nescesary in the Resonance --> SpinSystems window.", "Ask to merge individually for each spin system, this might result in clicking on a lot of popups." ] self.assignedResidueStrategySelect = RadioButtons(assignedResidueFrame, entries=entries, grid=(0, 0), select_callback=None, direction=VERTICAL, gridSpan=(2, 1), tipTexts=tipTexts) texts = ['Transfer Assignments'] commands = [self.transferAssignments] self.transferButton = ButtonList(self.frame, commands=commands, texts=texts) self.transferButton.grid(row=5, column=0, sticky='nsew', columnspan=2)
def body(self, guiFrame): self.specFreqEntry = IntEntry(self, text=self.specFreq, width=8, returnCallback=self.setSpecFreq) self.maxIterEntry = IntEntry(self, text=self.maxIter, width=8, returnCallback=self.setMaxIter) self.mixTimeEntry = FloatEntry(self, text=self.mixTime, width=8, returnCallback=self.setMixTime) self.corrTimeEntry = FloatEntry(self, text=self.corrTime, width=8, returnCallback=self.setCorrTime) self.leakRateEntry = FloatEntry(self, text=self.leakRate, width=8, returnCallback=self.setLeakRate) guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(1, weight=1) row = 0 labelFrame0 = LabelFrame(guiFrame, text='Input data') labelFrame0.grid(row=row, column=0, sticky=Tkinter.NSEW) labelFrame0.grid_columnconfigure(3, weight=1) label = Label(labelFrame0, text='Assigned NOESY spectrum') label.grid(row=0, column=0, sticky=Tkinter.NW) self.noesyPulldown = PulldownMenu(labelFrame0, entries=self.getNoesys(), callback=self.setNoesy, selected_index=0, do_initial_callback=0) self.noesyPulldown.grid(row=0, column=1, sticky=Tkinter.NW) label = Label(labelFrame0, text='H/D ratio: ') label.grid(row=0, column=2, sticky=Tkinter.NW) self.ratioHDEntry = FloatEntry(labelFrame0, text=self.ratioHD, width=6) self.ratioHDEntry.grid(row=0, column=3, sticky=Tkinter.NW) label = Label(labelFrame0, text='NOESY spectrum 1:') label.grid(row=1, column=0, sticky=Tkinter.NW) self.tmix1Pulldown = PulldownMenu(labelFrame0, entries=self.getNoesys(), callback=self.setNoesy1, selected_index=-0, do_initial_callback=0) self.tmix1Pulldown.grid(row=1, column=1, sticky=Tkinter.NW) label = Label(labelFrame0, text='Tmix (ms): ') label.grid(row=1, column=2, sticky=Tkinter.NW) self.tmix1Entry = FloatEntry(labelFrame0, text=60, width=6) self.tmix1Entry.grid(row=1, column=3, sticky=Tkinter.NW) label = Label(labelFrame0, text='NOESY spectrum 2:') label.grid(row=2, column=0, sticky=Tkinter.NW) self.tmix2Pulldown = PulldownMenu(labelFrame0, entries=self.getNoesys(), callback=self.setNoesy2, selected_index=0, do_initial_callback=0) self.tmix2Pulldown.grid(row=2, column=1, sticky=Tkinter.NW) label = Label(labelFrame0, text='Tmix (ms): ') label.grid(row=2, column=2, sticky=Tkinter.NW) self.tmix2Entry = FloatEntry(labelFrame0, text=120, width=6) self.tmix2Entry.grid(row=2, column=3, sticky=Tkinter.NW) label = Label(labelFrame0, text='NOESY spectrum 3:') label.grid(row=3, column=0, sticky=Tkinter.NW) self.tmix3Pulldown = PulldownMenu(labelFrame0, entries=self.getNoesys(), callback=self.setNoesy3, selected_index=0, do_initial_callback=0) self.tmix3Pulldown.grid(row=3, column=1, sticky=Tkinter.NW) label = Label(labelFrame0, text='Tmix (ms): ') label.grid(row=3, column=2, sticky=Tkinter.NW) self.tmix3Entry = FloatEntry(labelFrame0, text=200, width=6) self.tmix3Entry.grid(row=3, column=3, sticky=Tkinter.NW) label = Label(labelFrame0, text='3D NOESY:') label.grid(row=4, column=0, sticky=Tkinter.NW) self.noesy3dPulldown = PulldownMenu(labelFrame0, entries=self.getNoesys3d(), callback=self.setNoesy3d, selected_index=0, do_initial_callback=0) self.noesy3dPulldown.grid(row=4, column=1, sticky=Tkinter.NW) label10 = Label(labelFrame0, text='Num peaks:') label10.grid(row=5, column=0, sticky=Tkinter.NW) self.numPeaksLabel = Label(labelFrame0, text='0') self.numPeaksLabel.grid(row=5, column=1, sticky=Tkinter.NW) label11 = Label(labelFrame0, text='Num resonances:') label11.grid(row=5, column=2, sticky=Tkinter.NW) self.numResonancesLabel = Label(labelFrame0, text='0') self.numResonancesLabel.grid(row=5, column=3, sticky=Tkinter.NW) row += 1 labelFrame1 = LabelFrame(guiFrame, text='Parameters') labelFrame1.grid(row=row, column=0, sticky=Tkinter.NSEW) labelFrame1.grid_columnconfigure(3, weight=1) label = Label(labelFrame1, text='15N labelled sample:') label.grid(row=0, column=0, sticky=Tkinter.NW) self.nitrogenSelect = CheckButton(labelFrame1, callback=self.setNitrogenLabel) self.nitrogenSelect.grid(row=0, column=1, sticky=Tkinter.W) self.nitrogenSelect.set(1) label = Label(labelFrame1, text='13C labelled sample:') label.grid(row=0, column=2, sticky=Tkinter.NW) self.carbonSelect = CheckButton(labelFrame1, callback=self.setCarbonLabel) self.carbonSelect.grid(row=0, column=3, sticky=Tkinter.W) self.carbonSelect.set(0) labelFrame1.grid_rowconfigure(1, weight=1) data = [ self.specFreq, self.maxIter, self.mixTime, self.corrTime, self.leakRate ] colHeadings = [ 'Spectrometer\nfrequency', 'Max\niterations', 'Mixing\ntime (ms)', 'Correl.\ntime (ns)', 'Leak\nrate' ] editWidgets = [ self.specFreqEntry, self.maxIterEntry, self.mixTimeEntry, self.corrTimeEntry, self.leakRateEntry, ] editGetCallbacks = [ self.getSpecFreq, self.getMaxIter, self.getMixTime, self.getCorrTime, self.getLeakRate, ] editSetCallbacks = [ self.setSpecFreq, self.setMaxIter, self.setMixTime, self.setCorrTime, self.setLeakRate, ] self.midgeParamsMatrix = ScrolledMatrix( labelFrame1, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, maxRows=1, initialCols=5, headingList=colHeadings, callback=None, objectList=[ 'None', ], textMatrix=[ data, ]) self.midgeParamsMatrix.grid(row=1, column=0, columnspan=4, sticky=Tkinter.NSEW) label10 = Label(labelFrame1, text='Benchmark structure') label10.grid(row=2, column=0, sticky=Tkinter.NW) self.structurePulldown = PulldownMenu(labelFrame1, entries=self.getStructures(), callback=self.setStructure, selected_index=0, do_initial_callback=0) self.structurePulldown.grid(row=2, column=1, sticky=Tkinter.NW) label11 = Label(labelFrame1, text='ADC atom types:') label11.grid(row=2, column=2, sticky=Tkinter.NW) self.adcAtomsPulldown = PulldownMenu(labelFrame1, entries=self.getAdcAtomTypes(), callback=self.setAdcAtomTypes, selected_index=0, do_initial_callback=0) self.adcAtomsPulldown.grid(row=2, column=3, sticky=Tkinter.NW) row += 1 labelFrame2 = LabelFrame(guiFrame, text='Output') labelFrame2.grid(row=row, column=0, sticky=Tkinter.NSEW) labelFrame2.grid_columnconfigure(3, weight=1) label20 = Label(labelFrame2, text='Distance constraints:') label20.grid(row=0, column=0, sticky=Tkinter.NW) self.distConstrLabel = Label(labelFrame2, text='0') self.distConstrLabel.grid(row=0, column=1, sticky=Tkinter.NW) label21 = Label(labelFrame2, text='Anti-distance constraints:') label21.grid(row=0, column=2, sticky=Tkinter.NW) self.antiConstrLabel = Label(labelFrame2, text='0') self.antiConstrLabel.grid(row=0, column=3, sticky=Tkinter.NW) texts = [ 'Calculate distances', 'Show distance\nconstraints', 'Show anti-distance\nconstraints' ] commands = [ self.calculateDistances, self.showConstraints, self.showAntiConstraints ] self.midgeButtons = ButtonList(labelFrame2, expands=1, texts=texts, commands=commands) self.midgeButtons.grid(row=1, column=0, columnspan=4, sticky=Tkinter.NSEW) row += 1 self.bottomButtons = createDismissHelpButtonList(guiFrame, expands=0, help_url=None) self.bottomButtons.grid(row=row, column=0, columnspan=4, sticky=Tkinter.EW) self.getPeaks() self.getResonances() self.update() self.geometry('600x400')
def body(self, mainFrame): mainFrame.grid_columnconfigure(1, weight=1, minsize=100) mainFrame.config(borderwidth=5, relief='solid') row = 0 label = Label(mainFrame, text="Frame (with sub-widgets):") label.grid(row=row, column=0, sticky=Tkinter.E) frame = Frame(mainFrame, relief='raised', border=2, background='#8080D0') # Frame expands East-West frame.grid(row=row, column=1, sticky=Tkinter.EW) # Last column expands => Widgets pusted to the West frame.grid_columnconfigure(3, weight=1) # Label is within the sub frame label = Label(frame, text='label ') label.grid(row=0, column=0, sticky=Tkinter.W) entry = Entry(frame, text='Entry', returnCallback=self.showWarning) entry.grid(row=0, column=1, sticky=Tkinter.W) self.check = CheckButton(frame, text='Checkbutton', selected=True, callback=self.updateObjects) self.check.grid(row=0, column=2, sticky=Tkinter.W) # stick a button to the East wall button = Button(frame, text='Button', command=self.pressButton) button.grid(row=0, column=3, sticky=Tkinter.E) row += 1 label = Label(mainFrame, text="Text:") label.grid(row=row, column=0, sticky=Tkinter.E) self.textWindow = Text(mainFrame, text='Initial Text\n', width=60, height=5) self.textWindow.grid(row=row, column=1, sticky=Tkinter.NSEW) row += 1 label = Label(mainFrame, text="CheckButtons:") label.grid(row=row, column=0, sticky=Tkinter.E) entries = ['Alpha','Beta','Gamma','Delta'] selected = entries[2:] self.checkButtons = CheckButtons(mainFrame, entries, selected=selected,select_callback=self.changedCheckButtons) self.checkButtons.grid(row=row, column=1, sticky=Tkinter.W) row += 1 label = Label(mainFrame, text="PartitionedSelector:") label.grid(row=row, column=0, sticky=Tkinter.E) labels = ['Bool','Int','Float','String'] objects = [type(0),type(1),type(1.0),type('a')] selected = [type('a')] self.partitionedSelector= PartitionedSelector(mainFrame, labels=labels, objects=objects, colors = ['red','yellow','green','#000080'], callback=self.toggleSelector,selected=selected) self.partitionedSelector.grid(row=row, column=1, sticky=Tkinter.EW) row += 1 label = Label(mainFrame, text="PulldownMenu") label.grid(row=row, column=0, sticky=Tkinter.E) entries = ['Frodo','Pipin','Merry','Sam','Bill','Gandalf','Strider','Gimli','Legolas'] self.pulldownMenu = PulldownMenu(mainFrame, callback=self.selectPulldown, entries=entries, selected_index=2, do_initial_callback=False) self.pulldownMenu.grid(row=row, column=1, sticky=Tkinter.W) row += 1 label = Label(mainFrame, text="RadioButtons in a\nScrolledFrame.frame:") label.grid(row=row, column=0, sticky=Tkinter.EW) frame = ScrolledFrame(mainFrame, yscroll = False, doExtraConfig = True, width=100) frame.grid(row=row, column=1, sticky=Tkinter.EW) frame.grid_columnconfigure(0, weight=1) self.radioButtons = RadioButtons(frame.frame, entries=entries, select_callback=self.checkRadioButtons, selected_index=1, relief='groove') self.radioButtons.grid(row=0, column=0, sticky=Tkinter.W) row += 1 label = Label(mainFrame, text="LabelFrame with\nToggleLabels inside:") label.grid(row=row, column=0, sticky=Tkinter.E) labelFrame = LabelFrame(mainFrame, text='Frame Title') labelFrame.grid(row=row, column=1, sticky=Tkinter.NSEW) labelFrame.grid_rowconfigure(0, weight=1) labelFrame.grid_columnconfigure(3, weight=1) self.toggleLabel1 = ToggleLabel(labelFrame, text='ScrolledMatrix', callback=self.toggleFrame1) self.toggleLabel1.grid(row=0, column=0, sticky=Tkinter.W) self.toggleLabel1.arrowOn() self.toggleLabel2 = ToggleLabel(labelFrame, text='ScrolledGraph', callback=self.toggleFrame2) self.toggleLabel2.grid(row=0, column=1, sticky=Tkinter.W) self.toggleLabel3 = ToggleLabel(labelFrame, text='ScrolledCanvas', callback=self.toggleFrame3) self.toggleLabel3.grid(row=0, column=2, sticky=Tkinter.W) row += 1 mainFrame.grid_rowconfigure(row, weight=1) label = Label(mainFrame, text="changing/shrinking frames:") label.grid(row=row, column=0, sticky=Tkinter.E) self.toggleRow = row self.toggleFrame = Frame(mainFrame) self.toggleFrame.grid(row=row, column=1, sticky=Tkinter.NSEW) self.toggleFrame.grid_rowconfigure(0, weight=1) self.toggleFrame.grid_columnconfigure(0, weight=1) # option 1 self.intEntry = IntEntry(self, returnCallback = self.setNumber, width=8) self.multiWidget = MultiWidget(self, Entry, options=None, values=None, callback=self.setKeywords, minRows=3, maxRows=5) editWidgets = [None, None, self.intEntry, self.multiWidget] editGetCallbacks = [None, None, self.getNumber, self.getKeywords] editSetCallbacks = [None, None, self.setNumber, self.setKeywords] headingList = ['Name','Color','Number','Keywords'] self.scrolledMatrix = ScrolledMatrix(self.toggleFrame, headingList=headingList, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, callback=self.selectObject, multiSelect=False) self.scrolledMatrix.grid(row=0, column=0, sticky=Tkinter.NSEW) # option 2 self.scrolledGraph = ScrolledGraph(self.toggleFrame, width=400, height=300, symbolSize=5, symbols=['square','circle'], dataColors=['#000080','#800000'], lineWidths=[0,1] ) self.scrolledGraph.setZoom(1.3) dataSet1 = [[0,0],[1,1],[2,4],[3,9],[4,16],[5,25]] dataSet2 = [[0,0],[1,3],[2,6],[3,9],[4,12],[5,15]] self.scrolledGraph.update(dataSets=[dataSet1,dataSet2], xLabel = 'X axis label', yLabel = 'Y axis label', title = 'Main Title') self.scrolledGraph.draw() # option 3 self.scrolledCanvas = ScrolledCanvas(self.toggleFrame,relief = 'groove', borderwidth = 2, resizeCallback=None) canvas = self.scrolledCanvas.canvas font = 'Helvetica 10' box = canvas.create_rectangle(10,10,150,200, outline='grey', fill='grey90') line = canvas.create_line(0,0,200,200,fill='#800000', width=2) text = canvas.create_text(120,50, text='Text', font=font, fill='black') circle = canvas.create_oval(30,30,50,50,outline='#008000',fill='#404040',width=3) row += 1 label = Label(mainFrame, text="FloatEntry:") label.grid(row=row, column=0, sticky=Tkinter.E) self.floatEntry = FloatEntry(mainFrame, text=3.14159265, returnCallback=self.floatEntryReturn) self.floatEntry.grid(row=row, column=1, sticky=Tkinter.W) row += 1 label = Label(mainFrame, text="Scale:") label.grid(row=row, column=0, sticky=Tkinter.E) self.scale = Scale(mainFrame, from_=10, to=90, value=50, orient=Tkinter.HORIZONTAL) self.scale.grid(row=row, column=1, sticky=Tkinter.W) row += 1 label = Label(mainFrame, text="Value Ramp:") label.grid(row=row, column=0, sticky=Tkinter.E) self.valueRamp = ValueRamp(mainFrame, self.valueRampCallback, speed = 1.5, delay = 50) self.valueRamp.grid(row=row, column=1, sticky=Tkinter.W) row += 1 label = Label(mainFrame, text="ButtonList:") label.grid(row=row, column=0, sticky=Tkinter.E) texts = ['Select File','Close','Quit'] commands = [self.selectFile, self.close, self.quit] bottomButtons = ButtonList(mainFrame, texts=texts, commands=commands, expands=True) bottomButtons.grid(row=row, column=1, sticky=Tkinter.EW) self.protocol('WM_DELETE_WINDOW', self.quit)
def __init__(self, parent, dangleGui, project=None, *args, **kw): self.guiParent = parent self.dangleGui = dangleGui self.dangleDir = None self.dangleChain = None self.dangleResidue = None #self.outDir = OUTDIR self.row = None self.col = None self.project = project self.nmrProject = None self.colorScheme = 'red' self.chain = None self.shiftList = None self.dangleStore = False # Not None self.constraintSet = None self.ensemble = None Frame.__init__(self, parent=parent) self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(1, weight=1) row = 0 # TOP LEFT FRAME frame = LabelFrame(self, text='Options') frame.grid(row=row, column=0, sticky='nsew') frame.columnconfigure(5, weight=1) label = Label(frame, text='Chain') label.grid(row=0, column=0, sticky='w') self.chainPulldown = PulldownList( frame, callback=self.changeChain, tipText='Choose the molecular system chain to make predictions for' ) self.chainPulldown.grid(row=0, column=1, sticky='w') label = Label(frame, text='Shift List') label.grid(row=0, column=2, sticky='w') self.shiftListPulldown = PulldownList( frame, callback=self.changeShiftList, tipText='Select the shift list to take input chemical shifts from') self.shiftListPulldown.grid(row=0, column=3, sticky='w') label = Label(frame, text='Max No. of Islands:') label.grid(row=0, column=4, sticky='w') sizes = range(10) texts = [str(s) for s in sizes] + [ 'Do not reject', ] self.rejectPulldown = PulldownList( frame, texts=texts, objects=sizes + [ None, ], tipText= 'Select the maximum allowed number of disontinuous prediction islands' ) self.rejectPulldown.set(DEFAULT_MAX_ISLANDS) # Actual value not index self.rejectPulldown.grid(row=0, column=5, sticky='w') label = Label(frame, text='Dangle Run:') label.grid(row=1, column=0, sticky='w') self.dangleStorePulldown = PulldownList( frame, callback=self.changeDangleStore, tipText='Select a run number to store DANGLE results within') self.dangleStorePulldown.grid(row=1, column=1, sticky='w') label = Label(frame, text='Ensemble:') label.grid(row=1, column=2, sticky='w') self.ensemblePulldown = PulldownList( frame, callback=self.changeEnsemble, tipText= 'Select the structure ensemble for superimposition of angle values on the GLE plots' ) self.ensemblePulldown.grid(row=1, column=3, sticky='w') label = Label(frame, text='Restraint Set:') label.grid(row=1, column=4, sticky='w') self.constrSetPulldown = PulldownList( frame, callback=self.changeConstraintSet, tipText= 'Select the CCPN restraint set to store DANGLE dihedral angle restraints in' ) self.constrSetPulldown.grid(row=1, column=5, sticky='w') # TOP RIGHT FRAME outerFrame = Frame(self) outerFrame.grid(row=row, column=1, rowspan=2, sticky='nsew') outerFrame.rowconfigure(0, weight=1) outerFrame.columnconfigure(0, weight=1) frame = LabelFrame(outerFrame, text='Global Likelihood Estimates') frame.grid(row=0, column=0, sticky='nsew') frame.rowconfigure(1, weight=1) frame.columnconfigure(2, weight=1) self.prevPlot = ViewRamachandranFrame(frame, relief='sunken', defaultPlot=False, width=180, height=180, bgColor=self.cget('bg'), nullColor='#000000', titleText='Previous', xTicks=False, yTicks=False, xLabel='', yLabel='', showCoords=False) self.prevPlot.grid(row=0, column=0, sticky='nsew') self.prevPlot.getPlotColor = self.getPlotColor self.nextPlot = ViewRamachandranFrame(frame, relief='sunken', defaultPlot=False, width=180, height=180, bgColor=self.cget('bg'), nullColor='#000000', titleText='Next', xTicks=False, yTicks=False, xLabel='', yLabel='', showCoords=False) self.nextPlot.grid(row=0, column=1, sticky='nsew') self.nextPlot.getPlotColor = self.getPlotColor self.plot = ViewRamachandranFrame(frame, relief='sunken', defaultPlot=False, width=360, height=360, bgColor=self.cget('bg'), nullColor='#000000') self.plot.grid(row=1, column=0, columnspan=2, sticky='nsew') self.plot.selectColor = '#FFB0B0' self.plot.getPlotColor = self.getPlotColor # BOTTOM RIGHT FRAME frame = Frame(outerFrame) frame.grid(row=1, column=0, sticky='nsew') frame.rowconfigure(0, weight=1) frame.columnconfigure(0, weight=1) texts = ('Previous', ' Next ') commands = (self.showPrevious, self.showNext) tipTexts = [ 'Show GLE plot of angle predictions for previous residue in chain', 'Show GLE plot of angle predictions for next residue in chain' ] buttonList = ButtonList(frame, texts, commands, tipTexts=tipTexts) buttonList.grid(row=0, column=0, sticky='nsew') row += 1 # BOTTOM LEFT FRAME frame = LabelFrame(self, text='Dihedral Angle Predictions') frame.grid(row=row, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) self.floatEntry = FloatEntry(self, text='', returnCallback=self.setFloatEntry, width=10, formatPlaces=9) tipTexts = [ 'Residue number in chain', 'Residue type code', 'Number of high scoring discontinuous angle predictions', 'Predicted secondary structure code', 'Predicted phi dihedral angle (CO-N-CA-CO)', 'Predicted psi dihedral angle (N-CA-CO-N)', 'Upper bound of phi angle prediction', 'Lower bound of phi angle prediction', 'Upper bound of psi angle prediction', 'Lower bound of phi angle prediction', 'Chemical shifts used in prediction' ] headingList = [ 'Res\nNum', 'Res\nType', 'No. of\nIslands', 'SS', 'Phi', 'Psi', 'Phi\nUpper', 'Phi\nLower', 'Psi\nUpper', 'Psi\nLower', 'Chemical Shifts' ] editWidgets = [ None, None, None, None, self.floatEntry, self.floatEntry, self.floatEntry, self.floatEntry, self.floatEntry, self.floatEntry ] editGetCallbacks = [ None, None, None, None, self.getFloatEntry, self.getFloatEntry, self.getFloatEntry, self.getFloatEntry, self.getFloatEntry, self.getFloatEntry ] editSetCallbacks = [ None, None, None, None, self.setFloatEntry, self.setFloatEntry, self.setFloatEntry, self.setFloatEntry, self.setFloatEntry, self.setFloatEntry ] self.predictionMatrix = ScrolledMatrix( frame, headingList=headingList, multiSelect=True, callback=self.selectCell, tipTexts=tipTexts, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks) # doubleCallback=self.loadGLEs) self.predictionMatrix.grid(row=0, column=0, sticky='nsew') row += 1 tipTexts = [ 'Remove the predictions for the selected residues', 'Run the DANGLE method to predict dihedral angles and secondary structure', 'Delete the DANGLE results stored under the current run number', 'Store the angle predictions and bounds in a new CCPN dihedral angle restraint list', 'Store the secondary structure predictions in the CCPN project' ] texts = [ 'Clear\nSelected', 'Run Prediction!', 'Delete\nCurrent Run', 'Commit\nRestraints', 'Commit\nSecondary Structure' ] commands = [ self.clearSelected, self.runDangle, self.deleteRun, self.storeDihedralConstraints, self.storeSecondaryStructure ] self.buttonList = createDismissHelpButtonList( self, texts=texts, commands=commands, # dismiss_text='Quit', dismiss_cmd=self.dangleGui.quit, help_url=self.dangleGui.help_url, expands=True, tipTexts=tipTexts) self.buttonList.grid(row=row, column=0, columnspan=2, sticky='ew') self.buttonList.buttons[1].config(bg='#C0FFFF') self.updateProject(project) self.notify(dangleGui.registerNotify)
def body(self, guiFrame): self.geometry('700x500') guiFrame.expandGrid(1, 0) row = 0 # TOP LEFT FRAME frame = LabelFrame(guiFrame, text='Options') frame.grid(row=row, column=0, sticky='nsew') frame.columnconfigure(5, weight=1) label = Label(frame, text='Chain') label.grid(row=0, column=0, sticky='w') self.chainPulldown = PulldownList( frame, callback=self.changeChain, tipText='Choose the molecular system chain to make predictions for' ) self.chainPulldown.grid(row=0, column=1, sticky='w') label = Label(frame, text='Shift List') label.grid(row=0, column=2, sticky='w') self.shiftListPulldown = PulldownList( frame, callback=self.changeShiftList, tipText='Select the shift list to take input chemical shifts from') self.shiftListPulldown.grid(row=0, column=3, sticky='w') row += 1 # BOTTOM LEFT FRAME frame = LabelFrame(guiFrame, text='Secondary Structure Predictions') frame.grid(row=row, column=0, sticky='nsew') frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) tipTexts = ('Residue number in chain', 'Residue type code', 'Current stored secondary structure code', 'Predicted secondary structure code') + SEC_STRUC_TIPS headingList = ('Res\nNum', 'Res\nType', 'Current\nSS', 'Predicted\nSS') + SEC_STRUC_KEYS n = len(headingList) editWidgets = n * [None] editGetCallbacks = n * [None] editSetCallbacks = n * [None] self.predictionMatrix = ScrolledMatrix( frame, headingList=headingList, tipTexts=tipTexts, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks) self.predictionMatrix.grid(row=0, column=0, sticky='nsew') row += 1 tipTexts = [ 'Run the D2D method to predict secondary structure', 'Store the secondary structure predictions in the CCPN project' ] texts = [ 'Run D2D Prediction!', 'Commit Predicted\nSecondary Structure' ] commands = [self.runD2D, self.storeSecondaryStructure] self.buttonList = createDismissHelpButtonList(guiFrame, texts=texts, commands=commands, help_url=self.help_url, expands=True, tipTexts=tipTexts) self.buttonList.grid(row=row, column=0, columnspan=2, sticky='ew') self.update() self.notify(self.registerNotify)
def body(self, guiFrame): self.mdInitTempEntry = FloatEntry(self, text='', returnCallback=self.setMdInitTemp) self.mdFinTempEntry = FloatEntry(self, text='', returnCallback=self.setMdFinTemp) self.mdCoolStepsEntry = IntEntry(self, text='', returnCallback=self.setMdCoolSteps) self.mdSimStepsEntry = IntEntry(self, text='', returnCallback=self.setMdSimSteps) self.mdTauEntry = FloatEntry(self, text='', returnCallback=self.setMdTau) self.mdRepScaleEntry = FloatEntry(self, text='', returnCallback=self.setMdRepScale) guiFrame.grid_columnconfigure(0, weight=1) row = 0 guiFrame.grid_rowconfigure(row, weight=1) frame = LabelFrame(guiFrame, text='Input constraints') frame.grid(row=row, column=0, sticky=Tkinter.NSEW) frame.grid_columnconfigure(2, weight=1) srow = 0 label = Label(frame, text='Constraint set:') label.grid(row=srow, column=0, sticky=Tkinter.W) self.constraintSetPulldown = PulldownMenu( frame, callback=self.changeConstraintSet, selected_index=0, do_initial_callback=0) self.constraintSetPulldown.grid(row=srow, column=1, sticky=Tkinter.W) srow += 1 label = Label(frame, text='Dist constraint list 1:') label.grid(row=srow, column=0, sticky=Tkinter.W) self.distance1Pulldown = PulldownMenu( frame, callback=self.changeDistance1ConstraintList, selected_index=0, do_initial_callback=0) self.distance1Pulldown.grid(row=srow, column=1, sticky=Tkinter.W) self.numConstr1Label = Label(frame, text='Constraints: 0') self.numConstr1Label.grid(row=srow, column=2, sticky=Tkinter.W) srow += 1 label = Label(frame, text='Dist constraint list 2:') label.grid(row=srow, column=0, sticky=Tkinter.W) self.distance2Pulldown = PulldownMenu( frame, callback=self.changeDistance2ConstraintList, selected_index=0, do_initial_callback=0) self.distance2Pulldown.grid(row=srow, column=1, sticky=Tkinter.W) self.numConstr2Label = Label(frame, text='Constraints: 0') self.numConstr2Label.grid(row=srow, column=2, sticky=Tkinter.W) srow += 1 label = Label(frame, text='Dist constraint list 3:') label.grid(row=srow, column=0, sticky=Tkinter.W) self.distance3Pulldown = PulldownMenu( frame, callback=self.changeDistance3ConstraintList, selected_index=0, do_initial_callback=0) self.distance3Pulldown.grid(row=srow, column=1, sticky=Tkinter.W) self.numConstr3Label = Label(frame, text='Constraints: 0') self.numConstr3Label.grid(row=srow, column=2, sticky=Tkinter.W) srow += 1 label = Label(frame, text='Dist constraint list 4:') label.grid(row=srow, column=0, sticky=Tkinter.W) self.distance4Pulldown = PulldownMenu( frame, callback=self.changeDistance4ConstraintList, selected_index=0, do_initial_callback=0) self.distance4Pulldown.grid(row=srow, column=1, sticky=Tkinter.W) self.numConstr4Label = Label(frame, text='Constraints: 0') self.numConstr4Label.grid(row=srow, column=2, sticky=Tkinter.W) row += 1 frame0 = LabelFrame(guiFrame, text='Cooling scheme') frame0.grid(row=row, column=0, sticky=Tkinter.NSEW) frame0.grid_columnconfigure(1, weight=1) f0row = 0 frame0.grid_rowconfigure(f0row, weight=1) colHeadings = [ 'Step', 'Initial\nTemp.', 'Final\nTemp.', 'Cooling\nSteps', 'MD Steps', 'MD Tau', 'Rep.\nScale' ] editWidgets = [ None, self.mdInitTempEntry, self.mdFinTempEntry, self.mdCoolStepsEntry, self.mdSimStepsEntry, self.mdTauEntry, self.mdRepScaleEntry ] editGetCallbacks = [ None, self.getMdInitTemp, self.getMdFinTemp, self.getMdCoolSteps, self.getMdSimSteps, self.getMdTau, self.getMdRepScale ] editSetCallbacks = [ None, self.setMdInitTemp, self.setMdFinTemp, self.setMdCoolSteps, self.setMdSimSteps, self.setMdTau, self.setMdRepScale ] self.coolingSchemeMatrix = ScrolledMatrix( frame0, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, maxRows=9, initialRows=12, headingList=colHeadings, callback=self.selectCoolingStep, objectList=self.coolingScheme, textMatrix=self.coolingScheme) self.coolingSchemeMatrix.grid(row=f0row, column=0, columnspan=4, sticky=Tkinter.NSEW) f0row += 1 texts = ['Move earlier', 'Move later', 'Add step', 'Remove step'] commands = [ self.moveStepEarlier, self.moveStepLater, self.addCoolingStep, self.removeCoolingStep ] self.coolingSchemeButtons = ButtonList(frame0, expands=1, commands=commands, texts=texts) self.coolingSchemeButtons.grid(row=f0row, column=0, columnspan=4, sticky=Tkinter.EW) row += 1 guiFrame.grid_rowconfigure(row, weight=1) frame1 = LabelFrame(guiFrame, text='Dynamics control') frame1.grid(row=row, column=0, sticky=Tkinter.NSEW) frame1.grid_columnconfigure(1, weight=1) f1row = 0 label20 = Label(frame1, text='Number of clouds:') label20.grid(row=f1row, column=0, sticky=Tkinter.NW) self.numCloudsEntry = IntEntry(frame1, text=1, returnCallback=self.setNumClouds, width=10) self.numCloudsEntry.grid(row=f1row, column=1, sticky=Tkinter.NW) label21 = Label(frame1, text='Cloud file prefix:') label21.grid(row=f1row, column=2, sticky=Tkinter.NW) self.filePrefixEntry = Entry(frame1, text='t_intra_', returnCallback=self.setFilePrefix, width=10) self.filePrefixEntry.grid(row=f1row, column=3, sticky=Tkinter.NW) f1row += 1 texts = ['Start molecular dynamics', 'Show dynamics progress'] commands = [self.startMd, self.showMdProgress] self.mdButtons = ButtonList(frame1, expands=1, commands=commands, texts=texts) self.mdButtons.grid(row=f1row, column=0, columnspan=4, sticky=Tkinter.NSEW) row += 1 self.bottomButtons = createDismissHelpButtonList(guiFrame, expands=0, help_url=None) self.bottomButtons.grid(row=row, column=0, sticky=Tkinter.EW) self.update() for func in ('__init__', 'delete', 'setName'): for clazz in ('ccp.nmr.NmrConstraint.DistanceConstraintList', ): Implementation.registerNotify(self.updateConstraintLists, clazz, func) for func in ('__init__', 'delete'): Implementation.registerNotify( self.updateConstraintSets, 'ccp.nmr.NmrConstraint.NmrConstraintStore', func)