Example #1
0
    def body(self, master):

        self.geometry('600x400')

        #
        # Quick check
        #

        if not self.chains:
            showError("No chains",
                      "No chains available - cannot use export/import cycle.")
            self.destroy()

        #
        # Set it all up
        #

        columnspan = 2

        row = 0

        label = Label(master, text="AutoAssign export/import cycle.")
        label.grid(row=row, column=0, columnspan=columnspan, sticky=Tkinter.EW)

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row,
                       column=0,
                       columnspan=columnspan,
                       sticky=Tkinter.EW)

        row += 1

        label = Label(
            master,
            fg='red',
            text=
            "Popup to export %s data from the CCPN data model,\nrun %s, then re-import the output."
            % (self.format, self.format))
        label.grid(row=row, column=0, columnspan=columnspan, sticky=Tkinter.EW)

        #
        # Make a break...
        #

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row,
                       column=0,
                       columnspan=columnspan,
                       sticky=Tkinter.EW)

        #
        # Set up export file info
        #

        row += 1

        label = Label(master,
                      text="Export menu (using date/time label '%s')" %
                      self.dateTimeFlag)
        label.grid(row=row, column=0, columnspan=columnspan, sticky=Tkinter.EW)

        row += 1

        (chainList, self.chainDict) = createSelection(self.chains)

        label = Label(master, text="Select chain to export:")
        label.grid(row=row, column=0, sticky=Tkinter.W)

        self.chainSelect = PulldownMenu(master, entries=chainList)
        self.chainSelect.grid(row=row, column=1, sticky=Tkinter.W)

        row += 1

        label = Label(master, text="Export %s project file:" % self.format)
        label.grid(row=row, column=0, sticky=Tkinter.W)

        self.selectExportFileButton = Tkinter.Button(
            master,
            text='Select export file',
            command=(lambda: self.selectExportProjectFile()))
        self.selectExportFileButton.grid(row=row, column=1, sticky=Tkinter.W)

        row += 1

        self.exportButton = Tkinter.Button(master,
                                           text='Export',
                                           command=(lambda: self.doExport()))
        self.exportButton.grid(row=row,
                               column=0,
                               columnspan=columnspan,
                               sticky=Tkinter.EW)

        #
        # Make a break...
        #

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row,
                       column=0,
                       columnspan=columnspan,
                       sticky=Tkinter.EW)

        #
        # Set up import file info
        #

        row += 1

        label = Label(master, text="Re-import menu")
        label.grid(row=row, column=0, columnspan=columnspan, sticky=Tkinter.EW)

        row += 1

        #
        # Select the right chain with the right date/time flag...
        #

        label = Label(master, text="Select chain with correct date/time flag:")
        label.grid(row=row, column=0, sticky=Tkinter.W)

        self.chainDateTimeSelect = PulldownMenu(
            master, entries=self.chainDateTimeStamps)
        self.chainDateTimeSelect.grid(row=row, column=1, sticky=Tkinter.W)
        # TODO UPDATE THIS WHEN EXPORT BUTTON PRESSED AND GETTING OK FROM EXPORT ITSELF!
        # Probably also need just a message if no importDateTimeStamp available...

        row += 1

        label = Label(master, text="Import %s output file:" % self.format)
        label.grid(row=row, column=0, sticky=Tkinter.W)

        self.selectImportFileButton = Tkinter.Button(
            master,
            text='Select import file',
            command=(lambda: self.selectImportShiftFile()))
        self.selectImportFileButton.grid(row=row, column=1, sticky=Tkinter.W)

        row += 1

        self.importButton = Tkinter.Button(master,
                                           text='Import',
                                           command=(lambda: self.doImport()))
        self.importButton.grid(row=row,
                               column=0,
                               columnspan=columnspan,
                               sticky=Tkinter.EW)

        #
        # Make a break...
        #

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row,
                       column=0,
                       columnspan=columnspan,
                       sticky=Tkinter.EW)

        row += 1

        buttons = createDismissHelpButtonList(master,
                                              texts=[],
                                              commands=[],
                                              help_url=self.help_url)
        buttons.grid(row=row, columnspan=columnspan, column=0)
