Esempio n. 1
0
    def body(self, guiFrame):

        self.geometry('600x250+600+250')

        analysisProfile = self.analysisProfile
        userName = analysisProfile.userName
        userOrganisation = analysisProfile.userOrganisation
        userEmail = analysisProfile.userEmail

        guiFrame.grid_rowconfigure(0, weight=1)
        guiFrame.grid_columnconfigure(1, weight=1)

        explainText = 'To keep track of our users and which versions are being used\n' \
                          'we would like you to register your details with us.\n' \
                    'Collating the number of users is important for grant applications.\n' \
                    'Please do not use accents in any of the information\n' \
                    'because Python does not handle it gracefully.'
        row = 0
        label = Label(guiFrame,
                      text=explainText,
                      grid=(row, 0),
                      gridSpan=(1, 2),
                      sticky='ew')
        row += 1

        licenseAgreeText = 'I agree to abide by the rules of the CCPN licensing agreement.'

        self.agreeButton = CheckButton(guiFrame,
                                       licenseAgreeText,
                                       tipText=licenseAgreeText)
        self.agreeButton.grid(row=row, column=1, columnspan=1, sticky='nsew')

        row += 1

        self.entryWidgets = []
        for (text, value) in (('Name', userName),
                              ('Organisation', userOrganisation), ('Email',
                                                                   userEmail)):
            label = Label(guiFrame, text=text + ':', grid=(row, 0))
            entry = Entry(guiFrame,
                          text=value or '',
                          grid=(row, 1),
                          sticky='ew',
                          tipText='Your ' + text)
            self.entryWidgets.append(entry)
            row += 1

        texts = ['Register Now', 'Read License', 'Register Later']
        tipTexts = ['Register now', 'Read License', 'Register later']
        commands = [self.register, self.openLicense, self.close]
        buttons = UtilityButtonList(guiFrame,
                                    helpUrl=self.help_url,
                                    grid=(row, 0),
                                    gridSpan=(1, 2),
                                    commands=commands,
                                    texts=texts,
                                    tipTexts=tipTexts)
        self.buttons = buttons
Esempio n. 2
0
  def body(self, master):
      
    #
    # Popup window
    #
    
    self.widgets = []

    row = 0
    label = Label(master, text= "ChemComp formula '%s'" % self.formula)
    label.grid(row=row, column=0, columnspan = 2, sticky=Tkinter.EW)
      
    row = row + 1
    label = Label(master, text= "Number of bonds: %d" % self.bondNumber)
    label.grid(row=row, column=0, columnspan = 2, sticky=Tkinter.EW)
    
    #
    # Show relevant attributes...
    #
    
    for chemCompAttrInfo in self.chemCompInfo:
    
      row = row + 1
      
      attrName = chemCompAttrInfo[0]

      label = Label(master, text = attrName)
      label.grid(row=row, column=0, sticky=Tkinter.EW)     
      
      if attrName in self.nonEntryAttributes:
      
        widgetInfo = self.nonEntryAttributes[attrName]
        
        if widgetInfo[0] == PulldownMenu:
        
          self.widgets.append(PulldownMenu(master, entries = widgetInfo[1], selected_index = widgetInfo[1].index(chemCompAttrInfo[1])))

        elif widgetInfo[0] == CheckButton:

          self.widgets.append(CheckButton(master, selected = widgetInfo[1]))
      
      else:
      
        text = chemCompAttrInfo[1]
        if not text:
          text = ''

        self.widgets.append(Entry(master, text = text))
      
      self.widgets[-1].grid(row=row, column=1, sticky=Tkinter.EW)     

    row = row + 1
    texts = [ 'OK' ]
    commands = [ self.ok ]   # This calls 'ok' in BasePopup, this then calls 'apply' in here
    buttons = createHelpButtonList(master, texts=texts, commands=commands, help_url=self.help_url)
    buttons.grid(row=row, column=0, columnspan = 2)
Esempio n. 3
0
    def body(self, master):

        master.grid_columnconfigure(2, weight=1)

        row = 0
        label = Label(master, text='Data to export:')
        label.grid(row=row, column=0, columnspan=3, sticky=Tkinter.W)

        self.check_buttons = {}
        i = 0
        for heading in self.headings:
            row = row + 1
            isSelected = self.exportSelection.get(row, True)
            self.check_buttons[i] = c = CheckButton(
                master, selected=isSelected, callback=self.toggleCheckButton)
            c.grid(row=row, column=1)
            label = Label(master, text=heading)
            label.grid(row=row, column=2, sticky=Tkinter.W)
            i += 1

        row = row + 1
        button = Button(master, text='File:', command=self.findFile)
        button.grid(row=row, column=0, sticky=Tkinter.W)
        self.file_entry = Entry(master, text=self.file, width=30)
        self.file_entry.grid(row=row,
                             column=1,
                             columnspan=2,
                             sticky=Tkinter.EW)

        row = row + 1
        label = Label(master, text='Format:')
        label.grid(row=row, column=0, sticky=Tkinter.W)
        self.format_menu = PulldownMenu(master, entries=exportFormats)
        self.format_menu.grid(row=row,
                              column=1,
                              columnspan=2,
                              sticky=Tkinter.W)

        row = row + 1
        master.grid_rowconfigure(row, weight=1)
        texts = ['Save']
        commands = [self.ok]
        buttons = createDismissHelpButtonList(master,
                                              texts=texts,
                                              commands=commands,
                                              dismiss_text='Cancel')
        buttons.grid(row=row, column=0, columnspan=3, sticky=Tkinter.EW)
Esempio n. 4
0
    def body(self, master):

        master.grid_columnconfigure(0, weight=1)
        master.grid_columnconfigure(1, weight=1)

        self.geometry('600x400')

        #
        # Popup window
        #

        row = 0
        label = Label(master, text="Residue type '%s'" % self.ccpCode)
        label.grid(row=row, column=0, sticky=Tkinter.EW)

        row = row + 1
        label = Label(
            master,
            text=
            "Please select resonances that belong together (remaining ones are also grouped)"
        )
        label.grid(row=row, column=0, sticky=Tkinter.EW)

        for resName in self.resonanceNameList:

            row = row + 1

            label = Label(master, text="Resonance '%s'" % resName)
            label.grid(row=row, column=0, sticky=Tkinter.EW)

            self.checkButtons.append(CheckButton(master))
            self.checkButtons[-1].grid(row=row, column=1, sticky=Tkinter.EW)

        row = row + 1
        texts = ['OK']
        commands = [
            self.ok
        ]  # This calls 'ok' in BasePopup, this then calls 'apply' in here
        buttons = createHelpButtonList(master,
                                       texts=texts,
                                       commands=commands,
                                       help_url=self.help_url)
        buttons.grid(row=row, column=0)

        for i in range(row):
            master.grid_rowconfigure(i, weight=1)
Esempio n. 5
0
    def __init__(self,
                 parent,
                 residue=None,
                 resizeCallback=None,
                 project=None,
                 tipText=None,
                 shiftList=None,
                 *args,
                 **kw):

        self.shiftList = shiftList

        Frame.__init__(self, parent, *args, **kw)

        self.grid_columnconfigure(2, weight=1)

        row = 0
        self.label = Label(self, text='', grid=(row, 0))

        self.assignSelect = CheckButton(
            self,
            callback=self.setDisplayAssign,
            grid=(row, 1),
            tipText='Whether to show chemical shifts of assigned atoms')

        label0 = Label(self, text='Show Assignments', grid=(row, 2))

        row += 1
        self.grid_rowconfigure(row, weight=1)
        self.varFrame = ViewChemCompVarFrame(self,
                                             chemCompVar=self.chemCompVar,
                                             project=project,
                                             tipText=tipText,
                                             grid=(row, 0),
                                             gridSpan=(1, 3))

        self.assignSelect.set(True)
Esempio n. 6
0
    def body(self, master):

        #
        # Peaklist setup
        #

        self.peakListDict = {}

        for experiment in self.project.currentNmrProject.sortedExperiments():
            for dataSource in experiment.sortedDataSources():
                for peakList in dataSource.sortedPeakLists():

                    peakListLabel = "%s:%s:%d:%s" % (
                        experiment.name, dataSource.name, peakList.serial,
                        peakList.name)

                    self.peakListDict[peakListLabel] = peakList

        peakListLabels = self.peakListDict.keys()
        peakListLabels.sort()

        #
        # chemical shift list setup
        #

        self.shiftListDict = {}
        self.shiftListDict['None'] = None

        for shiftList in self.project.currentNmrProject.findAllMeasurementLists(
                className='ShiftList'):

            shiftListLabel = "%d:%s" % (shiftList.serial, shiftList.name)

            self.shiftListDict[shiftListLabel] = shiftList

        shiftListLabels = self.shiftListDict.keys()
        shiftListLabels.sort()

        row = 0

        label = Label(master, text="Generation of chemical shift list")
        label.grid(row=row, column=0, columnspan=2, sticky=Tkinter.W)

        row += 1

        label = Label(master, text="Peak lists:")
        label.grid(row=row, column=0, sticky=Tkinter.W)

        self.peakListBox = ScrolledListbox(master,
                                           width=50,
                                           height=5,
                                           selectmode=Tkinter.MULTIPLE,
                                           initial_list=peakListLabels)
        self.peakListBox.grid(row=row, column=1, sticky=Tkinter.EW)

        row += 1

        label = Label(master, text="Use existing shift list:")
        label.grid(row=row, column=0, sticky=Tkinter.W)

        self.shiftListSelect = PulldownMenu(master, entries=shiftListLabels)
        self.shiftListSelect.grid(row=row, column=1, sticky=Tkinter.EW)

        row += 1

        label = Label(master, text="Use multiple assignments:")
        label.grid(row=row, column=0, sticky=Tkinter.W)

        self.useAllContribs = CheckButton(master)
        self.useAllContribs.grid(row=row, column=1, sticky=Tkinter.W)

        #
        # Setup the default shift error per nucleus
        #

        self.defaultShiftError = {}

        for (nucl, text, defValue) in [('1H', 'proton', '0.002'),
                                       ('13C', 'carbon', '0.1'),
                                       ('15N', 'nitrogen', '0.1')]:

            row += 1

            label = Label(master, text="Default %s shift error:" % text)
            label.grid(row=row, column=0, sticky=Tkinter.W)

            self.defaultShiftError[nucl] = Entry(master, text=defValue)
            self.defaultShiftError[nucl].grid(row=row,
                                              column=1,
                                              sticky=Tkinter.W)

        row += 1

        texts = ['Create shift list']
        commands = [
            self.ok
        ]  # This calls 'ok' in BasePopup, this then calls 'apply' in here
        buttons = createDismissHelpButtonList(master,
                                              texts=texts,
                                              commands=commands,
                                              help_url=self.help_url)
        buttons.grid(row=row, columnspan=2, column=0)
Esempio n. 7
0
    def __init__(self,
                 parent,
                 entries,
                 select_callback=None,
                 selected=None,
                 direction=Tkinter.HORIZONTAL,
                 docKeys=None,
                 tipTexts=None,
                 *args,
                 **kw):

        if tipTexts and (len(tipTexts) == 1):
            # for length 1 tooltips just put on frame, rather than individual checkButtons
            tipText = tipTexts[0]
            if docKeys:
                docKey = docKeys[0]
            else:
                docKey = None
            tipTexts = None
            docKeys = None
        else:
            tipText = None
            docKey = None

        Frame.__init__(self,
                       parent,
                       docKey=docKey,
                       tipText=tipText,
                       createToolTip=True,
                       *args,
                       **kw)

        self.entries = entries
        self.select_callback = select_callback
        self.buttons = []

        if selected is None:
            selected = [False] * len(entries)

        nentries = len(entries)
        if not docKeys:
            docKeys = [None] * nentries

        if not tipTexts:
            tipTexts = [None] * nentries

        for n, entry in enumerate(entries):

            if select_callback:
                callback = self.doCallback
            else:
                callback = None

            b = CheckButton(self,
                            text=str(entry),
                            callback=callback,
                            docKey=docKeys[n],
                            tipText=tipTexts[n],
                            selected=selected[n])

            if direction == Tkinter.HORIZONTAL:
                b.grid(row=0, column=n, sticky='nw')
            else:
                b.grid(row=n, sticky='nw')

            self.buttons.append(b)
Esempio n. 8
0
    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)
