Example #1
0
    def __init__(self, title, message, texts, objects=None, parent=None):

        if parent is None:
            parent = Tkinter.Tk()
            #parent.withdraw()
            self.root = parent
            parent.protocol('WM_DELETE_WINDOW', self.destroy)

        else:
            self.root = None

        Tkinter.Toplevel.__init__(self, parent)

        self.resizable(0, 0)
        self.parent = parent
        self.title(title)
        self.var = Tkinter.IntVar()
        self.objects = objects or range(len(texts))

        assert len(self.objects) == len(texts)

        x = parent.winfo_rootx() + parent.winfo_width() / 2
        y = parent.winfo_rooty() + parent.winfo_height() / 2
        location = '+%d+%d' % (x, y)

        if hasattr(parent, 'font'):
            self.font = parent.font
        else:
            self.font = None

        Tkinter.Toplevel.geometry(self, location)
        Tkinter.Toplevel.lift(self, parent)
        self.update_idletasks()
        self.transient(parent)

        self.protocol('WM_DELETE_WINDOW', self._null)
        self.focus_force()
        self.grab_set()

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

        label = Label(self, text=message, grid=(0, 0))
        self.config(bg=label.cget('bg'))

        frame = Frame(self, grid=(1, 0))

        _buttons = []
        for i, text in enumerate(texts):
            button = Button(frame,
                            text=text,
                            command=lambda j=i: self._click(j))
            button.grid(row=i + 1, column=0, padx=2, pady=2, sticky='ew')
            if objects[i] is None:
                button.config(bg='#B0FFB0')
            _buttons.append(button)

        self._wait()
Example #2
0
def createQuitButton(parent, text=''):

  if not text:
    text = ''

  b = Button(parent, text=text, command=sys.exit)
  
  if not text:
    b.cancelIcon = Tkinter.PhotoImage(file=os.path.join(gfxDir,'cancel.gif'))
    b.config(image=b.cancelIcon, activebackground=b.cget('bg'))

  return b
Example #3
0
def createDismissButton(parent, dismiss_text = '', dismiss_cmd = None):

  if (not dismiss_text):
    dismiss_text = ''

  if (not dismiss_cmd):
    popup = parent
    while (not hasattr(popup, 'top')):
      popup = popup.parent
    dismiss_cmd = popup.close

  b = Button(parent, text=dismiss_text, command=dismiss_cmd)
  if not dismiss_text:
    b.cancelIcon = Tkinter.PhotoImage(file=os.path.join(gfxDir,'cancel.gif'))
    b.config(image=b.cancelIcon, activebackground=b.cget('bg'))

  return b