Example #2
0
  def body(self, master):
      
    #
    # Popup window
    #
    
    self.columnspan = len(self.chemCompAtoms[0])

    row = 0
    label = Label(master, text= "Molecule type '%s', ccp code '%s'" % (self.chemCompInfo[0][1],self.chemCompInfo[1][1]))
    label.grid(row=row, column=0, columnspan = self.columnspan, sticky=Tkinter.EW)
    
    #
    # Warning message if necessary!
    #
    
    if self.obligatoryAtoms:
      row += 1
      
      label = Label(master, text= "Warning: have to define atoms: %s!" % string.join(self.obligatoryAtoms,', '), fg = 'red')
      label.grid(row=row, column=0, columnspan = self.columnspan, sticky=Tkinter.EW)
    
    #
    # Show top information...
    #
    
    row = row + 1
    colNum = 0
    self.frameWidth = 0
    
    for chemCompAtomInfo in self.chemCompAtoms[0]:
      
      attrName = chemCompAtomInfo[0]

      label = Label(master, text = attrName, width = len(attrName) + 2)
      label.grid(row=row, column=colNum, sticky=Tkinter.EW)
      
      self.frameWidth += len(attrName) + 2
      colNum += 1
    
    #
    # Separator
    #
    
    row += 1

    separator = Separator(master, height = 3)
    separator.setColor('black', bgColor = 'black')
    separator.grid(row = row, columnspan = self.columnspan, sticky = Tkinter.EW)
      
    #
    # Separate frame for info (have to be able to scroll)
    #
    
    row += 1
    
    # THIS BIT TELLS MASTER TO CONFIGURE WINDOW ON INSIDE WIDGET!!
    master.grid_rowconfigure(row,weight = 1)
    for i in range(self.columnspan):
      master.grid_columnconfigure(i,weight = 1)
    
    self.atomFrame = ScrolledFrame(master, width = self.frameWidth, height = 300, doExtraConfig = False)
    self.atomFrame.grid(row=row, column=0, columnspan = self.columnspan, sticky=Tkinter.NSEW)
    self.atomFrameRow = row
    self.atomFrameMaster = master

    #
    # Separator
    #
    
    row += 1

    separator = Separator(master, height = 3)
    separator.setColor('black', bgColor = 'black')
    separator.grid(row = row, columnspan = self.columnspan, sticky = Tkinter.EW)
          
    #
    # End bit...
    #
    
    row = row + 1
    texts = [ 'OK', 'Update' ]
    commands = [ self.ok, self.update ]   # 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 = self.columnspan)
    
    self.setupAtomFrame()
    def body(self, master):

        self.geometry('600x400')

        columnspan = 5

        row = 0

        label = Label(master, text="AutoAssign project file setup window.")
        label.grid(row=row, column=0, columnspan=columnspan, sticky=Tkinter.W)

        #
        # Set up the spectra
        #

        row += 1

        label = Label(master, text="Spectrum type")
        label.grid(row=row, column=0, columnspan=2, sticky=Tkinter.W)

        label = Label(master, text="CCPN peak list")
        label.grid(row=row, column=2, columnspan=2, sticky=Tkinter.W)

        label = Label(master, text="Phase")  # TODO What's this?
        label.grid(row=row, column=4, sticky=Tkinter.W)

        self.spectrumSelectWidget = {}
        self.spectrumPhaseWidget = {}

        for i in range(len(self.autoAssignProjectFile.defaultSpectra)):

            row += 1

            specType = self.autoAssignProjectFile.defaultSpectra[i][0]

            if i == 0:
                labelText = "%s (root)" % specType
            else:
                labelText = "%s" % specType

            label = Label(master, text=labelText)
            label.grid(row=row, column=0, columnspan=2, sticky=Tkinter.W)

            self.spectrumSelectWidget[specType] = PulldownMenu(
                master, entries=self.peakNameList)
            self.spectrumSelectWidget[specType].grid(row=row,
                                                     column=2,
                                                     columnspan=2,
                                                     sticky=Tkinter.W)

            self.spectrumPhaseWidget[specType] = Entry(master,
                                                       text="",
                                                       width=4)
            self.spectrumPhaseWidget[specType].grid(row=row,
                                                    column=4,
                                                    sticky=Tkinter.W)

        #
        # Make a break...
        #

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row,
                       column=0,
                       columnspan=columnspan,
                       sticky=Tkinter.EW)

        #
        # Set up the tolerances
        #

        row += 1

        label = Label(master, text="Atom tolerances")
        label.grid(row=row, column=0, columnspan=columnspan, sticky=Tkinter.EW)

        toleranceAtoms = self.autoAssignProjectFile.toleranceAtoms
        toleranceDefault = self.autoAssignProjectFile.toleranceDefault

        self.toleranceWidget = {}

        for i in range(0, len(toleranceAtoms), 2):
            row += 1
            for j in range(2):
                curPos = i + j

                if curPos == len(toleranceAtoms):
                    break

                toleranceAtom = toleranceAtoms[curPos]

                label = Label(master, text=toleranceAtom)
                label.grid(row=row, column=2 * j, sticky=Tkinter.E)

                self.toleranceWidget[toleranceAtom] = Entry(
                    master, text=str(toleranceDefault[curPos]), width=6)
                self.toleranceWidget[toleranceAtom].grid(row=row,
                                                         column=1 + 2 * j,
                                                         sticky=Tkinter.W)

        #
        # Make a break...
        #

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row,
                       column=0,
                       columnspan=columnspan,
                       sticky=Tkinter.EW)

        row += 1

        label = Label(
            master,
            text="Will save the peak files in the project file directory.",
            fg='red')
        label.grid(row=row, column=0, columnspan=columnspan, sticky=Tkinter.EW)

        row += 1

        texts = ['OK']
        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=columnspan, column=0)