Esempio n. 9
0
    def body(self, guiFrame):

        fixedSpectrum = self.fixedPeak.peakList.dataSource
        moveSpectrum = self.movePeak.peakList.dataSource

        guiFrame.grid_columnconfigure(0, weight=1)

        row = 0
        frame = LabelFrame(guiFrame,
                           text='Working Spectra',
                           grid=(row, 0),
                           sticky='ew')
        frame.grid_columnconfigure(1, weight=1)

        s = '%s:%-20s' % (fixedSpectrum.experiment.name, fixedSpectrum.name)

        Label(frame, text='Fixed:', grid=(0, 0), sticky='e')
        tipText = 'The experiment:spectrum name of the reference spectrum, which will not be moved'
        Label(frame, text=s, grid=(0, 1), tipText=tipText)

        s = '%s:%-20s' % (moveSpectrum.experiment.name, moveSpectrum.name)

        Label(frame, text='Moving:', grid=(0, 2), sticky='e')
        tipText = 'The experiment:spectrum name of the spectrum which will be re-referenced using peak positions'
        Label(frame, text=s, grid=(0, 3), tipText=tipText)

        row += 1
        guiFrame.grid_rowconfigure(row, weight=1)
        frame = LabelFrame(guiFrame,
                           text='Peak Position Mapping',
                           grid=(row, 0))
        frame.expandGrid(0, 0)

        tipText = 'Whether the more than one moving spectrum dimension may be mapped to the same fixed spectrum dimension; typically not used but can be useful for re-referencing with a diagonal peak'
        self.fixedDimsButton = CheckButton(
            frame,
            text='Allow repeated fixed dim',
            selected=False,
            grid=(0, 0),
            callback=self.changedFixedDimsButton,
            tipText=tipText)

        self.dimPulldown = PulldownList(self, callback=self.setDimMapping)

        editWidgets = [None, None, self.dimPulldown, None, None, None]
        editGetCallbacks = [None, None, self.getDimMapping, None, None, None]
        editSetCallbacks = [None, None, self.setDimMapping, None, None, None]

        tipTexts = [
            'The dimension number of the spectrum being re-referenced',
            'The isotope type that corresponds to both the fixed and re-reference spectrum dimensions',
            'The dimension number of the fixed spectrum, used as a reference',
            'The position of the moving peak in the relevant dimension, before any changes (for the spectrum being re-referenced)',
            'The position of the fixed peak in the relevant dimension; potential new position of the moving peak after re-referencing changes',
            'The chemical shift difference between the two peak positions on one dimension'
        ]
        headingList = [
            'Moving\nDim', 'Isotope', 'Fixed\nDim', 'Original\nPosition',
            'New\nPosition', u'\u0394'
        ]
        self.scrolledMatrix = ScrolledMatrix(frame,
                                             headingList=headingList,
                                             callback=self.selectPeakDim,
                                             editWidgets=editWidgets,
                                             maxRows=5,
                                             editSetCallbacks=editSetCallbacks,
                                             editGetCallbacks=editGetCallbacks,
                                             grid=(1, 0),
                                             tipTexts=tipTexts)

        row += 1
        tipTexts = [
            'Use the stated mapping of dimensions to re-reference the moving spectrum so that the selected peaks lie at the same position',
        ]
        texts = ['Commit']
        commands = [self.ok]
        buttons = UtilityButtonList(guiFrame,
                                    texts=texts,
                                    commands=commands,
                                    closeText='Cancel',
                                    helpUrl=self.help_url,
                                    grid=(row, 0),
                                    tipTexts=tipTexts)

        self.update()
Esempio n. 10
0
    def setupProchiralList(self, listIndex, chainLabel):

        chain = self.resParentChainLabelDict[self.resParent][chainLabel]
        self.chain = chain

        self.prochiralListFrame.destroy()
        self.prochiralListFrame = ScrolledFrame(self.prochiralListFrameMaster,
                                                width=200,
                                                doExtraConfig=False)
        self.prochiralListFrame.grid(row=self.prochiralListFrameRow,
                                     column=0,
                                     columnspan=2,
                                     sticky=Tkinter.NSEW)

        #
        # TODO: also handle case one resonance, two atomSets!?!?
        #

        frameRow = 0
        x = y = 0

        frame = self.prochiralListFrame.frame

        self.resonanceObjects = {}
        self.resonanceLabelDict = {}

        #
        # Reuse previous settings...
        #

        if len(self.chainResonancesDict[self.resParent][chain]) == len(
                self.chainAtomSetsDict[self.resParent][chain]):
            usePreviousSettings = True
        else:
            usePreviousSettings = False

        for i in range(0, len(self.chainAtomSetsDict[self.resParent][chain])):
            atomSetGroup = self.chainAtomSetsDict[self.resParent][chain][i]

            isStereo = False
            hasResonances = False
            isValidCase = False

            resonances = []

            if usePreviousSettings and self.chainResonancesDict[
                    self.resParent][chain][i]:

                resonances = self.chainResonancesDict[
                    self.resParent][chain][i][3]
                isStereo = self.chainResonancesDict[
                    self.resParent][chain][i][0]
                hasResonances = True
                isValidCase = True

            else:

                for atomSet in atomSetGroup:
                    resonanceSets = atomSet.sortedResonanceSets()

                    if resonanceSets:
                        hasResonances = True

                        for resonanceSet in resonanceSets:
                            for resonance in resonanceSet.sortedResonances():
                                if resonance not in resonances:
                                    resonances.append(resonance)

                        if len(resonanceSets) == 1:
                            isValidCase = True
                            if len(resonanceSet.atomSets) == 1:
                                isStereo = True

                    else:
                        # Case only one resonance but stereo assigned
                        resonances.append(0)

                if len(resonances) == 1:
                    # Case only one resonance, not stereo assigned
                    resonances.append(None)

            #
            # Set up only for valid cases
            #

            if hasResonances and isValidCase:

                if not usePreviousSettings:
                    self.chainResonancesDict[self.resParent][chain].append(
                        [isStereo, False, False, resonances])

                residue = atomSetGroup[0].findFirstAtom().residue
                ccpCode = residue.molResidue.ccpCode
                seqCode = residue.seqCode

                rowspan = 2

                checkButton = CheckButton(
                    frame,
                    selected=isStereo,
                    callback=lambda status=isStereo, fr=frameRow, item=i, setup
                    =False: self.toggleResonances(status, fr, item, setup))
                checkButton.grid(row=frameRow,
                                 rowspan=rowspan,
                                 column=0,
                                 sticky=Tkinter.EW)

                label = Label(frame, text=ccpCode, width=5)
                label.grid(row=frameRow,
                           rowspan=rowspan,
                           column=1,
                           sticky=Tkinter.E)
                label = Label(frame, text=str(seqCode), width=5)
                label.grid(row=frameRow,
                           rowspan=rowspan,
                           column=2,
                           sticky=Tkinter.W)

                #
                # Set up the atom names
                #

                for j in range(0, len(atomSetGroup)):
                    atomSet = atomSetGroup[j]
                    label = Label(frame, text=atomSet.name)
                    label.grid(row=frameRow + j,
                               column=3,
                               sticky=Tkinter.E,
                               ipadx=4)

                #
                # Set up the resonances
                #

                self.resonanceObjects[frameRow] = {
                    True: [[], []],
                    False: [[], []]
                }

                resonanceLabelList = []

                for resonance in resonances:

                    if not resonance:

                        resonanceLabel = 'unknown'

                    else:

                        if hasattr(resonance, 'shifts') and resonance.shifts:
                            shiftLabel = " (shifts: "

                            for shift in resonance.sortedShifts():
                                shiftLabel += "%.2f, " % shift.value

                            shiftLabel = shiftLabel[:-2] + ")"

                        else:
                            shiftLabel = ""

                        resonanceLabel = "'%d.%s'%s" % (
                            seqCode, resonance.name, shiftLabel)
                        self.resonanceLabelDict[resonanceLabel] = resonance

                    resonanceLabelList.append(resonanceLabel)

                separator = Separator(frame, height=1, width=30)
                separator.setColor('black', bgColor='black')
                separator.grid(row=frameRow, column=4, sticky=Tkinter.EW)
                self.resonanceObjects[frameRow][True][0].append(separator)

                separator = CrossLine(frame,
                                      height=20,
                                      width=30,
                                      canvas_bg=frame['bg'],
                                      color='dimgray')
                self.resonanceObjects[frameRow][False][0].append(separator)

                resonanceList = PulldownMenu(
                    frame,
                    entries=resonanceLabelList,
                    callback=lambda selInd=x, selItem=y, fr=frameRow, item=i:
                    self.setProchiralLabels(selInd, selItem, fr, item),
                    do_initial_callback=False,
                    label_color='red')
                resonanceList.grid(row=frameRow, column=5, sticky=Tkinter.EW)
                self.resonanceObjects[frameRow][True][0].append(resonanceList)

                resonanceLabel = Label(frame,
                                       text="%s" % resonanceLabelList[0],
                                       fg='dimgray')
                self.resonanceObjects[frameRow][False][0].append(
                    resonanceLabel)

                separator = Separator(frame, height=1, width=30)
                separator.setColor('black', bgColor='black')
                separator.grid(row=frameRow + 1, column=4)
                self.resonanceObjects[frameRow][True][1].append(separator)

                self.resonanceObjects[frameRow][False][1].append(None)

                resonanceLabel = Label(frame,
                                       text="%s" % resonanceLabelList[1],
                                       fg='red')
                resonanceLabel.grid(row=frameRow + 1,
                                    column=5,
                                    sticky=Tkinter.EW)
                self.resonanceObjects[frameRow][True][1].append(resonanceLabel)

                resonanceLabel = Label(frame,
                                       text="%s" % resonanceLabelList[1],
                                       fg='dimgray')
                self.resonanceObjects[frameRow][False][1].append(
                    resonanceLabel)

                if not isStereo:
                    checkButton.callback(isStereo, setup=True)

                separator = Separator(frame, height=1)
                separator.setColor('black', bgColor='black')
                separator.grid(row=frameRow + rowspan,
                               columnspan=6,
                               sticky=Tkinter.EW)

                frameRow += rowspan + 1

            elif not usePreviousSettings:
                self.chainResonancesDict[self.resParent][chain].append(None)

        return True
Esempio n. 11
0
  def body(self, guiFrame):

    self.geometry('600x350')

    project = self.project
    analysisProject = self.analysisProject

    guiFrame.grid_columnconfigure(1, weight=1)

    row = 0
    frame = Frame(guiFrame, grid=(0,0))
    label = Label(frame, text=' Window:', grid=(0,0))
    self.windowPulldown = PulldownList(frame, grid=(0,1),
                                      tipText='The window that will be printed out',
                                      callback=self.selectWindow)
                                      
    tipTexts = ['For the window pulldown, show all of the spectrum windows in the current project, irrespective of the active group',
                'For the window pulldown, show only spectrum windows that are in the currently active window group']
    self.whichWindows = RadioButtons(frame, grid=(0,2),
                                     entries=ACTIVE_OPTIONS, tipTexts=tipTexts,
                                     select_callback=self.updateWindows)
    
    texts = [ 'Save Print File' ]
    tipTexts = [ 'Save the printout to the specified file' ]
    commands = [ self.saveFile ]
    buttons = UtilityButtonList(guiFrame, helpUrl=self.help_url, grid=(row,2),
                                commands=commands, texts=texts, tipTexts=tipTexts)
    self.buttons = buttons
    buttons.buttons[0].config(bg='#B0FFB0')
    
    row += 1
    guiFrame.grid_rowconfigure(row, weight=1)
    options = ['Options', 'Spectra', 'Peak Lists', 'Region']
    tipTexts = ['Optional settings for spectra', 'Optional settings for peak lists', 'Optional settings for the region']
    tabbedFrame = TabbedFrame(guiFrame, options=options, tipTexts=tipTexts)
    tabbedFrame.grid(row=row, column=0, columnspan=3, sticky='nsew')
    self.tabbedFrame = tabbedFrame

    optionFrame, spectrumFrame, peakListFrame, regionFrame = tabbedFrame.frames

    optionFrame.expandGrid(0, 0)
    getOption = lambda key, defaultValue: PrintBasic.getPrintOption(analysisProject, key, defaultValue)
    setOption = lambda key, value: PrintBasic.setPrintOption(analysisProject, key, value)
    self.printFrame = PrintFrame(optionFrame, getOption=getOption,
                                 grid=(0,0), gridSpan=(1,1),
                                 setOption=setOption, haveTicks=True,
                                 doOutlineBox=False)

    spectrumFrame.expandGrid(0, 0)
    frame = Frame(spectrumFrame, grid=(0,0), gridSpan=(1,1))
    frame.expandGrid(1,0)

    self.overrideSpectrum = CheckButton(frame,
       text='Use below settings when printing',
       tipText='Use below settings when printing instead of the window values',
       grid=(0,0), sticky='w')

    tipText = 'Change the settings of the selected spectra back to their window values'
    button = Button(frame, text='Reset Selected', tipText=tipText,
                    command=self.resetSelected, grid=(0,1), sticky='e')

    self.posColorPulldown = PulldownList(self, callback=self.setPosColor)
    self.negColorPulldown = PulldownList(self, callback=self.setNegColor)
    headings = ['Spectrum', 'Pos. Contours\nDrawn', 'Neg. Contours\nDrawn', 'Positive\nColours', 'Negative\nColours']
    tipTexts = ['Spectrum in window', 'Whether the positive contours should be drawn', 'Whether the negative contours should be drawn',
      'Colour scheme for positive contours (can be a single colour)', 'Colour scheme for negative contours (can be a single colour)']

    editWidgets      = [ None, None, None, self.posColorPulldown, self.negColorPulldown]
    editGetCallbacks = [ None, self.togglePos, self.toggleNeg, self.getPosColor, self.getNegColor]
    editSetCallbacks = [ None, None, None, self.setPosColor, self.setNegColor]
    self.spectrumTable = ScrolledMatrix(frame, headingList=headings,
                                        tipTexts=tipTexts,
                                        multiSelect=True,
                                        editWidgets=editWidgets,
                                        editGetCallbacks=editGetCallbacks,
                                        editSetCallbacks=editSetCallbacks,
                                        grid=(1,0), gridSpan=(1,2))

    peakListFrame.expandGrid(0, 0)
    frame = Frame(peakListFrame, grid=(0,0), gridSpan=(1,3))
    frame.expandGrid(1,0)

    self.overridePeakList = CheckButton(frame,
       text='Use below settings when printing',
       tipText='Use below settings when printing instead of the window values',
       grid=(0,0))

    tipText = 'Change the settings of the selected peak lists back to their window values'
    button = Button(frame, text='Reset Selected', tipText=tipText,
                    command=self.resetSelected, grid=(0,1), sticky='e')

    colors = Color.standardColors
    self.peakColorPulldown = PulldownList(self, callback=self.setPeakColor,
                                        texts=[c.name for c in colors],
                                        objects=[c.hex for c in colors],
                                        colors=[c.hex for c in colors])
    headings = [ 'Peak List', 'Symbols Drawn', 'Peak Font', 'Peak Colour']
    self.fontMenu = FontList(self, mode='Print', extraTexts=[no_peak_text])
    editWidgets      = [ None, None, self.fontMenu, self.peakColorPulldown]
    editGetCallbacks = [ None, self.togglePeaks, self.getPeakFont, self.getPeakColor ]
    editSetCallbacks = [ None, None, self.setPeakFont, self.setPeakColor ]
    self.peakListTable = ScrolledMatrix(frame, headingList=headings,
                                        multiSelect=True,
                                        editWidgets=editWidgets,
                                        editGetCallbacks=editGetCallbacks,
                                        editSetCallbacks=editSetCallbacks,
                                        grid=(1,0), gridSpan=(1,2))

    regionFrame.expandGrid(0, 0)
    frame = Frame(regionFrame, grid=(0,0), gridSpan=(1,3))
    frame.expandGrid(3,0)
    tipText = 'Use the specified override region when printing rather than the window values'
    self.overrideButton = CheckButton(frame, text='Use override region when printing',
                                      tipText=tipText,
                                      callback=self.toggledOverride, grid=(0,0))

    tipTexts = ('Use min and max to specify override region', 'Use center and width to specify override region')
    self.use_entry = USE_ENTRIES[0]
    self.useButtons = RadioButtons(frame, entries=USE_ENTRIES,
                                      tipTexts=tipTexts,
                                      select_callback=self.changedUseEntry,
                                      grid=(1,0))

    texts = ('Set Region from Window', 'Set Center from Window', 'Set Width from Window')
    tipTexts = ('Set the override region to be the current window region',
                'Set the center of the override region to be the center of the current window region',
                'Set the width of the override region to be the width of the current window region')
    commands = (self.setRegionFromWindow, self.setCenterFromWindow, self.setWidthFromWindow)
    self.setRegionButton = ButtonList(frame, texts=texts,
                                      tipTexts=tipTexts,
                                      commands=commands, grid=(2,0))

    self.minRegionWidget = FloatEntry(self, returnCallback=self.setMinRegion, width=10)
    self.maxRegionWidget = FloatEntry(self, returnCallback=self.setMaxRegion, width=10)
    headings = MIN_MAX_HEADINGS
    editWidgets      = [ None, None, self.minRegionWidget, self.maxRegionWidget ]
    editGetCallbacks = [ None, None, self.getMinRegion,    self.getMaxRegion ]
    editSetCallbacks = [ None, None, self.setMinRegion,    self.setMaxRegion ]
    self.regionTable = RegionScrolledMatrix(frame, headingList=headings,
                                            editWidgets=editWidgets,
                                            editGetCallbacks=editGetCallbacks,
                                            editSetCallbacks=editSetCallbacks,
                                            grid=(3,0))

    self.updateWindows()
    self.updateAfter()
    
    self.administerNotifiers(self.registerNotify)