Example #4
0
  def __init__(self, parent, application, *args, **kw):

    project = application.project
    simStore = project.findFirstNmrSimStore(application=APP_NAME) or \
               project.newNmrSimStore(application=APP_NAME, name=APP_NAME)

    self.application = application
    self.residue = None
    self.structure = None
    self.serverCredentials = None
    self.iCingBaseUrl = DEFAULT_URL
    self.resultsUrl = None
    self.chain = None
    self.nmrProject = application.nmrProject
    self.serverDone = False

    NmrSimRunFrame.__init__(self, parent, project, simStore, *args, **kw)

    # # # # # # New Structure Frame # # # # #

    self.structureFrame.grid_forget()

    tab = self.tabbedFrame.frames[0]

    frame = Frame(tab, grid=(1,0))
    frame.expandGrid(2,1)

    div = LabelDivider(frame, text='Structures', grid=(0,0), gridSpan=(1,2))

    label = Label(frame, text='Ensemble: ', grid=(1,0))
    self.structurePulldown = PulldownList(frame, callback=self.changeStructure, grid=(1,1))

    headingList = ['Model','Use']
    editWidgets      = [None,None]
    editGetCallbacks = [None,self.toggleModel]
    editSetCallbacks = [None,None,]
    self.modelTable = ScrolledMatrix(frame, grid=(2,0), gridSpan=(1,2),
                                     callback=self.selectStructModel,
                                     editWidgets=editWidgets,
                                     editGetCallbacks=editGetCallbacks,
                                     editSetCallbacks=editSetCallbacks,
                                     headingList=headingList)

    texts = ['Activate Selected','Inactivate Selected']
    commands = [self.activateModels, self.disableModels]
    buttons = ButtonList(frame, texts=texts, commands=commands, grid=(3,0), gridSpan=(1,2))


    # # # # # # Submission frame # # # # # #

    tab = self.tabbedFrame.frames[1]
    tab.expandGrid(1,0)

    frame = LabelFrame(tab, text='Server Job Submission', grid=(0,0))
    frame.expandGrid(None,2)

    srow = 0
    label = Label(frame, text='iCing URL:', grid=(srow, 0))
    urls = [DEFAULT_URL,]
    self.iCingBaseUrlPulldown = PulldownList(frame, texts=urls, objects=urls, index=0, grid=(srow,1))


    srow +=1
    label = Label(frame, text='Results File:', grid=(srow, 0))
    self.resultFileEntry = Entry(frame, bd=1, text='', grid=(srow,1), width=50)
    self.setZipFileName()
    button = Button(frame, text='Choose File', bd=1, sticky='ew',
                    command=self.chooseZipFile, grid=(srow, 2))

    srow +=1
    label = Label(frame, text='Results URL:', grid=(srow, 0))
    self.resultUrlEntry = Entry(frame, bd=1, text='', grid=(srow,1), width=50)
    button = Button(frame, text='View Results HTML', bd=1, sticky='ew',
                    command=self.viewHtmlResults, grid=(srow, 2))

    srow +=1
    texts    = ['Submit Project!', 'Check Run Status',
                'Purge Server Result', 'Download Results']
    commands = [self.runCingServer, self.checkStatus,
                self.purgeCingServer, self.downloadResults]

    self.buttonBar = ButtonList(frame, texts=texts, commands=commands,
                                grid=(srow, 0), gridSpan=(1,3))

    for button in self.buttonBar.buttons[:1]:
      button.config(bg=CING_BLUE)

    # # # # # # Residue frame # # # # # #

    frame = LabelFrame(tab, text='Residue Options', grid=(1,0))
    frame.expandGrid(1,1)

    label = Label(frame, text='Chain: ')
    label.grid(row=0,column=0,sticky='w')
    self.chainPulldown = PulldownList(frame, callback=self.changeChain)
    self.chainPulldown.grid(row=0,column=1,sticky='w')

    headingList = ['#','Residue','Linking','Decriptor','Use?']
    editWidgets      = [None,None,None,None,None]
    editGetCallbacks = [None,None,None,None,self.toggleResidue]
    editSetCallbacks = [None,None,None,None,None,]
    self.residueMatrix = ScrolledMatrix(frame,
                                        headingList=headingList,
                                        multiSelect=True,
                                        editWidgets=editWidgets,
                                        editGetCallbacks=editGetCallbacks,
                                        editSetCallbacks=editSetCallbacks,
                                        callback=self.selectResidue)
    self.residueMatrix.grid(row=1, column=0, columnspan=2, sticky = 'nsew')

    texts = ['Activate Selected','Inactivate Selected']
    commands = [self.activateResidues, self.deactivateResidues]
    self.resButtons = ButtonList(frame, texts=texts, commands=commands,)
    self.resButtons.grid(row=2, column=0, columnspan=2, sticky='ew')

    """
    # # # # # # Validate frame # # # # # #

    frame = LabelFrame(tab, text='Validation Options', grid=(2,0))
    frame.expandGrid(None,2)

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

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

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

    srow += 1
    self.selectCheckScript = CheckButton(frame)
    self.selectCheckScript.grid(row=srow, column=0,sticky='nw' )
    self.selectCheckScript.set(False)
    label = Label(frame, text='User Python script\n(overriding option)')
    label.grid(row=srow,column=1,sticky='nw')

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

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

    # # # # # # # # # #

    self.update(simStore)

    self.administerNotifiers(application.registerNotify)
Example #5
0
    def __init__(self, parent, application, *args, **kw):

        project = application.project
        self.nmrProject = nmrProject = application.nmrProject

        if project:
            calcStore = project.findFirstNmrCalcStore(name=APP_NAME, nmrProject=nmrProject) or \
                        project.newNmrCalcStore(name=APP_NAME, nmrProject=nmrProject)
        else:
            calcStore = None

        self.application = application
        self.residue = None
        self.structure = None
        self.serverCredentials = None
        self.iCingBaseUrl = DEFAULT_URL
        self.resultsUrl = None
        self.chain = None
        self.serverDone = False

        NmrCalcRunFrame.__init__(self, parent, project, calcStore, *args, **kw)

        # # # # # # New Structure Frame # # # # #

        self.structureTable.grid_forget()
        self.structureButtons.grid_forget()
        self.ensemblePulldown.grid_forget()
        self.modelButtons.grid_forget()
        self.modelPulldown.grid_forget()

        frame = self.inputTabs.frames[0]
        frame.grid_rowconfigure(0, weight=0)
        frame.grid_rowconfigure(1, weight=1)

        label = Label(frame, text='Ensemble: ', grid=(0, 0))
        self.structurePulldown = PulldownList(
            frame,
            callback=self.changeStructure,
            grid=(0, 1),
            tipText='The structure ensemble coordinates to submit')

        tipTexts = [
            'Conformational model number', 'Whether analyse this model'
        ]
        headingList = ['Model', 'Use']
        editWidgets = [None, None]
        editGetCallbacks = [None, self.toggleModel]
        editSetCallbacks = [
            None,
            None,
        ]
        self.modelTable = ScrolledMatrix(frame,
                                         grid=(1, 0),
                                         gridSpan=(1, 2),
                                         callback=self.selectStructModel,
                                         multiSelect=True,
                                         tipTexts=tipTexts,
                                         editWidgets=editWidgets,
                                         initialRows=2,
                                         editGetCallbacks=editGetCallbacks,
                                         editSetCallbacks=editSetCallbacks,
                                         headingList=headingList)

        tipTexts = [
            'Activate the selected models so that they will be consedered in the analysis',
            'Deactivate the selected models so that they will not be considered in the analysis'
        ]
        texts = ['Activate Selected', 'Inactivate Selected']
        commands = [self.activateModels, self.disableModels]
        buttons = ButtonList(frame,
                             texts=texts,
                             commands=commands,
                             grid=(2, 0),
                             gridSpan=(1, 2),
                             tipTexts=tipTexts)

        # # # # # # Submission frame # # # # # #

        tab = self.tabbedFrame.frames[1]
        tab.expandGrid(1, 0)

        frame = LabelFrame(tab, text='Server Job Submission', grid=(0, 0))
        frame.expandGrid(None, 2)

        srow = 0
        label = Label(frame, text='iCing URL:', grid=(srow, 0))
        self.iCingBaseUrlPulldown = PulldownList(
            frame,
            texts=URLS,
            objects=URLS,
            index=0,
            grid=(srow, 1),
            tipText='Web location of iCING server to use')

        srow += 1
        label = Label(frame, text='Results File:', grid=(srow, 0))
        self.resultFileEntry = Entry(
            frame,
            bd=1,
            text='',
            grid=(srow, 1),
            width=50,
            tipText='Name of file to store compressed CING results in')
        self.setZipFileName()
        button = Button(frame,
                        text='Choose File',
                        bd=1,
                        sticky='ew',
                        command=self.chooseZipFile,
                        grid=(srow, 2),
                        tipText='Select file to overwrite with CING results')

        srow += 1
        label = Label(frame, text='Results URL:', grid=(srow, 0))
        self.resultUrlEntry = Entry(
            frame,
            bd=1,
            text='',
            grid=(srow, 1),
            width=50,
            tipText='Web location where CING results will be posted')
        button = Button(frame,
                        text='View Results HTML',
                        bd=1,
                        sticky='ew',
                        command=self.viewHtmlResults,
                        grid=(srow, 2),
                        tipText='Open the HTML CING results in a web browser')

        srow += 1
        tipTexts = [
            'Submit the CCPN project to the CING server',
            'Determin whether the iCING job is complete, pending or has failed',
            'Remove all trace of the last submissionfrom the iCING server',
            'Download the compressed CING results, including HTML'
        ]
        texts = [
            'Submit Project!', 'Check Run Status', 'Purge Server Result',
            'Download Results'
        ]
        commands = [
            self.runCingServer, self.checkStatus, self.purgeCingServer,
            self.downloadResults
        ]

        self.buttonBar = ButtonList(frame,
                                    texts=texts,
                                    commands=commands,
                                    grid=(srow, 0),
                                    gridSpan=(1, 3),
                                    tipTexts=tipTexts)

        for button in self.buttonBar.buttons[:1]:
            button.config(bg=CING_BLUE)

        # # # # # # Residue frame # # # # # #

        frame = LabelFrame(tab, text='Residue Options', grid=(1, 0))
        frame.expandGrid(1, 1)

        label = Label(frame, text='Chain: ')
        label.grid(row=0, column=0, sticky='w')
        self.chainPulldown = PulldownList(
            frame,
            callback=self.changeChain,
            tipText='Select the molecular system chain to consider')
        self.chainPulldown.grid(row=0, column=1, sticky='w')

        headingList = ['#', 'Residue', 'Linking', 'Decriptor', 'Use?']
        tipTexts = [
            'Sequence number', 'Residue type code',
            'In-chain connectivity of residue',
            'Protonation and steriochemical state',
            'Whether to consider the residue in the analysis'
        ]
        editWidgets = [None, None, None, None, None]
        editGetCallbacks = [None, None, None, None, self.toggleResidue]
        editSetCallbacks = [
            None,
            None,
            None,
            None,
            None,
        ]
        self.residueMatrix = ScrolledMatrix(frame,
                                            headingList=headingList,
                                            multiSelect=True,
                                            tipTexts=tipTexts,
                                            editWidgets=editWidgets,
                                            editGetCallbacks=editGetCallbacks,
                                            editSetCallbacks=editSetCallbacks,
                                            callback=self.selectResidue)
        self.residueMatrix.grid(row=1, column=0, columnspan=2, sticky='nsew')

        tipTexts = [
            'Use the selected residues in the analysis',
            'Do not use the selected residues in the analysis'
        ]
        texts = ['Activate Selected', 'Inactivate Selected']
        commands = [self.activateResidues, self.deactivateResidues]
        self.resButtons = ButtonList(frame,
                                     texts=texts,
                                     commands=commands,
                                     tipTexts=tipTexts)
        self.resButtons.grid(row=2, column=0, columnspan=2, sticky='ew')
        """
    # # # # # # Validate frame # # # # # #

    frame = LabelFrame(tab, text='Validation Options', grid=(2,0))
    frame.expandGrid(None,2)

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

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

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

    srow += 1
    self.selectCheckScript = CheckButton(frame)
    self.selectCheckScript.grid(row=srow, column=0,sticky='nw' )
    self.selectCheckScript.set(False)
    label = Label(frame, text='User Python script\n(overriding option)')
    label.grid(row=srow,column=1,sticky='nw')

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

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

        # # # # # # # # # #

        self.update(calcStore)

        self.administerNotifiers(application.registerNotify)