Example #4
0
  def __init__(self, parent, project, path = None,
               molTypeEntries = None, chemCompEntries = None,
               selectedChemComps = None, selectLinking = None,
               *args, **kw):

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

    self.project = project
    self.molTypeEntries = molTypeEntries
    self.chemCompEntries = chemCompEntries
    self.selectLinking = selectLinking

    if (not path):
      path = getDataPath()

    self.path = path
      
    # Check if all chemComps available locally
    self.path_allChemComps = getChemCompArchiveDataDir()
    if not os.path.exists(self.path_allChemComps):
      self.path_allChemComps = None

    self.chemCompInfoDict = {}
    self.chemCompInfoList = []
    self.chemCompDownload = False
    self.chem_comps_shown = {}

    for entry in chemCompList:
      self.chemCompClasses[entry] = getattr(ccp.api.molecule.ChemComp, entry)

    self.grid_columnconfigure(0, weight=1)

    row = 0
    
    if (molTypeEntries is None):
      headerText = "Show residues (select molecular type(s)):"
    else:
      headerText = "Show %s residues:" % (str(molTypeEntries))
    
    #
    #
    # TODO TODO: HERE need to do some niftier stuff for displaying!
    #
    #
    
    headerTextWidget = Label(self, text = headerText)
    headerTextWidget.grid(row=row, column=0, sticky=Tkinter.W)
    row = row + 1

    if (molTypeEntries is None):
      self.mol_type_buttons = CheckButtons(self, entries=molTypeList,
                                select_callback=self.updateTables)
      self.mol_type_buttons.grid(row=row, column=0, sticky=Tkinter.EW)
      row = row + 1
    else:
      self.mol_type_buttons = None

    #
    # The chemComps to display...
    #
    
    self.showLocalText = 'Show local'
    self.showWebText = 'Show available via web'
    self.display_buttons = CheckButtons(self, entries=[self.showLocalText,self.showWebText],
                                              select_callback=self.updateTables,
                                              selected = [self.showLocalText])
    self.display_buttons.grid(row=row, column=0, sticky=Tkinter.EW)
    row = row + 1

    self.grid_rowconfigure(row, weight=2)
    headings = ('number', 'show details', 'molType', 'ccpCode', 'code1Letter', 'cifCode', 'name')
    editWidgets = 7 * [ None ]
    editGetCallbacks = [ None, self.toggleShow, None, None, None, None, None ]
    editSetCallbacks = 7 * [ None ]
    self.chem_comp_table = ScrolledMatrix(self, headingList=headings,
                                  editWidgets=editWidgets,
                                  editGetCallbacks=editGetCallbacks,
                                  editSetCallbacks=editSetCallbacks)
    self.chem_comp_table.grid(row=row, column=0, sticky=Tkinter.NSEW)

    row = row + 1
    texts = [ 'Show all in details window', 'Clear details window' ]
    commands = [ self.showAll, self.showNone ]
    buttons = ButtonList(self, texts=texts, commands=commands)
    buttons.grid(row=row, column=0, sticky=Tkinter.EW)
    
    row = row + 1

    separator = Separator(self,height = 3)
    separator.setColor('black', bgColor = 'black')
    separator.grid(row=row, column=0, sticky=Tkinter.EW)

    row = row + 1
    
    headerTextWidget = Label(self, text = "Select the residue variant:")
    headerTextWidget.grid(row=row, column=0, sticky=Tkinter.W)

    row = row + 1
    if (chemCompEntries is None):
      self.chem_comp_buttons = CheckButtons(self, entries=chemCompList,
                                 selected=('ChemComp',),
                                 select_callback=self.updateChemCompVarTable)
      self.chem_comp_buttons.grid(row=row, column=0, sticky=Tkinter.EW)
      row = row + 1
    else:
      self.chem_comp_buttons = None

    self.grid_rowconfigure(row, weight=1)
    headings = ('number', 'molType', 'ccpCode', 'linking', 'descriptor', 'molecularMass', 'formula', 'nonStereoSmiles', 'stereoSmiles')
    self.chem_comp_var_table = ScrolledMatrix(self, headingList=headings)
    self.chem_comp_var_table.grid(row=row, column=0, sticky=Tkinter.NSEW)
    self.chem_comp_var_headings = headings[1:]
    
    if selectedChemComps:
      for chemComp in selectedChemComps:
        key = (chemComp.molType, chemComp.ccpCode)
        self.chem_comps_shown[key] = 1

    self.updateTables()