Esempio n. 12
0
  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)
Esempio n. 13
0
    def body(self, guiFrame):

        row = 0
        frame = Frame(guiFrame, grid=(row, 0))
        frame.expandGrid(None, 6)

        label = Label(frame, text='Chain:', grid=(0, 0))
        tipText = 'Selects which molecular chain to show residues and chemical shift values for'
        self.chainPulldown = PulldownList(frame,
                                          callback=self.changeChain,
                                          grid=(0, 1),
                                          tipText=tipText)

        label = Label(frame, text='  Shift List:', grid=(0, 2))
        tipText = 'Selects which shift list is used to derive the displayed chemical shift values'
        self.shiftListPulldown = PulldownList(frame,
                                              callback=self.changeShiftList,
                                              grid=(0, 3),
                                              tipText=tipText)

        label = Label(frame, text=' List all shifts:', grid=(0, 4))
        tipText = 'Sets whether to display all the chemical shifts for residues or just for the nominated atom types in columns'
        self.otherShiftsSelect = CheckButton(frame,
                                             callback=self.draw,
                                             grid=(0, 5),
                                             tipText=tipText)

        utilButtons = UtilityButtonList(frame,
                                        helpUrl=self.help_url,
                                        grid=(0, 7))

        row += 1
        frame = Frame(guiFrame, grid=(row, 0))
        frame.expandGrid(None, 6)

        label = Label(frame, text=' 1-letter codes:', grid=(0, 0))
        tipText = 'Whether to use 1-letter residue codes in the table, or otherwise Ccp/three-letter codes'
        self.oneLetterSelect = CheckButton(frame,
                                           callback=self.draw,
                                           grid=(0, 1),
                                           selected=False,
                                           tipText=tipText)

        precisions = [0.1, 0.01, 0.001]
        texts = [str(t) for t in precisions]
        label = Label(frame, text='  1H precision:', grid=(0, 2))
        tipText = 'Specifies how many decimal places to use when displaying 1H chemical shift values'
        self.protonPrecisionSelect = PulldownList(frame,
                                                  texts=texts,
                                                  objects=precisions,
                                                  callback=self.draw,
                                                  index=1,
                                                  grid=(0, 3),
                                                  tipText=tipText)

        label = Label(frame, text='  Other precision:')
        label.grid(row=0, column=4, sticky='w')
        tipText = 'Specifies how many decimal places to use when displaying chemical shift values for isotopes other than 1H'
        self.otherPrecisionSelect = PulldownList(frame,
                                                 texts=texts,
                                                 objects=precisions,
                                                 callback=self.draw,
                                                 index=1,
                                                 grid=(0, 5),
                                                 tipText=tipText)

        row += 1
        frame = Frame(guiFrame, grid=(row, 0))
        frame.expandGrid(None, 1)

        label = Label(frame, text='Column\nAtoms:', grid=(0, 0))
        tipText = 'Selects which kinds of atoms are displayed in aligned columns, or otherwise displayed at the end of the residue row (if "List all shifts" is set)'
        self.optSelector = PartitionedSelector(frame,
                                               self.toggleOpt,
                                               tipText=tipText,
                                               maxRowObjects=10,
                                               grid=(0, 1),
                                               sticky='ew')
        options = ['H', 'N', 'C', 'CA', 'CB', 'CG']
        self.optSelector.update(objects=options,
                                labels=options,
                                selected=['H', 'N', 'CA'])

        row += 1
        guiFrame.expandGrid(row, 0)
        self.canvasFrame = ScrolledCanvas(guiFrame,
                                          relief='groove',
                                          width=650,
                                          borderwidth=2,
                                          resizeCallback=None,
                                          grid=(row, 0),
                                          padx=1,
                                          pady=1)
        self.canvas = self.canvasFrame.canvas
        #self.canvas.bind('<Button-1>', self.toggleResidue)

        row += 1
        tipTexts = [
            'Output information from the table as PostScript file, for printing etc.',
            'Output information from the table as a whitespace separated plain text file'
        ]
        commands = [self.makePostScript, self.exportText]
        texts = ['Export PostScript', 'Export Text']
        buttonList = ButtonList(guiFrame,
                                commands=commands,
                                texts=texts,
                                grid=(row, 0),
                                tipTexts=tipTexts)

        chains = self.getChains()
        if len(chains) > 1:
            self.chain = chains[1]
        else:
            self.chain = None

        self.updateShiftLists()
        self.updateChains()
        self.otherShiftsSelect.set(True)
        self.update()

        for func in ('__init__', 'delete'):
            self.registerNotify(self.updateChains,
                                'ccp.molecule.MolSystem.Chain', func)
        for func in ('__init__', 'delete'):
            self.registerNotify(self.updateShiftLists, 'ccp.nmr.Nmr.ShiftList',
                                func)
Esempio n. 14
0
    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')
Esempio n. 15
0
    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)
Esempio n. 16
0
    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)
Esempio n. 17
0
  def __init__(self, parent, file_types = None, directory = None,
               single_callback = None, double_callback = None,
               prompt = None, show_file = True, file = '', multiSelect=False,
               default_dir = None, getRowColor = None,
               getExtraCell = None, extraHeadings = None, extraJustifies = None,
               displayExtra = True, *args, **kw):

    if file_types is None:
      file_types = [ FileType("All", ["*"]) ]

    if directory is None:
      directory = normalisePath(os.getcwd())

    if extraHeadings is None:
      extraHeadings = ()
    else:
      extraHeadings = tuple(extraHeadings)

    if extraJustifies is None:
      extraJustifies = ()
    else:
      extraJustifies = tuple(extraJustifies)

    if extraHeadings or extraJustifies:
      assert len(extraHeadings) == len(extraJustifies)
      assert getExtraCell

    self.extraHeadings = extraHeadings
    self.extraJustifies = extraJustifies
    self.displayExtra = displayExtra

    Frame.__init__(self, parent, *args, **kw)

    self.file_types = file_types
    self.fileType = file_types[0]
    self.single_callback = single_callback
    self.double_callback = double_callback
    self.show_file = show_file
    self.directory = None
    self.historyBack = []
    self.historyFwd = []
    self.determineDir(directory)
    self.default_dir = default_dir
    self.getRowColor = getRowColor
    self.getExtraCell = getExtraCell

    
    self.grid_columnconfigure(0, weight=1)

    row = 0
    if prompt:
      label = Label(self, text=prompt, grid=(row,0))
      row += 1

    self.grid_rowconfigure(row, weight=1)
    if show_file:
      headings = ('Name', 'Size', 'Date')
      justifies = ('left','right','right')
    else:
      headings = ('Directory',)
      justifies = ('left',)
    self.normalHeadings = headings
    self.normalJustifies = justifies
    headings = headings + extraHeadings
    justifies = justifies + extraJustifies

    self.fileList = ScrolledMatrix(self, headingList=headings, justifyList=justifies,
                                    initialRows=10, callback=self.singleCallback,
                                    doubleCallback=self.doubleCallback,
                                    multiSelect=multiSelect, grid=(row,0))

    row += 1
    texts = ['Back', 'Up', 'Forward', 'Top', 'Home', 'New', 'Refresh']
    commands = [self.backDir, self.fwdDir, self.upDir, self.topDir,
                self.homeDir, self.createDir, self.updateFileList ]

    if self.default_dir:
      texts.append('Default')
      commands.append(self.setDefaultDir)
      
    self.icons = []
    for name in ICON_NAMES:
      icon = Tkinter.PhotoImage(file=os.path.join(GFX_DIR,name+'.gif'))
      self.icons.append(icon)
      
    self.buttons = ButtonList(self, texts=texts, commands=commands,
                              images=self.icons, grid=(row,0))


    if show_file:
      row += 1
      self.file_entry = LabeledEntry(self, label='File name',
                              label_width=10, entry_width=40,
                              returnCallback=self.setSelectedFile)
      self.file_entry.grid(row=row, column=0, sticky=Tkinter.EW)
    else:
      self.file_entry = None

    row += 1
    self.directory_entry = LabeledEntry(self, label='Directory',
                                        entry = directory,
                                        label_width=10, entry_width=40,
                                        returnCallback=self.entryDir)
    self.directory_entry.grid(row=row, column=0, sticky=Tkinter.EW)


    row += 1
    subFrame = Frame(self, grid=(row,0))
    subFrame.expandGrid(None,6)

    if show_file:

      label = Label(subFrame, text='File type:', grid=(0,0))

      type_labels = self.determineTypeLabels()
      self.fileType_menu = PulldownList(subFrame, callback=self.typeCallback,
                                        texts=type_labels, objects=self.file_types,
                                        grid=(0,1))

    label = Label(subFrame, text=' Show hidden:', grid=(0,2))

    self.hidden_checkbutton = CheckButton(subFrame, text='', selected=False,
                                          callback=self.updateFileList, grid=(0,3))

    label = Label(subFrame, text='Dir path:', grid=(0,4))

    self.pathMenu = PulldownList(subFrame, callback=self.dirCallback,
                                 objects=range(len(self.dirs)),
                                 texts=self.dirs, index=len(self.dirs)-1,
                                 indent='  ', prefix=dirsep, grid=(0,5))

    self.updateFileList()
    self.updateButtons()

    if file:
      self.setFile(file)
Esempio n. 18
0
  def body(self, master):
    
    if not self.components:
      showError("Error","No valid %s implemented (yet)." % self.importExportFlag,master)
      self.close()
      
    # 
    # Set specific import/export info
    #

    if self.importExportFlag == 'import' and not self.component:
      self.checkButton = {}
    else:
      self.exportButton = {}

    #
    # Generic info
    #
    
    self.widgets = {}
    self.widgetInfo = {}

    row = -1
    
    for component in self.components:
      
      self.fileDefs = (component,self.format,self.selectFile,self.selectDir)
      normalWidgets = []
      toggleWidgets = []
      allWidgets =[]
      
      localWidgetCount = 0
      
      #
      # This is for handling rereferring text
      #
      
      if self.IOkeywords[component].has_key('showText'):
        
        row += 1
        
        label = Label(master, text = self.IOkeywords[component]['showText'])
        label.grid(row=row, column=0, columnspan = 3, sticky=Tkinter.EW)
        
        self.widgets[component] = None
        
        row = row + 1
        separator = Separator(master,height = 3)
        separator.setColor('black', bgColor = 'black')
        separator.grid(row=row, column=0, columnspan = 3, sticky=Tkinter.EW)

        continue

      #
      # Import ONLY!
      #
      
      if self.importExportFlag == 'import' and not self.component:
        row += 1
        
        label = Label(master, text = 'Import %s:' % component)
        label.grid(row=row, column=0, sticky=Tkinter.E)
      
        self.checkButton[component] = CheckButton(master) 
        self.checkButton[component].grid(row=row, column=1, sticky=Tkinter.W)
            
      toggleInfoLabelRow = None
      
      if self.importExportFlag == 'export':
        row += 1
        componentToggleRow = row
      else:
        componentToggleRow = None
        
      #row += 1

      for widgetIndex in range(0,len(self.widgetSetup[component])):

        widgetInfo = self.widgetSetup[component][widgetIndex]
        buttonKeyword = widgetInfo[1]

        (label,widget,selectionDict) = setIoInfo(master,widgetInfo,self.project,self.fileDefs)

        #
        # Make sure that widget info does not appear if no valid objects
        # available for mandatory information!!
        #

        if self.IOkeywords[component].has_key(widgetInfo[1]) and self.IOkeywords[component][widgetInfo[1]][1]:
          if not widget:
            if self.widgets.has_key(component):
              showError("Error","Could not set up export menu for %s: no '%s' information available." % (component,widgetInfo[3]),self)
              for (label,widget,infoButton) in normalWidgets + toggleWidgets:
                label.grid_forget()
                widget.grid_forget()
                infoButton.grid_forget()
                row -=1
                
              del(self.widgets[component])
            break

        #
        # This can fail (e.g. nothing available to make a list...)
        #

        if widget:
          if not self.widgets.has_key(component):
            self.widgets[component] = {}
            self.widgetInfo[component] = {}
          
          if localWidgetCount == self.toggleInfoIndex[component]:
            row += 1
            toggleInfoLabelRow = row
            allWidgets.append('TOGGLEWIDGET')

          self.widgets[component][buttonKeyword] = widget
          self.widgetInfo[component][buttonKeyword] = (widgetInfo,selectionDict)
          
          infoButton = Tkinter.Button(master,text = 'i', font = ('Courier','10','bold'), width = 0, height = 0, command = lambda text = self.IOkeywords[component][buttonKeyword][2]: self.doInfoPopup(text))

          row = row + 1
          label.grid(row=row, column=0, sticky=Tkinter.E)
          self.widgets[component][buttonKeyword].grid(row=row, column=1, sticky=Tkinter.W)
          infoButton.grid(row=row, column=2, sticky=Tkinter.E)
        
          tempWidgetInfo = (label,self.widgets[component][buttonKeyword],infoButton)
          allWidgets.append(tempWidgetInfo)
          if self.widgetSetup[component].index(widgetInfo) >= self.toggleInfoIndex[component]:
            toggleWidgets.append(tempWidgetInfo)
          else:
            normalWidgets.append(tempWidgetInfo)

          localWidgetCount += 1

      if self.widgets.has_key(component) and self.widgets[component]:
        if self.importExportFlag == 'export':

          row += 1
          #print 'export button row %d' % row

          self.exportButton[component] = Tkinter.Button(master, text = "Export %s file." % component, command = lambda comp = component: self.importExportFile(comp))
          self.exportButton[component].grid(row=row, column=0, columnspan = 3, sticky=Tkinter.EW)
          
          allWidgets.append((None,self.exportButton[component],None))

        if toggleInfoLabelRow != None:
          #print toggleInfoLabelRow
          toggleInfoLabel = ToggleLabel(master,  text='Additional options', callback= lambda hidden, curRow = toggleInfoLabelRow, toggleWidgets = toggleWidgets: self.toggleInfo(hidden,curRow,toggleWidgets))
          toggleInfoLabel.grid(row=toggleInfoLabelRow, column=0, sticky = Tkinter.E)
 
          if componentToggleRow != None:
            # Keep track of widget for hiding when encompassing widget is expanded
            allWidgetIndex = allWidgets.index('TOGGLEWIDGET')
            allWidgets[allWidgetIndex] = (toggleInfoLabel,'TOGGLE',None)
          else:
            # If not part of encompassing toggle, just minimize now...
            toggleInfoLabel.callback(1)
        if componentToggleRow != None:
          toggleInfoLabel = ToggleLabel(master,  text='Click here for the %s export menu.' % component, callback= lambda hidden, curRow = componentToggleRow, allWidgets = allWidgets: self.toggleInfo(hidden,curRow,allWidgets))
          toggleInfoLabel.grid(row=componentToggleRow, column=0, columnspan = 3, sticky = Tkinter.EW)
          toggleInfoLabel.callback(1)

        row = row + 1
        separator = Separator(master,height = 3)
        separator.setColor('black', bgColor = 'black')
        separator.grid(row=row, column=0, columnspan = 3, sticky=Tkinter.EW)
      
    if self.widgets:
      row = row + 1
      
      if self.importExportFlag == 'import':
        texts = [ 'IMPORT' ]
        commands = [ self.ok ]   # This calls 'ok' in BasePopup, this then calls 'apply' in here
      else:
        texts = []
        commands = []
      
      buttons = createDismissHelpButtonList(master, texts=texts, commands=commands, help_url=self.help_url)
      buttons.grid(row=row, column=0, columnspan = 3)

    else:
      showError("Error","No valid objects to %s" % self.importExportFlag,master)
      self.close()
Esempio n. 19
0
    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()
Esempio n. 20
0
  def body(self, guiFrame):
  
    guiFrame.grid_columnconfigure(0, weight=1)
    guiFrame.grid_rowconfigure(0, weight=1)

    options = ['Parameters','Restraints','Alignment Media & Tensors','About Meccano']
    tabbedFrame = TabbedFrame(guiFrame, options=options)
    tabbedFrame.grid(row=0, column=0, sticky='nsew')
    
    frameA, frameB, frameC, frameD = tabbedFrame.frames
    frameA.grid_columnconfigure(1, weight=1)
    frameA.grid_rowconfigure(13, weight=1)
    frameB.grid_columnconfigure(1, weight=1)
    frameB.grid_rowconfigure(1, weight=1)
    frameC.grid_columnconfigure(0, weight=1)
    frameC.grid_rowconfigure(1, weight=1)
    frameD.grid_columnconfigure(0, weight=1)
    frameD.grid_rowconfigure(0, weight=1)
    
    texts = ['Run MECCANO!']
    commands = [self.runMeccano]
    bottomButtons = createDismissHelpButtonList(guiFrame, texts=texts,
                                                commands=commands, expands=True)
    bottomButtons.grid(row=1, column=0, sticky='ew')

    if not Meccano:
      bottomButtons.buttons[0].disable()
  
    # Parameters
        
    row = 0
    label = Label(frameA, text='Calculation Run:')
    label.grid(row=row,column=0,sticky='w')
    self.runPulldown = PulldownList(frameA, callback=self.selectRun)
    self.runPulldown.grid(row=row,column=1,sticky='w')
    
    row += 1    
    label = Label(frameA, text='Shift List (for CO):')
    label.grid(row=row,column=0,sticky='w')
    self.shiftListPulldown = PulldownList(frameA, callback=self.selectShiftList)
    self.shiftListPulldown.grid(row=row,column=1,sticky='w')
           
    row += 1    
    label = Label(frameA, text='Keep Copy of Used Shifts:')
    label.grid(row=row,column=0,sticky='w')
    self.toggleCopyShifts = CheckButton(frameA)
    self.toggleCopyShifts.grid(row=row,column=1,sticky='w')
    self.toggleCopyShifts.set(True)
        
    row += 1    
    label = Label(frameA, text='Molecular System:')
    label.grid(row=row,column=0,sticky='w')
    self.molSystemPulldown = PulldownList(frameA, callback=self.selectMolSystem)
    self.molSystemPulldown.grid(row=row,column=1,sticky='w')
        
    row += 1    
    label = Label(frameA, text='Chain:')
    label.grid(row=row,column=0,sticky='w')
    self.chainPulldown = PulldownList(frameA, callback=self.selectChain)
    self.chainPulldown.grid(row=row,column=1,sticky='w')
    self.chainPulldown.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='First Peptide Plane:')
    label.grid(row=row,column=0,sticky='w')
    self.firstResEntry = IntEntry(frameA, text=None, width=8)
    self.firstResEntry.grid(row=row,column=1,sticky='w')
    self.firstResEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Last Peptide Plane:')
    label.grid(row=row,column=0,sticky='w')
    self.lastResEntry = IntEntry(frameA, text=None, width=8)
    self.lastResEntry.grid(row=row,column=1,sticky='w')
    self.lastResEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Max Num Optimisation Steps:')
    label.grid(row=row,column=0,sticky='w')
    self.maxOptStepEntry = IntEntry(frameA, text=500, width=8)
    self.maxOptStepEntry.grid(row=row,column=1,sticky='w')
    self.maxOptStepEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Num Optimisation Peptide Planes:')
    label.grid(row=row,column=0,sticky='w')
    self.numOptPlaneEntry = IntEntry(frameA, text=2, width=8)
    self.numOptPlaneEntry.grid(row=row,column=1,sticky='w')
    self.numOptPlaneEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Min Num Optimisation Hits:')
    label.grid(row=row,column=0,sticky='w')
    self.numOptHitsEntry = IntEntry(frameA, text=5, width=8)
    self.numOptHitsEntry.grid(row=row,column=1,sticky='w')
    self.numOptHitsEntry.bind('<Leave>', self.updateRunParams) 

    row += 1    
    label = Label(frameA, text='File Name Prefix:')
    label.grid(row=row,column=0,sticky='w')
    self.pdbFileEntry = Entry(frameA, text='Meccano', width=8)
    self.pdbFileEntry.grid(row=row,column=1,sticky='w')
    self.pdbFileEntry.bind('<Leave>', self.updateRunParams) 
           
    row += 1    
    label = Label(frameA, text='Write Output File (.out):')
    label.grid(row=row,column=0,sticky='w')
    self.toggleWriteOutFile = CheckButton(frameA)
    self.toggleWriteOutFile.grid(row=row,column=1,sticky='w')
    self.toggleWriteOutFile.set(False)
    self.toggleWriteOutFile.bind('<Leave>', self.updateRunParams) 
           
    row += 1    
    label = Label(frameA, text='Write PDB File (.pdb):')
    label.grid(row=row,column=0,sticky='w')
    self.toggleWritePdbFile = CheckButton(frameA)
    self.toggleWritePdbFile.grid(row=row,column=1,sticky='w')
    self.toggleWritePdbFile.set(True)
    self.toggleWritePdbFile.bind('<Leave>', self.updateRunParams) 
    
    if not Meccano:
      row += 1    
      label = Label(frameA, text='The Meccano executable is not available (it needs to be compiled)', fg='red')
      label.grid(row=row,column=0,columnspan=2,sticky='w')

    # Restraints
    
    label = Label(frameB, text='Constraint Set:')
    label.grid(row=0,column=0,sticky='w')
    
    self.constraintSetPulldown = PulldownList(frameB, callback=self.selectConstraintSet)
    self.constraintSetPulldown.grid(row=0,column=1,sticky='w')
    
    self.alignMediumPulldown= PulldownList(self, callback=self.setAlignMedium)
    
    headingList = ['#','List Type','Use?','Alignment\nMedium','Num\nRestraints']
    editWidgets      = [None,None,None,self.alignMediumPulldown,None]
    editGetCallbacks = [None,None,self.toggleUseRestraints,self.getAlignMedium,None]
    editSetCallbacks = [None,None,None,self.setAlignMedium,None]
    self.restraintMatrix = ScrolledMatrix(frameB,
                                          headingList=headingList,
                                          editSetCallbacks=editSetCallbacks,
                                          editGetCallbacks=editGetCallbacks, 
                                          editWidgets=editWidgets,
                                          callback=None,
                                          multiSelect=True)
    self.restraintMatrix.grid(row=1,column=0,columnspan=2,sticky='nsew')
    
    
    # Alignment Media
    
    div = LabelDivider(frameC,text='Alignment Media')
    div.grid(row=0,column=0,sticky='ew')
    
    self.mediumNameEntry = Entry(self, returnCallback=self.setMediumName)
    self.mediumDetailsEntry = Entry(self, returnCallback=self.setMediumDetails)
    
    headingList = ['#','Name','Details','Static Tensor','Dynamic Tensor']
    editWidgets      = [None, self.mediumNameEntry, self.mediumDetailsEntry, None, None]
    editGetCallbacks = [None, self.getMediumName, self.getMediumDetails, None, None]
    editSetCallbacks = [None, self.setMediumName, self.setMediumDetails, None, None]
    self.mediaMatrix = ScrolledMatrix(frameC,
                                      headingList=headingList,
                                      editSetCallbacks=editSetCallbacks,
                                      editGetCallbacks=editGetCallbacks, 
                                      editWidgets=editWidgets,
                                      callback=self.selectAlignMedium,
                                      multiSelect=True)
                                 
    self.mediaMatrix.grid(row=1,column=0,sticky='nsew')
     
    
    texts = ['Add Alignment medium','Remove Alignment Medium']
    commands = [self.addAlignMedium,self.removeAlignMedium]
    buttonList = ButtonList(frameC, texts=texts, commands=commands, expands=True)
    buttonList.grid(row=2,column=0,sticky='nsew')
    
    self.editAxialEntry = FloatEntry(self, returnCallback=self.setAxial)
    self.editRhombicEntry = FloatEntry(self, returnCallback=self.setRhombic)
    self.editAlphaEulerEntry = FloatEntry(self, returnCallback=self.setEulerAlpha)
    self.editBetaEulerEntry = FloatEntry(self, returnCallback=self.setEulerBeta)
    self.editGammaEulerEntry = FloatEntry(self, returnCallback=self.setEulerGamma)
    
    
    div = LabelDivider(frameC,text='Alignment Tensors')
    div.grid(row=3,column=0,sticky='ew')
    
    headingList = ['Type', u'Axial (\u03B6)',u'Rhombic (\u03B7)',
                   u'Euler \u03B1',u'Euler \u03B2',u'Euler \u03B3']
    editWidgets      = [None,self.editAxialEntry,
                        self.editRhombicEntry,self.editAlphaEulerEntry,
                        self.editBetaEulerEntry,self.editGammaEulerEntry]
    editSetCallbacks = [None,self.setAxial,self.setRhombic,
                        self.setEulerAlpha,self.setEulerBeta,self.setEulerGamma]
    editGetCallbacks = [None,self.getAxial,self.getRhombic,
                        self.getEulerAlpha,self.getEulerBeta,self.getEulerGamma]
                   
    self.tensorMatrix = ScrolledMatrix(frameC, maxRows=2,
                                       headingList=headingList,
                                       editSetCallbacks=editSetCallbacks,
                                       editGetCallbacks=editGetCallbacks, 
                                       editWidgets=editWidgets,
                                       callback=self.selectTensor,
                                       multiSelect=True)
                                          
    self.tensorMatrix.grid(row=4,column=0,sticky='nsew')
    
    texts = ['Add Static Tensor','Add Dynamic Tensor','Remove Tensor']
    commands = [self.addStaticTensor,self.addDynamicTensor,self.removeTensor]
    buttonList = ButtonList(frameC,texts=texts, commands=commands, expands=True)
    buttonList.grid(row=5,column=0,sticky='ew')
       
    # About
    
    label = Label(frameD, text='About Meccano...')
    label.grid(row=0,column=0,sticky='w')
  
    #
  
    self.geometry('500x400')

    self.updateShiftLists()
    self.updateMolSystems()
    self.updateResidueRanges()
    self.updateConstraintSets()
    self.updateAlignMedia()
    self.updateRuns()