Example #5
0
    def body(self, master):

        self.geometry('700x500')

        #
        # Setup header
        #

        row = 0

        label = Label(master, text='Original', width=10)
        label.grid(row=row, column=0, sticky=Tkinter.EW)

        label = Label(master, text='Modify ChemCompVar', width=35)
        label.grid(row=row, column=1, sticky=Tkinter.EW)

        label = Label(master, text='Status', width=20)
        label.grid(row=row, column=2, sticky=Tkinter.EW)

        label = Label(master, text='', width=5)
        label.grid(row=row, column=3, sticky=Tkinter.EW)

        row += 1

        label = Label(master, text='code', width=10)
        label.grid(row=row, column=0, sticky=Tkinter.EW)

        label = Label(master,
                      text='ccpCode (molType): linking, descriptor',
                      width=35)
        label.grid(row=row, column=1, sticky=Tkinter.EW)

        label = Tkinter.Button(master,
                               text='Add new molecule',
                               command=self.addNewMolecule)
        label.grid(row=row, column=2)

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row, columnspan=3, sticky=Tkinter.EW)

        row += 1

        # THIS BIT TELLS MASTER TO CONFIGURE WINDOW ON INSIDE WIDGET!!
        master.grid_rowconfigure(row, weight=1)
        for i in range(4):
            master.grid_columnconfigure(i, weight=1)
        self.sequenceFrame = ScrolledFrame(master,
                                           width=70,
                                           height=300,
                                           doExtraConfig=False)
        self.sequenceFrame.grid(row=row,
                                column=0,
                                columnspan=4,
                                sticky=Tkinter.NSEW)
        self.sequenceFrameRow = row
        self.sequenceFrameMaster = master

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row, columnspan=3, sticky=Tkinter.EW)

        row += 1

        texts = ['Change', 'Change and quit']
        commands = [
            self.updateMolDict, self.ok
        ]  # This calls 'ok' in BasePopup, this then calls 'apply' in here
        buttons = createDismissHelpButtonList(master,
                                              texts=texts,
                                              commands=commands,
                                              dismiss_text='Cancel',
                                              help_url=self.help_url)
        buttons.grid(row=row, column=0, columnspan=3, sticky=Tkinter.EW)

        self.setupSequenceFrame()