Esempio n. 21
0
    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)
Esempio n. 22
0
    def __init__(self,
                 parent,
                 file_types=None,
                 directory=None,
                 single_callback=None,
                 double_callback=None,
                 select_dir_callback=None,
                 change_dir_callback=None,
                 should_change_dir_callback=None,
                 prompt=None,
                 show_file=True,
                 file='',
                 multiSelect=False,
                 default_dir=None,
                 getRowColor=None,
                 getExtraCell=None,
                 extraHeadings=None,
                 extraJustifies=None,
                 displayExtra=True,
                 manualFileFilter=False,
                 extraTipTexts=None,
                 *args,
                 **kw):

        if file_types is None:
            file_types = [FileType("All", ["*"])]

        if manualFileFilter:
            self.manualFilter = FileType("Manual")
            file_types.append(self.manualFilter)
        else:
            self.manualFilter = None

        if directory is None:
            directory = normalisePath(os.getcwd())

        if extraHeadings is None:
            extraHeadings = ()
        else:
            extraHeadings = tuple(extraHeadings)

        if extraJustifies is None:
            extraJustifies = ()
        else:
            extraJustifies = tuple(extraJustifies)

        if extraHeadings or extraJustifies:
            assert len(extraHeadings) == len(extraJustifies)
            assert getExtraCell

        self.extraHeadings = extraHeadings
        self.extraJustifies = extraJustifies
        self.extraTipTexts = extraTipTexts or []
        self.displayExtra = displayExtra

        Frame.__init__(self, parent, *args, **kw)

        self.file_types = file_types
        self.fileType = file_types[0]
        self.single_callback = single_callback
        self.double_callback = double_callback
        self.select_dir_callback = select_dir_callback
        self.change_dir_callback = change_dir_callback
        self.should_change_dir_callback = should_change_dir_callback
        self.show_file = show_file
        self.directory = None
        self.historyBack = []
        self.historyFwd = []
        self.determineDir(directory)
        self.default_dir = default_dir
        self.getRowColor = getRowColor
        self.getExtraCell = getExtraCell

        self.grid_columnconfigure(0, weight=1)

        row = 0
        if prompt:
            label = Label(self, text=prompt, grid=(row, 0))
            row += 1

        self.grid_rowconfigure(row, weight=1)
        if show_file:
            headings = ('Name', 'Size', 'Date')
            justifies = ('left', 'right', 'right')
            tipTexts = [
                'Name of file, directory or link', 'Size of file in bytes',
                'Date of last modification'
            ]
        else:
            headings = ('Directory', )
            justifies = ('left', )
            tipTexts = ['Name of directory']

        self.normalHeadings = headings
        self.normalJustifies = justifies
        self.normalTipTexts = tipTexts
        headings = headings + extraHeadings
        justifies = justifies + extraJustifies
        tipTexts += [None] * len(extraHeadings)

        self.fileList = ScrolledMatrix(self,
                                       headingList=headings,
                                       justifyList=justifies,
                                       initialRows=10,
                                       callback=self.singleCallback,
                                       doubleCallback=self.doubleCallback,
                                       tipTexts=tipTexts,
                                       multiSelect=multiSelect,
                                       grid=(row, 0))

        row += 1
        tipTexts = [
            'Go to previous location in history',
            'Go forward in location history', 'Go up one directory level',
            'Go to root directory', 'Go to home directory',
            'Make a new directory', 'Refresh directory listing'
        ]

        texts = ['Back', 'Forward', 'Up', 'Top', 'Home', 'New', 'Refresh']
        commands = [
            self.backDir, self.fwdDir, self.upDir, self.topDir, self.homeDir,
            self.createDir, self.updateFileList
        ]

        if self.default_dir:
            texts.append('Default')
            commands.append(self.setDefaultDir)
            tipTexts.append('Set the current directory as the default')

        self.icons = []
        for name in ICON_NAMES:
            icon = Tkinter.PhotoImage(
                file=os.path.join(GFX_DIR, name + '.gif'))
            self.icons.append(icon)

        self.buttons = ButtonList(self,
                                  texts=texts,
                                  commands=commands,
                                  images=self.icons,
                                  grid=(row, 0),
                                  tipTexts=tipTexts)

        if show_file:
            row += 1
            self.file_entry = LabeledEntry(self,
                                           label='File name',
                                           label_width=10,
                                           entry_width=40,
                                           returnCallback=self.setSelectedFile)
            self.file_entry.grid(row=row, column=0, sticky=Tkinter.EW)
        else:
            self.file_entry = None

        row += 1
        self.directory_entry = LabeledEntry(self,
                                            label='Directory',
                                            entry=directory,
                                            label_width=10,
                                            entry_width=40,
                                            returnCallback=self.entryDir)
        self.directory_entry.grid(row=row, column=0, sticky=Tkinter.EW)

        row += 1
        subFrame = Frame(self, grid=(row, 0))
        subFrame.expandGrid(None, 6)

        if show_file:

            label = Label(subFrame, text='File type:', grid=(0, 0))

            type_labels = self.determineTypeLabels()
            self.fileType_menu = PulldownList(
                subFrame,
                callback=self.typeCallback,
                texts=type_labels,
                objects=self.file_types,
                grid=(0, 1),
                tipText='Restrict listed files to selected suffix')

        label = Label(subFrame, text=' Show hidden:', grid=(0, 2))

        self.hidden_checkbutton = CheckButton(
            subFrame,
            text='',
            selected=False,
            callback=self.updateFileList,
            grid=(0, 3),
            tipText='Show hidden files beginning with "." etc.')

        label = Label(subFrame, text='Dir path:', grid=(0, 4))

        self.pathMenu = PulldownList(
            subFrame,
            callback=self.dirCallback,
            objects=range(len(self.dirs)),
            texts=self.dirs,
            index=len(self.dirs) - 1,
            indent='  ',
            prefix=dirsep,
            grid=(0, 5),
            tipText='Directory navigation to current location')

        if show_file and self.manualFilter is not None:
            row += 1
            self.manual_filter_entry = LabeledEntry(
                self,
                label='Manual Select',
                entry=defaultFilter,
                label_width=13,
                entry_width=40,
                returnCallback=self.entryFilter,
                tipText=
                'Path specification with wildcards to select multiple files')
            self.manual_filter_entry.grid(row=row, column=0, sticky=Tkinter.EW)

        self.updateFileList()
        self.updateButtons()

        if file:
            self.setFile(file)
Esempio n. 23
0
  def setupAtomFrame(self,resetFrame = False, resetStatus = True):
    
    frameRow = 0
    self.atomWidgets = []
    
    if resetFrame:
      self.atomFrame = ScrolledFrame(self.atomFrameMaster, width = self.frameWidth, height = 300, doExtraConfig = False)
      self.atomFrame.grid(row=self.atomFrameRow, column=0, columnspan = self.columnspan, sticky=Tkinter.NSEW)    
    
    frame = self.atomFrame.frame
      
    #
    # Make fake info at top for col length...
    #
    
    colNum = 0
    
    for chemCompAtomInfo in self.chemCompAtoms[0]:
      
      attrName = chemCompAtomInfo[0]

      label = Label(frame, text = '', width = len(attrName) + 2)
      label.grid(row=frameRow, column=colNum, sticky=Tkinter.EW)
      
      colNum += 1
            
    #
    # Now atom info...
    #
    
    for chemCompAtom in self.chemCompAtoms:
      
      frameRow += 1
      colNum = 0
      
      self.atomWidgets.append([])

      for chemCompAtomInfo in chemCompAtom:

        attrName = chemCompAtomInfo[0]

        if attrName == 'bondedAtoms':

          bondedAtomText = ""
          
          for otherAtom in chemCompAtomInfo[1]:
            bondedAtomText += otherAtom[0][1] + ','
          
          label = Label(frame, text = bondedAtomText[:-1])
          label.grid(row=frameRow, column=colNum, sticky=Tkinter.EW)
            
        else:

          if attrName in self.nonEntryAttributes:

            widgetInfo = self.nonEntryAttributes[attrName]

            if widgetInfo[0] == PulldownMenu:

              self.atomWidgets[-1].append(PulldownMenu(frame, entries = widgetInfo[1], selected_index = widgetInfo[1].index(chemCompAtomInfo[1])))

            elif widgetInfo[0] == CheckButton:

              self.atomWidgets[-1].append(CheckButton(frame, selected = chemCompAtomInfo[1]))

          else:

            text = chemCompAtomInfo[1]
            if not text:
              text = ''

            self.atomWidgets[-1].append(Entry(frame, text = text, width = 5))

          self.atomWidgets[-1][-1].grid(row=frameRow, column=colNum)     
      
        colNum += 1
Esempio n. 24
0
def setIoInfo(master,setupInfo,project,fileDefs,forceCreation = False, appendNone = False):
  
  (widgetType,IOkeywd,labelText,IOdefault,extraDefs) = setupInfo
  
  label = Label(master, text = labelText)
  widget = None
  selectionDict = None
  
  if widgetType[-5:] == 'Entry':
    
    addKeywds = {}
    if extraDefs and extraDefs.has_key('width'):
      addKeywds['width'] = extraDefs['width']
      
    widget = Entry(master, text='%s' % str(IOdefault),**addKeywds)
    
  elif widgetType == 'CheckButton':
  
    widget = CheckButton(master)
    widget.setSelected(IOdefault)
    
  elif widgetType[:13] == 'SelectionList' or widgetType[:18] == 'MultiSelectionList':

    if IOdefault[:7] == 'project':
       
      ccpnObjects = getCcpnObjects(project,IOdefault)

      (selectionList,selectionDict) = createSelection(ccpnObjects)
      
      if (selectionList or forceCreation) and widgetType[-8:] == 'WithNone':
        if appendNone:
          selectionList.append('None')
        else:
          selectionList.insert(0,'None')
        selectionDict['None'] = None
      
    else:
      selectionList = IOdefault # Should be list!
    
    if selectionList:
      if widgetType[:13] == 'SelectionList':
        widget = PulldownList(master, texts = selectionList)
      elif widgetType[:18] == 'MultiSelectionList':
        widget = ScrolledListbox(master,height = 5,selectmode = Tkinter.MULTIPLE,initial_list = selectionList)

  elif widgetType in ('FileButton','FileMultiButton','DirButton'):
 
    (component,format,selectFile,selectDir) = fileDefs
    fileComponent = None
    
    if extraDefs:
      if extraDefs.has_key('component'):
        fileComponent = extraDefs['component'] # Can't reset component 'cos necessary for handling widget!
      elif extraDefs.has_key('format'):
        format = extraDefs['format']
    
    if widgetType[:4] == 'File':
      if widgetType == 'FileMultiButton':
        multiSelect= True
      else:
        multiSelect = False
      
      widget = Tkinter.Button(master, text = IOdefault, command = lambda comp = component, format = format, buttonKeyword = IOkeywd, defaultText = IOdefault, fileComponent = fileComponent, multiSelect = multiSelect: selectFile(comp,format,buttonKeyword,defaultText,fileComponent,multiSelect = multiSelect))

    elif widgetType == 'DirButton':
      widget = Tkinter.Button(master, text = IOdefault, command = lambda comp = component, format = format, buttonKeyword = IOkeywd: selectDir(comp,format,buttonKeyword))

  return (label,widget,selectionDict)
Esempio n. 25
0
    def body(self, guiFrame):

        self.geometry('550x600')
        guiFrame.grid_columnconfigure(0, weight=1)

        row = 0

        frame = Frame(guiFrame, grid=(row, 0))
        frame.expandGrid(0, 4)

        label = Label(frame, text='Peak List:', grid=(0, 0))
        tipText = 'For spectra with (mostly) one peak per residue, selects which peak list to initialise; by adding anonymous resonance and spin system numbers'
        self.peakListPulldown = PulldownList(frame,
                                             self.changePeakList,
                                             grid=(0, 1),
                                             tipText=tipText)

        label = Label(frame, text='15N tolerance (ppm):', grid=(0, 2))
        tipText = 'The upper limit in the difference between 15N ppm positions for two peaks to be considered as a potential amide'
        self.tolEntry = FloatEntry(frame,
                                   text=0.02,
                                   width=8,
                                   grid=(0, 3),
                                   sticky='ew',
                                   tipText=tipText)

        frame2 = Frame(frame, grid=(1, 0), gridSpan=(1, 4), sticky='ew')
        frame2.grid_columnconfigure(5, weight=1)

        label = Label(frame2, text='Follow Amides:', grid=(0, 0))
        tipText = 'Sets whether to follow the H-N locations of potential amide peaks when clicking in rows of the table'
        self.followSelect = CheckButton(frame2,
                                        callback=None,
                                        grid=(0, 1),
                                        selected=True,
                                        tipText=tipText)

        self.windowLabel = Label(frame2, text='Window:', grid=(0, 2))

        tipText = 'Selects the spectrum window in which to show positions of potential amide peaks'
        self.windowPulldown = PulldownList(frame2,
                                           self.selectWindowPane,
                                           grid=(0, 3),
                                           tipText=tipText)

        label = Label(frame2, text='Mark Amides:', grid=(0, 4))
        tipText = 'Whether to put a multi-dimensional cross mark though the H-N positions of the selected peak pair'
        self.markSelect = CheckButton(frame2,
                                      callback=None,
                                      grid=(0, 5),
                                      selected=True,
                                      tipText=tipText)

        utilButtons = UtilityButtonList(guiFrame,
                                        grid=(row, 1),
                                        sticky='ne',
                                        helpUrl=self.help_url)

        row += 1
        tipTexts = [
            'For the stated peak list, considering confirmed amide side chain peaks, add spin system and resonance numbers to all peaks',
        ]
        commands = [
            self.initialisePeakList,
        ]
        texts = [
            'Initialise Peak List!',
        ]
        self.initButtons = ButtonList(guiFrame,
                                      commands=commands,
                                      grid=(row, 0),
                                      texts=texts,
                                      gridSpan=(1, 2),
                                      tipTexts=tipTexts)
        self.initButtons.buttons[0].config(bg='#B0FFB0')

        row += 1
        div = LabelDivider(guiFrame,
                           text='Amide Side Chain Peaks',
                           gridSpan=(1, 2),
                           grid=(row, 0))

        row += 1
        guiFrame.grid_rowconfigure(row, weight=1)

        frame = Frame(guiFrame, gridSpan=(1, 2), grid=(row, 0))
        frame.expandGrid(0, 0)

        editSetCallbacks = [None] * 8
        editGetCallbacks = [None] * 8
        editWidgets = [None] * 8
        editGetCallbacks[1] = self.toggleConfirm
        #self.userCodeEntry = Entry(self,text='', returnCallback=self.setResidueCode, width=6)
        tipTexts = [
            'Number of the peak pair for the table',
            'Whether the peak pair is confirmed as being from an amide side chain; a common nitrogen by different hydrogens',
            'The difference in 15N ppm position between the two peaks of the pair',
            'The assignment annotation of the first peak in the pair',
            'The assignment annotation of the second peak in the pair',
            'The average 15N position of the peaks in the pair',
            'The 1H chemical shift of the first peak in the pair',
            'The 1H chemical shift of the second peak in the pair'
        ]
        headingList = [
            '#', 'Confirmed?', u'15N\n\u0394ppm', 'Peak 1', 'Peak 2',
            'Shift N', 'Shift H1', 'Shift H2'
        ]
        self.amidePairMatrix = ScrolledMatrix(
            frame,
            headingList=headingList,
            editSetCallbacks=editSetCallbacks,
            editGetCallbacks=editGetCallbacks,
            editWidgets=editWidgets,
            callback=self.selectAmidePair,
            multiSelect=True,
            grid=(0, 0),
            tipTexts=tipTexts)

        tipTexts = [
            'Confirm the selected peak pairs as being amide side chain peaks; a common nitrogen by different hydrogens',
            'remove any conformation for the selected peak pairs being amide side chain peaks',
            'Manually force an update the table of potential pairs of amide side chain peaks'
        ]
        commands = [
            self.confirmAmidePairs, self.unconfirmAmidePairs,
            self.predictAmidePairs
        ]
        texts = ['Confirm\nSelected', 'Unconfirm\nSelected', 'Update\nTable']
        self.amideButtons = ButtonList(frame,
                                       texts=texts,
                                       commands=commands,
                                       grid=(1, 0),
                                       tipTexts=tipTexts)

        self.updatePeakLists()
        self.administerNotifiers(self.registerNotify)
Esempio n. 26
0
    def body(self, master):

        row = 0

        label = Label(master, text='File format reference:')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.menu = PulldownMenu(master, entries=self.formatNamesList)
        self.menu.grid(row=row, column=1, sticky=Tkinter.E, ipadx=20)

        row = row + 1

        label = Label(master, text='Try to link unrecognized atom names')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.linkRes = CheckButton(master, selected=True)
        self.linkRes.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(master, text='Try IUPAC names (as backup)')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.iupacNames = CheckButton(master)
        self.iupacNames.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(master, text='Use ambiguous name information')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.useAmb = CheckButton(master)
        self.useAmb.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(master, text='Complete stereospecific assignment')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.allStereo = CheckButton(master)
        self.allStereo.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(master, text='Force shift merges')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.shiftMerge = CheckButton(master)
        self.shiftMerge.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(master,
                      text='Status other atom for all single prochiral atoms')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.allSingleProchiral = PulldownMenu(
            master, entries=['Unknown', 'Same information', 'Always ignore'])
        self.allSingleProchiral.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(
            master,
            text='Status other atom for all possibly equivalent single atoms')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.allSinglePossEquiv = PulldownMenu(
            master, entries=['Unknown', 'Always equivalent', 'Always ignore'])
        self.allSinglePossEquiv.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(
            master,
            text=
            'Automatically connect ambiguous resonances to stereospecific ones'
        )
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.connStereo = CheckButton(master)
        self.connStereo.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(master, text='Use minimal number of popups')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.minimalPopups = CheckButton(master)
        self.minimalPopups.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(master, text='Verbose output')
        label.grid(row=row, column=0, sticky=Tkinter.E)

        self.verbose = CheckButton(master, selected=True)
        self.verbose.grid(row=row, column=1, sticky=Tkinter.W)

        row = row + 1

        label = Label(
            master,
            text=
            'Warning: it is recommended you save your project first,\nin case linkResonances is interrupted (this might corrupt the data).',
            fg='red')
        label.grid(row=row,
                   column=0,
                   columnspan=2,
                   ipady=15,
                   sticky=Tkinter.EW)

        row = row + 1

        texts = ['Link resonances to atoms']
        commands = [
            self.ok
        ]  # This calls 'ok' in BasePopup, this then calls 'apply' in here
        buttons = createDismissHelpButtonList(master,
                                              texts=texts,
                                              commands=commands,
                                              help_url=self.help_url)
        buttons.grid(row=row, column=0, columnspan=3)
Esempio n. 27
0
  def body(self, guiFrame):

    self.geometry('700x700')
   
    guiFrame.expandGrid(0,0)
    
    options = ['Peak Lists & Settings','Peak Intensity Comparison']
    tabbedFrame = TabbedFrame(guiFrame, options=options, callback=self.changeTab)
    tabbedFrame.grid(row=0, column=0, sticky='nsew')
    self.tabbedFrame = tabbedFrame
    frameA, frameB = tabbedFrame.frames

    row = 0
    frameA.grid_columnconfigure(1, weight=1)
    frameA.grid_columnconfigure(3, weight=1)
    frameA.grid_columnconfigure(5, weight=1)
    frameA.grid_rowconfigure(5, weight=1)

    tipText = 'Number of reference peaks (no saturation)'
    self.peaksALabel = Label(frameA, text='Number of Ref Peaks: ', tipText=tipText)
    self.peaksALabel.grid(row=1,column=0,columnspan=2,sticky='w')

    tipText = 'Number of NOE saturation peaks'
    self.peaksBLabel = Label(frameA, text='Number of Sat Peaks: ', tipText=tipText)
    self.peaksBLabel.grid(row=1,column=2,columnspan=2,sticky='w')

    tipText = 'Number of peaks in assigned list'
    self.peaksCLabel = Label(frameA, text='Number of Assign Peaks: ', tipText=tipText)
    self.peaksCLabel.grid(row=1,column=4,columnspan=2,sticky='w')
    
    tipText = 'Selects which peak list is considered the NOE intensity reference (no saturation)'
    specALabel = Label(frameA, text='Ref Peak List: ')
    specALabel.grid(row=0,column=0,sticky='w')
    self.specAPulldown = PulldownList(frameA, callback=self.setRefPeakList, tipText=tipText)
    self.specAPulldown.grid(row=0,column=1,sticky='w')

    tipText = 'Selects which peak list is considered as NOE saturated.'
    specBLabel = Label(frameA, text='Sat Peak List: ')
    specBLabel.grid(row=0,column=2,sticky='w')
    self.specBPulldown = PulldownList(frameA, callback=self.setSatPeakList, tipText=tipText)
    self.specBPulldown.grid(row=0,column=3,sticky='w')

    tipText = 'Selects a peak list with assignments to use as a positional reference'
    specCLabel = Label(frameA, text='Assignment Peak List: ')
    specCLabel.grid(row=0,column=4,sticky='w')
    self.specCPulldown = PulldownList(frameA, callback=self.setAssignPeakList, tipText=tipText)
    self.specCPulldown.grid(row=0,column=5,sticky='w')

    frame0a = Frame(frameA)
    frame0a.grid(row=2,column=0,columnspan=6,sticky='nsew')
    frame0a.grid_columnconfigure(9, weight=1)
    
    tipText = '1H ppm tolerance for matching assigned peaks to reference & NOE saturation peaks'
    tolHLabel   = Label(frame0a, text='Tolerances: 1H')
    tolHLabel.grid(row=0,column=0,sticky='w')
    self.tolHEntry = FloatEntry(frame0a,text='0.02', width=6, tipText=tipText)
    self.tolHEntry .grid(row=0,column=1,sticky='w')  

    tipText = '15N ppm tolerance for matching assigned peaks to reference & NOE saturation peaks'
    tolNLabel   = Label(frame0a, text=' 15N')
    tolNLabel .grid(row=0,column=2,sticky='w')   
    self.tolNEntry = FloatEntry(frame0a,text='0.1', width=6, tipText=tipText)
    self.tolNEntry .grid(row=0,column=3,sticky='w')   

    tipText = 'Whether to peak new peaks in reference & NOE saturated lists (at assignment locations)'
    label = Label(frame0a, text=' Pick new peaks?', grid=(0,4)) 
    self.pickPeaksSelect = CheckButton(frame0a, tipText=tipText,
                                       grid=(0,5), selected=True)

    tipText = 'Whether to assign peaks in the peaks in the reference & NOE saturation lists, if not already assigned'
    label = Label(frame0a, text=' Assign peaks?')
    label.grid(row=0,column=6,sticky='w')   
    self.assignSelect = CheckButton(frame0a, tipText=tipText)
    self.assignSelect.set(1)
    self.assignSelect.grid(row=0,column=7,sticky='w')    

    tipText = 'Whether to consider peak height or volume in the heteronuclear NOE calculation'
    intensLabel = Label(frame0a, text=' Intensity Type:')
    intensLabel .grid(row=0,column=8,sticky='w')   
    self.intensPulldown = PulldownList(frame0a, texts=['height','volume'],
                                       callback=self.setIntensityType,
                                       tipText=tipText)
    self.intensPulldown.grid(row=0,column=9,sticky='w')    

    divider = LabelDivider(frameA, text='Peaks', grid=(3,0),
                           gridSpan=(1,6))

    tipTexts = ['Show the selected intensity reference peaks in the below table',
                'Show the selected NOE saturation peaks in the below table',
                'Show the selected assigned peak list in the below table',
                'Show the displayed peaks in a separate peak table, where assignments etc. may be adjusted']
    texts    = ['Show Ref Peaks','Show Sat Peaks',
                'Show Assign Peaks', 'Separate Peak Table']
    commands = [self.viewRefPeakList, self.viewSatPeakList,
                self.viewAssignPeakList, self.viewSeparatePeakTable]
    self.viewPeaksButtons = ButtonList(frameA, expands=True, tipTexts=tipTexts,
                                       texts=texts, commands=commands)
    self.viewPeaksButtons.grid(row=4,column=0,columnspan=6,sticky='nsew')

    self.peakTable = PeakTableFrame(frameA, self.guiParent, grid=(5,0),
                                    gridSpan=(1,6))
    self.peakTable.bottomButtons1.grid_forget()
    self.peakTable.bottomButtons2.grid_forget()
    #self.peakTable.topFrame.grid_forget()
    self.peakTable.topFrame.grid(row=2, column=0, sticky='ew')
    # Next tab

    frameB.expandGrid(0,0)
    
    tipTexts = ['Row number',
                'Assignment annotation for NOE saturation peak',
                'Assignment annotation for reference peak (no saturation)',
                '1H chemical shift of NOE saturation peak',
                '1H chemical shift of reference peak',
                '15N chemical shift of NOE saturation peak',
                '15N chemical shift of reference peak',
                'The separation between compared peaks: square root of the sum of ppm differences squared',
                'The intensity if the NOE saturation peak',
                'The intensity of the reference peak (no saturation)',
                'Ratio of peak intensities: saturated over reference',
                'Residue(s) for reference peak']
    colHeadings      = ['#','Sat Peak','Ref Peak','1H shift A',
                        '1H shift B','15N shift A','15N shift B',
                        'Closeness\nScore','Intensity A','Intensity B',
                        'Intensity\nRatio','Residue']
    self.scrolledMatrix = ScrolledMatrix(frameB, multiSelect=True, 
                                         headingList=colHeadings,
                                         callback=self.selectCell,
                                         tipTexts=tipTexts,
                                         grid=(0,0),
                                         deleteFunc=self.removePair)

    tipTexts = ['Force a manual update of the table; pair-up NOE saturation and reference peaks according to assigned peak positions',
                'Remove the selected rows of peak pairs',
                'Show peaks corresponding to the selected row in a table',
                'Save the Heteronuclear NOE values in the CCPN project as a data list']
    texts    = ['Refresh Table','Remove Pairs',
                'Show Peak Pair','Create Hetero NOE List']
    commands = [self.matchPeaks,self.removePair,
                self.showPeakPair,self.makeNoeList]
    self.pairButtons = ButtonList(frameB, tipTexts=tipTexts, grid=(1,0),
                                  texts=texts, commands=commands)


    bottomButtons = UtilityButtonList(tabbedFrame.sideFrame, helpUrl=self.help_url)
    bottomButtons.grid(row=0, column=0, sticky='e')
    
    self.updatePulldowns()
    self.updateAfter()

    self.administerNotifiers(self.registerNotify)