Example #6
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
Example #7
0
    def body(self, master):

        #
        # Setup header
        #

        row = 0

        label = Label(master, text='Select the resonance list:')
        label.grid(row=row, column=0, sticky=Tkinter.EW)

        label = Label(master, text='Select the chain:')
        label.grid(row=row, column=1, sticky=Tkinter.EW)

        row += 1

        self.resParentSelect = PulldownMenu(master,
                                            entries=self.resParentList,
                                            callback=self.setupResParentList,
                                            do_initial_callback=False)
        self.resParentSelect.grid(row=row, column=0, sticky=Tkinter.EW)

        self.chainSelect = PulldownMenu(master,
                                        entries=[],
                                        callback=self.setupProchiralList,
                                        do_initial_callback=False)
        self.chainSelect.grid(row=row, column=1, sticky=Tkinter.EW)

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row, columnspan=2, sticky=Tkinter.EW)

        row += 1

        # THIS BIT TELLS MASTER TO CONFIGURE WINDOW ON INSIDE WIDGET!!
        master.grid_rowconfigure(row, weight=1)
        for i in range(2):
            master.grid_columnconfigure(i, weight=1)

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

        row = row + 1

        texts = ['Set all', 'Set chain']
        commands = [
            self.ok, self.setStereo
        ]  # This calls 'ok' in BasePopup, this then calls 'apply' in here
        buttons = createDismissHelpButtonList(master,
                                              texts=texts,
                                              commands=commands,
                                              dismiss_text='Exit',
                                              help_url=self.help_url)
        buttons.grid(row=row, column=0, columnspan=2, sticky=Tkinter.EW)

        self.resParentSelect.callback(0, self.resParentList[0])
Example #8
0
    def body(self, master):

        #
        # Setup header
        #

        row = 0
        self.columnSpan = 3

        label = Label(
            master,
            text=
            'Select molecular system, chains and chemical shift list to be analyzed:'
        )
        label.grid(row=row,
                   column=0,
                   columnspan=self.columnSpan,
                   sticky=Tkinter.EW)

        row += 1

        self.molSysSelect = PulldownMenu(master,
                                         entries=self.molSysLabelList,
                                         callback=self.setupChains)
        self.molSysSelect.grid(row=row, column=0, sticky=Tkinter.W)

        self.chainSelect = PulldownMenu(master,
                                        entries=self.chainLabelList,
                                        callback=self.setupShiftList)
        self.chainSelect.grid(row=row, column=1, sticky=Tkinter.W)

        self.shiftListSelect = PulldownMenu(master,
                                            entries=self.shiftListLabels,
                                            callback=self.setupPercentageFrame,
                                            do_initial_callback=False)
        self.shiftListSelect.grid(row=row, column=2, sticky=Tkinter.W)

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row, columnspan=self.columnSpan, sticky=Tkinter.EW)

        row += 1

        master.grid_rowconfigure(row, weight=1)
        for i in range(self.columnSpan):
            master.grid_columnconfigure(i, weight=1)

        self.percentageFrame = ScrolledFrame(master,
                                             height=180,
                                             doExtraConfig=False)
        self.percentageFrame.grid(row=row,
                                  columnspan=self.columnSpan,
                                  sticky=Tkinter.NSEW)
        self.percentageFrameRow = row
        self.percentageFrameMaster = master

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row, columnspan=self.columnSpan, sticky=Tkinter.EW)

        row += 1

        master.grid_rowconfigure(row, weight=1)
        self.resultsFrame = ScrolledFrame(master,
                                          height=180,
                                          doExtraConfig=False)
        self.resultsFrame.grid(row=row,
                               columnspan=self.columnSpan,
                               sticky=Tkinter.NSEW)
        self.resultsFrameRow = row
        self.resultsFrameMaster = master

        row += 1

        separator = Separator(master, height=3)
        separator.setColor('black', bgColor='black')
        separator.grid(row=row, columnspan=self.columnSpan, sticky=Tkinter.EW)

        row += 1

        texts = ['Recalculate', 'Write to file']
        commands = [
            self.recalc, self.writeFile
        ]  # This calls 'ok' in BasePopup, this then calls 'apply' in here
        buttons = createDismissHelpButtonList(master,
                                              texts=texts,
                                              commands=commands,
                                              dismiss_text='Exit',
                                              help_url=self.help_url)
        buttons.grid(row=row, columnspan=self.columnSpan, sticky=Tkinter.EW)

        self.shiftListSelect.callback(0, self.shiftListLabels[0])
Example #9
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()