Esempio n. 28
0
  def body(self, guiFrame):

    guiFrame.grid_columnconfigure(3, weight=1)

    self.progressBar = TypingEnsemblePopup(self,total=100)
    self.progressBar.close()
    
    row = 0
    label = Label(guiFrame, text=' Chain: ', grid=(row,0))
    tipText = 'Selects which molecular chain the spin system residue types will be predicted for; determines which range of types are available'
    self.chainPulldown = PulldownList(guiFrame, self.changeChain,
                                      grid=(row,1), tipText=tipText)

    tipText = 'Selects which shift list will be used as the source of chemical shift information to make the residue type predictions'
    label = Label(guiFrame, text='Shift List: ', grid=(row,2))
    self.shiftListPulldown = PulldownList(guiFrame, callback=self.setShiftList,
                                          grid=(row,3), tipText=tipText)

    utilButtons = UtilityButtonList(guiFrame, helpUrl=self.help_url)
    utilButtons.grid(row=row, column=4, sticky='w')

    row += 1
    frame = LabelFrame(guiFrame, text='Options', grid=(row,0), gridSpan=(1,5))
    frame.grid_columnconfigure(3, weight=1)

    frow = 0
    label = Label(frame, text='Keep existing types?',
                  grid=(frow,0), sticky='e')
    tipText = 'Whether any existing residue type information should be preserved, when predicting the type of others'
    self.preserveTypesSelect = CheckButton(frame, grid=(frow,1), selected=False, 
                                           callback=self.selectPreserveTypes,
                                           tipText=tipText)
  

    label = Label(frame, text='Assignment threshold: ',
                  grid=(frow,2), sticky='e')
    tipText = 'The lower limit for the predicted residue type to be set with "Assign Types"; needs to be adjusted according to result statistics and amount of shift data'
    self.thresholdEntry = FloatEntry(frame, text=self.threshold,
                                     width=8, grid=(frow,3), tipText=tipText)

    frow += 1
    label = Label(frame, text='Ensemble size: ', grid=(frow,0), sticky='e')
    tipText = 'The number of best scoring residue type mappings, from the Monte Carlo search, to use un the prediction'
    self.ensembleEntry = IntEntry(frame,text=20,width=4,
                                  grid=(frow,1), tipText=tipText)

    label = Label(frame, text='Num Search Steps: ', grid=(frow,2), sticky='e')
    tipText = 'The number of iterative steps that will be used in the Monte Carlo search of best spin system to residue type mappings'
    self.stepsEntry = IntEntry(frame, text=100000, width=8,
                               tipText=tipText, grid=(frow,3))

    frow += 1
    label = Label(frame, text='Isotope shifts to consider:',
                  grid=(frow,0), gridSpan=(1,4))
    
    frow += 1
    self.isotopes = ['1H','13C']
    isos   = ['1H','13C','15N']
    colors = [COLOR_DICT[x] for x in isos] 
    tipText = 'Selects which kinds of resonances, in terms of isotope, the residue type predictions will be made with'
    self.isotopeCheckButtons = PartitionedSelector(frame, labels=isos,
                                                   objects=isos, colors=colors,
                                                   callback=self.toggleIsotope,
                                                   selected=self.isotopes,
                                                   grid=(frow,0),
                                                   gridSpan=(1,4), tipText=tipText)
        
    row += 1
    guiFrame.grid_rowconfigure(row, weight=1)
    labelFrame = LabelFrame(guiFrame, text='Spin Systems', grid=(row,0), gridSpan=(1,5))
    labelFrame.expandGrid(0,0)
    
    tipTexts = ['The spin system serial number',
                'The residue to which the spin system may currently be assigned',
                'Set whether to include a particular spin system in the type predictions',
                'The spin system to residue type match score for a prediction; higher (less negative) is better',
                'The predicted types of residue that the spin system may be',
                'The chemical shifts in the spin system that will be used in the analysis']
    headingList = ['#','Residue','Use?','Score','Types','Shifts']
    justifyList = ['center','center','center','center','center','left']
    editWidgets      = [None, None, None, None, None, None]
    editGetCallbacks = [None, None, self.toggleInclude, None, None, None]
    editSetCallbacks = [None, None, None, None, None, None]
    self.scrolledMatrix = ScrolledMatrix(labelFrame, headingList=headingList,
                                         justifyList=justifyList,
 					 editSetCallbacks=editSetCallbacks,
                                         editWidgets=editWidgets,
 					 editGetCallbacks=editGetCallbacks,
                                         callback=self.selectCell,
                                         grid=(0,0), tipTexts=tipTexts)

    row += 1
    tipTexts = ['Execute the Monte Carlo search that will make the residue type predictions for the spin systems',
                'Assign the residue type of spin systems with a unique type prediction and prediction score above the stated threshold',
                'Show a residue type prediction for the selected spin system alone; only considers that spin system of shifts, not how all spin systems fit to the sequence',
                'Show a table of peaks that are assigned to the resonances of the selected spin system']
    texts    = ['Run\nTyping','Assign\nTypes',
                'Show Individual\nClassification',
                'Show\nPeaks']
    commands = [self.run, self.assign,
                self.individualScore,
                self.showPeaks]
    bottomButtons = ButtonList(guiFrame, texts=texts, commands=commands,
                               grid=(row,0), gridSpan=(1,5), tipTexts=tipTexts)
    
    self.runButton    = bottomButtons.buttons[0]
    self.assignButton = bottomButtons.buttons[1]
    self.scoreButton  = bottomButtons.buttons[2]
    self.peaksButton  = bottomButtons.buttons[2]
    self.runButton.config(bg='#B0FFB0')
    
    for func in ('__init__','delete'):
      self.registerNotify(self.updateChains, 'ccp.molecule.MolSystem.Chain', func)
      self.registerNotify(self.updateShiftLists, 'ccp.nmr.Nmr.ShiftList', func)
      
    for func in ('__init__','delete','setCcpCode',
                 'setResidue','addResonance', 'setName',
                 'removeResonance','setResonances'):
       self.registerNotify(self.updateSpinSystemsAfter, 'ccp.nmr.Nmr.ResonanceGroup', func)

    self.updateChains()
    self.updateShiftLists()
    self.updateSpinSystems()
Esempio n. 29
0
    def body(self, guiFrame):

        guiFrame.grid_columnconfigure(0, weight=1)
        row = 0

        self.scrolledGraph = ScrolledGraph(guiFrame,
                                           width=400,
                                           height=300,
                                           symbolSize=5,
                                           symbols=['square', 'circle'],
                                           dataColors=['#000080', '#800000'],
                                           lineWidths=[0, 1],
                                           grid=(row, 0))

        #self.scrolledGraph.setZoom(0.7)

        row += 1
        frame = Frame(guiFrame, grid=(row, 0), sticky='ew')

        label = Label(frame, text='Fitting Function:', grid=(0, 0))

        tipText = 'Selects which form of function to fit to the experimental data'
        self.methodPulldown = PulldownList(frame,
                                           self.changeMethod,
                                           grid=(0, 1),
                                           tipText=tipText)

        row += 1
        frame = Frame(guiFrame, grid=(row, 0), sticky='ew')

        tipText = 'The effective equation of the final fitted graph, incorporating all parameters'
        self.equationLabel = Label(frame,
                                   text='Equation:',
                                   grid=(0, 0),
                                   tipText=tipText)

        tipText = 'The error in the fit of the selected parameterised function to the experimental data'
        self.errorLabel = Label(frame,
                                text='Fit Error:',
                                grid=(0, 1),
                                tipText=tipText)

        row += 1
        frame = Frame(guiFrame, grid=(row, 0), sticky='ew')

        label = Label(frame, text='Include x origin?:', grid=(0, 0))

        tipText = 'Whether to include the x=0 point in the drawing'
        self.xOriginSelect = CheckButton(frame,
                                         callback=self.draw,
                                         grid=(0, 1),
                                         selected=False,
                                         tipText=tipText)

        label = Label(frame, text='Include y origin?:', grid=(0, 2))

        tipText = 'Whether to include the y=0 point in the drawing'
        self.yOriginSelect = CheckButton(frame,
                                         callback=self.draw,
                                         grid=(0, 3),
                                         selected=False,
                                         tipText=tipText)

        label = Label(frame, text='Include y error?:', grid=(0, 4))

        tipText = 'Whether to include the y error bars in the drawing (if these exist)'
        self.yErrorSelect = CheckButton(frame,
                                        callback=self.draw,
                                        grid=(0, 5),
                                        selected=False,
                                        tipText=tipText)

        row += 1
        frame = Frame(guiFrame, grid=(row, 0), sticky='ew')

        label = Label(frame, text='Navigation Window:', grid=(0, 0))

        tipText = 'Selects which spectrum window will be used for navigating to peak positions'
        self.windowPanePulldown = PulldownList(frame,
                                               self.changeWindow,
                                               grid=(0, 1),
                                               tipText=tipText)

        label = Label(frame, text='Follow in window?:', grid=(0, 2))

        tipText = 'Whether to navigate to the position of the reference peak (for the group), in the selected window'
        self.followSelect = CheckButton(frame,
                                        callback=self.windowPaneNavigate,
                                        grid=(0, 3),
                                        selected=False,
                                        tipText=tipText)

        label = Label(frame, text='Mark Ref Peak?:', grid=(0, 4))

        tipText = 'Whether to put a multi-dimensional cross-mark through the reference peak position, so it can be identified in spectra'
        self.markSelect = CheckButton(frame,
                                      callback=None,
                                      tipText=tipText,
                                      grid=(0, 5),
                                      selected=False)

        row += 1
        guiFrame.grid_rowconfigure(row, weight=1)
        tipTexts = [
            'The number of the data point, in order of increasing X-axis value',
            'For each point, the value of the parameter which is varied in the NMR series, e.g. T1, temperature, concentration etc.',
            'For each point, the experimental value being fitted, e.g. peak intensity of chemical shift distance',
            'The value of the best-fit function at the X-axis location',
            'The difference between the experimental (Y-axis) value and the fitted value',
            'The error in the experimental (Y-axis) value'
        ]
        headingList = ['Point', 'x', 'y', 'Fitted y', u'\u0394', 'y error']
        self.scrolledMatrix = ScrolledMatrix(guiFrame,
                                             headingList=headingList,
                                             callback=self.selectObject,
                                             tipTexts=tipTexts,
                                             grid=(row, 0))

        row += 1
        tipTexts = [
            'Remove the selected data point, optionally removing the underlying peak',
            'Show a table of spectrum peaks that correspond to the selected data point'
        ]
        texts = ['Remove Point', 'Show Peak']
        commands = [self.removePoint, self.showObject]

        if self.prevSetFunction:
            texts.append('Previous Set')
            tipTexts.append(
                'Move to the previous set of fitted values; the next group of peaks, often corresponding to a different residue or resonance'
            )
            commands.append(self.prevSet)

        if self.nextSetFunction:
            tipTexts.append(
                'Move to the next set of fitted values; the next group of peaks, often corresponding to a different residue or resonance'
            )
            texts.append('Next Set')
            commands.append(self.nextSet)

        bottomButtons = UtilityButtonList(guiFrame,
                                          texts=texts,
                                          commands=commands,
                                          helpUrl=self.help_url,
                                          tipTexts=tipTexts,
                                          grid=(row, 0),
                                          doClone=False)
        self.removeButton = bottomButtons.buttons[0]

        for func in ('__init__', 'delete', 'setName'):
            self.registerNotify(self.updateWindows,
                                'ccpnmr.Analysis.SpectrumWindow', func)

        self.update()
Esempio n. 30
0
    def body(self, guiFrame):

        row = 0
        col = 0
        #    frame = Frame( guiFrame )
        #    frame.grid(row=row, column=col, sticky='news')
        self.menuBar = Menu(guiFrame)
        self.menuBar.grid(row=row, column=col, sticky='ew')

        #----------------------------------------------------------------------------------
        # Project frame
        #----------------------------------------------------------------------------------

        #    guiFrame.grid_columnconfigure(row, weight=1)
        #    frame = LabelFrame(guiFrame, text='Project', font=medFont)
        row = +1
        col = 0
        frame = LabelFrame(guiFrame, text='Project', **labelFrameAttributes)
        print '>', frame.keys()
        frame.grid(row=row, column=col, sticky='nsew')
        frame.grid_columnconfigure(2, weight=1)
        #    frame.grid_rowconfigure(0, weight=1)

        srow = 0
        self.projectOptions = [
            'old', 'new from PDB', 'new from CCPN', 'new from CYANA'
        ]
        self.projOptionsSelect = RadioButtons(frame,
                                              selected_index=0,
                                              entries=self.projectOptions,
                                              direction='vertical',
                                              select_callback=self.updateGui)
        self.projOptionsSelect.grid(row=srow,
                                    column=0,
                                    rowspan=len(self.projectOptions),
                                    columnspan=2,
                                    sticky='w')

        if self.options.name:
            text = self.options.name
        else:
            text = ''
        # end if
        self.projEntry = Entry(frame,
                               bd=1,
                               text=text,
                               returnCallback=self.updateGui)
        self.projEntry.grid(row=srow, column=2, columnspan=2, sticky='ew')
        #    self.projEntry.bind('<Key>', self.updateGui)
        self.projEntry.bind('<Leave>', self.updateGui)

        projButton = Button(frame,
                            bd=1,
                            command=self.chooseOldProjectFile,
                            text='browse')
        projButton.grid(row=srow, column=3, sticky='ew')

        srow += 1
        self.pdbEntry = Entry(frame, bd=1, text='')
        self.pdbEntry.grid(row=srow, column=2, sticky='ew')
        self.pdbEntry.bind('<Leave>', self.updateGui)

        pdbButton = Button(frame,
                           bd=1,
                           command=self.choosePdbFile,
                           text='browse')
        pdbButton.grid(row=srow, column=3, sticky='ew')

        srow += 1
        self.ccpnEntry = Entry(frame, bd=1, text='')
        self.ccpnEntry.grid(row=srow, column=2, sticky='ew')
        self.ccpnEntry.bind('<Leave>', self.updateGui)

        ccpnButton = Button(frame,
                            bd=1,
                            command=self.chooseCcpnFile,
                            text='browse')
        ccpnButton.grid(row=srow, column=3, sticky='ew')

        srow += 1
        self.cyanaEntry = Entry(frame, bd=1, text='')
        self.cyanaEntry.grid(row=srow, column=2, sticky='ew')
        self.cyanaEntry.bind('<Leave>', self.updateGui)

        cyanaButton = Button(frame,
                             bd=1,
                             command=self.chooseCyanaFile,
                             text='browse')
        cyanaButton.grid(row=srow, column=3, sticky='ew')

        #Empty row
        srow += 1
        label = Label(frame, text='')
        label.grid(row=srow, column=0, sticky='nw')

        srow += 1
        label = Label(frame, text='Project name:')
        label.grid(row=srow, column=0, sticky='nw')
        self.nameEntry = Entry(frame, bd=1, text='')
        self.nameEntry.grid(row=srow, column=2, sticky='w')

        #Empty row
        srow += 1
        label = Label(frame, text='')
        label.grid(row=srow, column=0, sticky='nw')

        srow += 1
        self.openProjectButton = Button(frame,
                                        command=self.openProject,
                                        text='Open Project',
                                        **actionButtonAttributes)
        self.openProjectButton.grid(row=srow,
                                    column=0,
                                    columnspan=4,
                                    sticky='ew')

        #----------------------------------------------------------------------------------
        # status
        #----------------------------------------------------------------------------------
        #    guiFrame.grid_columnconfigure(1, weight=0)
        srow = 0
        frame = LabelFrame(guiFrame, text='Status', **labelFrameAttributes)
        frame.grid(row=srow, column=1, sticky='wnes')
        self.projectStatus = Text(frame,
                                  height=11,
                                  width=70,
                                  borderwidth=0,
                                  relief='flat')
        self.projectStatus.grid(row=0, column=0, sticky='wen')

        #Empty row
        srow += 1
        label = Label(frame, text='')
        label.grid(row=srow, column=0, sticky='nw')

        srow += 1
        self.closeProjectButton = Button(frame,
                                         command=self.closeProject,
                                         text='Close Project',
                                         **actionButtonAttributes)
        self.closeProjectButton.grid(row=srow,
                                     column=0,
                                     columnspan=4,
                                     sticky='ew')

        #----------------------------------------------------------------------------------
        # Validate frame
        #----------------------------------------------------------------------------------

        row += 1
        col = 0
        frame = LabelFrame(guiFrame, text='Validate', **labelFrameAttributes)
        #    frame = LabelFrame(guiFrame, text='Validate', font=medFont)
        frame.grid(row=row, column=col, sticky='nsew')
        #    frame.grid_columnconfigure(2, weight=1)
        frame.grid_rowconfigure(0, weight=1)

        srow = 0
        #    label = Label(frame, text='validation')
        #    label.grid(row=srow,column=0,sticky='nw')
        #
        #    self.selectDoValidation = CheckButton(frame)
        #    self.selectDoValidation.grid(row=srow, column=1,sticky='nw' )
        #    self.selectDoValidation.set(True)
        #
        #    srow += 1
        #    label = Label(frame, text='')
        #    label.grid(row=srow,column=0,sticky='nw')
        #
        #    srow += 1
        label = Label(frame, text='checks')
        label.grid(row=srow, column=0, sticky='nw')

        self.selectCheckAssign = CheckButton(frame)
        self.selectCheckAssign.grid(row=srow, column=1, sticky='nw')
        self.selectCheckAssign.set(True)
        label = Label(frame, text='assignments and shifts')
        label.grid(row=srow, column=2, sticky='nw')

        #    srow += 1
        #    self.selectCheckQueen = CheckButton(frame)
        #    self.selectCheckQueen.grid(row=srow, column=4,sticky='nw' )
        #    self.selectCheckQueen.set(False)
        #    label = Label(frame, text='QUEEN')
        #    label.grid(row=srow,column=5,sticky='nw')
        #
        #    queenButton = Button(frame, bd=1,command=None, text='setup')
        #    queenButton.grid(row=srow,column=6,sticky='ew')

        srow += 1
        self.selectCheckResraint = CheckButton(frame)
        self.selectCheckResraint.grid(row=srow, column=1, sticky='nw')
        self.selectCheckResraint.set(True)
        label = Label(frame, text='restraints')
        label.grid(row=srow, column=2, sticky='nw')

        srow += 1
        self.selectCheckStructure = CheckButton(frame)
        self.selectCheckStructure.grid(row=srow, column=1, sticky='nw')
        self.selectCheckStructure.set(True)
        label = Label(frame, text='structural')
        label.grid(row=srow, column=2, sticky='nw')

        srow += 1
        self.selectMakeHtml = CheckButton(frame)
        self.selectMakeHtml.grid(row=srow, column=1, sticky='nw')
        self.selectMakeHtml.set(True)
        label = Label(frame, text='generate HTML')
        label.grid(row=srow, column=2, sticky='nw')

        srow += 1
        self.selectCheckScript = CheckButton(frame)
        self.selectCheckScript.grid(row=srow, column=1, sticky='nw')
        self.selectCheckScript.set(False)
        label = Label(frame, text='user script')
        label.grid(row=srow, column=0, sticky='nw')

        self.validScriptEntry = Entry(frame, bd=1, text='')
        self.validScriptEntry.grid(row=srow,
                                   column=2,
                                   columnspan=3,
                                   sticky='ew')

        scriptButton = Button(frame,
                              bd=1,
                              command=self.chooseValidScript,
                              text='browse')
        scriptButton.grid(row=srow, column=5, sticky='ew')

        srow += 1
        label = Label(frame, text='ranges')
        label.grid(row=srow, column=0, sticky='nw')
        self.rangesEntry = Entry(frame, text='')
        self.rangesEntry.grid(row=srow, column=2, columnspan=3, sticky='ew')

        #    self.validScriptEntry = Entry(frame, bd=1, text='')
        #    self.validScriptEntry.grid(row=srow,column=3,sticky='ew')
        #
        #    scriptButton = Button(frame, bd=1,command=self.chooseValidScript, text='browse')
        #    scriptButton.grid(row=srow,column=4,sticky='ew')

        srow += 1
        texts = ['Run Validation', 'View Results', 'Setup QUEEN']
        commands = [self.runCing, None, None]
        buttonBar = ButtonList(frame,
                               texts=texts,
                               commands=commands,
                               expands=True)
        buttonBar.grid(row=srow, column=0, columnspan=6, sticky='ew')
        for button in buttonBar.buttons:
            button.config(**actionButtonAttributes)
        # end for
        self.runButton = buttonBar.buttons[0]
        self.viewResultButton = buttonBar.buttons[1]
        self.queenButton = buttonBar.buttons[2]

        #----------------------------------------------------------------------------------
        # Miscellaneous frame
        #----------------------------------------------------------------------------------

        row += 0
        col = 1
        #    frame = LabelFrame(guiFrame, text='Miscellaneous', font=medFont)
        frame = LabelFrame(guiFrame,
                           text='Miscellaneous',
                           **labelFrameAttributes)
        frame.grid(row=row, column=col, sticky='news')
        frame.grid_columnconfigure(2, weight=1)
        frame.grid_columnconfigure(4, weight=1, minsize=30)
        frame.grid_rowconfigure(0, weight=1)

        # Exports

        srow = 0
        label = Label(frame, text='export to')
        label.grid(row=srow, column=0, sticky='nw')

        self.selectExportXeasy = CheckButton(frame)
        self.selectExportXeasy.grid(row=srow, column=1, sticky='nw')
        self.selectExportXeasy.set(True)
        label = Label(frame, text='Xeasy, Sparky, TALOS, ...')
        label.grid(row=srow, column=2, sticky='nw')

        srow += 1
        self.selectExportCcpn = CheckButton(frame)
        self.selectExportCcpn.grid(row=srow, column=1, sticky='nw')
        self.selectExportCcpn.set(True)
        label = Label(frame, text='CCPN')
        label.grid(row=srow, column=2, sticky='nw')

        srow += 1
        self.selectExportQueen = CheckButton(frame)
        self.selectExportQueen.grid(row=srow, column=1, sticky='nw')
        self.selectExportQueen.set(True)
        label = Label(frame, text='QUEEN')
        label.grid(row=srow, column=2, sticky='nw')

        srow += 1
        self.selectExportRefine = CheckButton(frame)
        self.selectExportRefine.grid(row=srow, column=1, sticky='nw')
        self.selectExportRefine.set(True)
        label = Label(frame, text='refine')
        label.grid(row=srow, column=2, sticky='nw')

        srow += 1
        label = Label(frame, text='')
        label.grid(row=srow, column=0, sticky='nw')

        # User script

        srow += 1
        label = Label(frame, text='user script')
        label.grid(row=srow, column=0, sticky='nw')

        self.selectMiscScript = CheckButton(frame)
        self.selectMiscScript.grid(row=srow, column=1, sticky='nw')
        self.selectMiscScript.set(False)

        self.miscScriptEntry = Entry(frame, bd=1, text='')
        self.miscScriptEntry.grid(row=srow, column=3, sticky='ew')

        script2Button = Button(frame,
                               bd=1,
                               command=self.chooseMiscScript,
                               text='browse')
        script2Button.grid(row=srow, column=4, sticky='ew')

        srow += 1
        texts = ['Export', 'Run Script']
        commands = [None, None]
        buttonBar = ButtonList(frame,
                               texts=texts,
                               commands=commands,
                               expands=True)
        buttonBar.grid(row=srow, column=0, columnspan=5, sticky='ew')
        for button in buttonBar.buttons:
            button.config(**actionButtonAttributes)
        # end for
        self.exportButton = buttonBar.buttons[0]
        self.scriptButton = buttonBar.buttons[1]

        #----------------------------------------------------------------------------------
        # Textarea
        #----------------------------------------------------------------------------------
        row += 1
        guiFrame.grid_rowconfigure(row, weight=1)
        self.outputTextBox = ScrolledText(guiFrame)
        self.outputTextBox.grid(row=row, column=0, columnspan=2, sticky='nsew')

        self.redirectConsole()

        #----------------------------------------------------------------------------------
        # Buttons
        #----------------------------------------------------------------------------------
        row += 1
        col = 0
        texts = ['Quit', 'Help']
        commands = [self.close, None]
        self.buttonBar = ButtonList(guiFrame,
                                    texts=texts,
                                    commands=commands,
                                    expands=True)
        self.buttonBar.grid(row=row, column=col, columnspan=2, sticky='ew')

        #    self.openProjectButton = self.buttonBar.buttons[0]
        #    self.closeProjectButton = self.buttonBar.buttons[1]
        #    self.runButton = self.buttonBar.buttons[0]
        #    self.viewResultButton = self.buttonBar.buttons[1]

        for button in self.buttonBar.buttons:
            button.config(**actionButtonAttributes)