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)
def body(self): frame = self.frame self.resultsResidueNumber = 1 frame.expandGrid(5, 0) resultTopFrame = LabelFrame(frame, text='Which results to show') resultTopFrame.grid(row=0, column=0, sticky='ew') self.resultsResidueNumber = 3 texts = [' < '] commands = [self.resultsPrevResidue] self.resultsPreviousButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsPreviousButton.grid(row=0, column=1, sticky='nsew') tipText = 'The Number of the residue in the sequence to display results for' self.resultsResidueNumberEntry = IntEntry( resultTopFrame, grid=(0, 2), width=7, text=3, returnCallback=self.resultsUpdateAfterEntry, tipText=tipText) #self.resultsResidueNumberEntry.bind('<Leave>', self.resultsUpdateAfterEntry, '+') texts = [' > '] commands = [self.resultsNextResidue] self.resultsNextButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsNextButton.grid(row=0, column=3, sticky='nsew') selectCcpCodes = ['residue'] + AMINO_ACIDS self.resultsSelectedCcpCode = 'residue' tipText = 'Instead of going through the sequence residue by residue, jump directly to next amino acid of a specific type.' resultsSelectCcpCodeLabel = Label( resultTopFrame, text='Directly jump to previous/next:', grid=(0, 4)) self.resultsSelectCcpCodePulldown = PulldownList( resultTopFrame, callback=self.resultsChangeSelectedCcpCode, texts=selectCcpCodes, index=selectCcpCodes.index(self.resultsSelectedCcpCode), grid=(0, 5), tipText=tipText) self.selectedSolution = 1 runLabel = Label(resultTopFrame, text='run:') runLabel.grid(row=0, column=6) texts = [' < '] commands = [self.resultsPrevSolution] self.resultsPreviousSolutionButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsPreviousSolutionButton.grid(row=0, column=7, sticky='nsew') tipText = 'If you ran the algorithm more than once, you can select the solution given by the different runs.' self.resultsSolutionNumberEntry = IntEntry( resultTopFrame, grid=(0, 8), width=7, text=1, returnCallback=self.solutionUpdateAfterEntry, tipText=tipText) #self.resultsSolutionNumberEntry.bind('<Leave>', self.solutionUpdateAfterEntry, '+') texts = [' > '] commands = [self.resultsNextSolution] self.resultsNextSolutionButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.resultsNextSolutionButton.grid(row=0, column=9, sticky='nsew') self.energyLabel = Label(resultTopFrame, text='energy:') self.energyLabel.grid(row=0, column=10) texts = ['template for puzzling'] commands = [self.adoptSolution] self.adoptButton = ButtonList(resultTopFrame, commands=commands, texts=texts) self.adoptButton.grid(row=0, column=11, sticky='nsew') # LabelFrame(frame, text='Spin Systems') resultsSecondFrame = Frame(frame) resultsSecondFrame.grid(row=2, column=0, sticky='nsew') resultsSecondFrame.grid_columnconfigure(0, weight=1) resultsSecondFrame.grid_columnconfigure(1, weight=1) resultsSecondFrame.grid_columnconfigure(2, weight=1) resultsSecondFrame.grid_columnconfigure(3, weight=1) resultsSecondFrame.grid_columnconfigure(4, weight=1) headingList = ['#', '%'] tipTexts = [ 'Spinsystem number {} indicates serial of the spinsystem. If the spinsystem was already assigned to a residue, the residue number is shown aswell', 'percentage of the solutions that connected this spinsystem to this residue' ] editWidgets = [None, None, None] self.displayResultsTables = [] self.residueLabels = [] for i in range(5): label = Label(resultsSecondFrame, text='residue') label.grid(row=0, column=i) #editGetCallbacks = [createCallbackFunction(i)]*3 displayResultsTable = ScrolledMatrix( resultsSecondFrame, headingList=headingList, multiSelect=False, tipTexts=tipTexts, callback=self.selectSpinSystemForTable, passSelfToCallback=True) displayResultsTable.grid(row=2, column=i, sticky='nsew') displayResultsTable.sortDown = False self.residueLabels.append(label) self.displayResultsTables.append(displayResultsTable) # LabelFrame(frame, text='Sequence Fragment') resultsFirstFrame = Frame(resultsSecondFrame) resultsFirstFrame.grid(row=1, column=0, sticky='ew', columnspan=5) resultsFirstFrame.grid_rowconfigure(0, weight=1) resultsFirstFrame.grid_rowconfigure(1, weight=1) resultsFirstFrame.grid_columnconfigure(0, weight=1) texts = [ ' res 1 ', ' links ', ' res 2 ', ' links ', ' res 3 ', ' links ', ' res 4 ', ' links ', ' res 5 ' ] commands = [ lambda: self.selectRelativeResidue(1, True), lambda: self.selectLink(1, True), lambda: self.selectRelativeResidue(2, True), lambda: self.selectLink(2, True), lambda: self.selectRelativeResidue(3, True), lambda: self.selectLink(3, True), lambda: self.selectRelativeResidue(4, True), lambda: self.selectLink(4, True), lambda: self.selectRelativeResidue(5, True) ] self.sequenceButtons = ButtonList(resultsFirstFrame, commands=commands, texts=texts) self.sequenceButtons.grid(row=0, column=0, sticky='nsew') for n, button in enumerate(self.sequenceButtons.buttons): if n % 2: button.grid(column=n, sticky='ns') self.sequenceButtons.grid_columnconfigure(n, weight=0) else: self.sequenceButtons.grid_columnconfigure(n, uniform=2) spacer = Spacer(resultsFirstFrame) spacer.grid(row=1, column=0, sticky='nsew') texts = [ ' res 1 ', ' links ', ' res 2 ', ' links ', ' res 3 ', ' links ', ' res 4 ', ' links ', ' res 5 ' ] commands = commands = [ lambda: self.selectRelativeResidue(1, False), lambda: self.selectLink(1, False), lambda: self.selectRelativeResidue(2, False), lambda: self.selectLink(2, False), lambda: self.selectRelativeResidue(3, False), lambda: self.selectLink(3, False), lambda: self.selectRelativeResidue(4, False), lambda: self.selectLink(4, False), lambda: self.selectRelativeResidue(5, False) ] self.sequenceButtonsB = ButtonList(resultsFirstFrame, commands=commands, texts=texts) self.sequenceButtonsB.grid(row=2, column=0, sticky='nsew') for n, button in enumerate(self.sequenceButtonsB.buttons): if n % 2: button.grid(column=n, sticky='ns') self.sequenceButtonsB.grid_columnconfigure(n, weight=0) else: self.sequenceButtonsB.grid_columnconfigure(n, uniform=2) frame.grid_rowconfigure(3, weight=2) resultsThirdFrame = Frame(frame) resultsThirdFrame.grid(row=3, column=0, sticky='nsew') resultsThirdFrame.grid_rowconfigure(0, weight=1) resultsThirdFrame.grid_columnconfigure(0, weight=1) tabbedFrameB = TabbedFrame(resultsThirdFrame, options=['Peaks', 'Spin System'], callback=self.toggleTab, grid=(0, 0)) #self.tabbedFrameB = tabbedFrame PeakFrame, SpinSystemFrame = tabbedFrameB.frames SpinSystemFrame.grid_rowconfigure(0, weight=1) PeakFrame.grid_rowconfigure(1, weight=1) SpinSystemFrame.grid_columnconfigure(0, weight=1) PeakFrame.grid_columnconfigure(0, weight=1) headingList = [ 'residue', 'assigned to in project', 'user defined sequence', 'selected annealing result', '%' ] tipTexts = [None, None, None, None, None] editWidgets = [None, None, None, None, None] editGetCallbacks = [None, None, None, None, None] editSetCallbacks = [None, None, None, None, None] self.spinSysTable = ScrolledMatrix(SpinSystemFrame, headingList=headingList, editWidgets=editWidgets, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.spinSysTable.grid(row=0, column=0, sticky='nsew') buttonFrameinPeakFrame = Frame(PeakFrame) buttonFrameinPeakFrame.grid(sticky='ew') self.findButton = Button( buttonFrameinPeakFrame, text=' Go to Peak ', borderwidth=1, padx=2, pady=1, command=self.findPeak, tipText='Locate the currently selected peak in the specified window' ) self.findButton.grid(row=0, column=0, sticky='e') label = Label(buttonFrameinPeakFrame, text='in window:') label.grid(row=0, column=1, sticky='w') self.windowPulldown = PulldownList( buttonFrameinPeakFrame, callback=self.selectWindowPane, tipText='Choose the spectrum window for locating peaks or strips') self.windowPulldown.grid(row=0, column=2, sticky='w') self.assignSelectedPeaksButton = Button( buttonFrameinPeakFrame, text='Assign Resonances to Peak(s)', borderwidth=1, padx=2, pady=1, command=self.assignSelectedPeaks, tipText= 'Assign resonances to peak dimensions, this of course only works when the peak is found in the spectrum.' ) self.assignSelectedPeaksButton.grid(row=0, column=3, sticky='ew') self.assignSelectedSpinSystemsToResiduesButton = Button( buttonFrameinPeakFrame, text='Assign Spinsystems to Residues', borderwidth=1, padx=2, pady=1, command=self.assignSelectedSpinSystemsToResidues, tipText='Assign spinsystems to residues') self.assignSelectedSpinSystemsToResiduesButton.grid(row=0, column=4, sticky='ew') headingList = [ '#', 'spectrum', 'Dim1', 'Dim2', 'Dim3', 'c.s. dim1', 'c.s. dim2', 'c.s. dim3', 'colabelling' ] tipTexts = [ 'Peak number, only present when the peak was actually found in the spectrum.', 'Name of the spectrum', 'Name of atomSet measured in this dimension. Dimension number corresponds to Ref Exp Dim as indicated by going in the main menu to Experiment-->Experiments-->Experiment Type', 'Name of atomSet measured in this dimension. Dimension number corresponds to Ref Exp Dim as indicated by going in the main menu to Experiment-->Experiments-->Experiment Type', 'Name of atomSet measured in this dimension. Dimension number corresponds to Ref Exp Dim as indicated by going in the main menu to Experiment-->Experiments-->Experiment Type', 'Chemical Shift', 'Chemical Shift', 'Chemical Shift', 'Colabbeling fraction over all nuclei that are on the magnetization transfer pathway during the experiment that gave rise to the peak, including visited nuclei that were not measured in any of the peak dimensions' ] #editWidgets = [None, None, None, None, None, None, None, None, None] editGetCallbacks = [ None, None, None, None, None, None, None, None, None ] #editGetCallbacks = [self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak, self.selectPeak] editSetCallbacks = [ None, None, None, None, None, None, None, None, None ] self.displayPeakTable = ScrolledMatrix(PeakFrame, headingList=headingList, multiSelect=True, tipTexts=tipTexts) #editWidgets=editWidgets, multiSelect=True, # editGetCallbacks=editGetCallbacks, # editSetCallbacks=editSetCallbacks, # tipTexts=tipTexts) self.displayPeakTable.grid(row=1, column=0, sticky='nsew') self.windowPane = None self.updateWindows()
return self.var.get() def set(self, text=''): self.var.set(text) if (__name__ == '__main__'): from memops.gui.Button import Button msg = 'hello world' count = 0 def func(): global count count = count + 1 label.set(msg + ' ' + str(count)) print label.get() root = Tkinter.Tk() label = Label(root, text='hello world') label.grid() button = Button(root, text='hit me', command=func) button.grid() root.mainloop()
def drawFrame(self): # build up the body. # what are the rules governing when this tab should show something and # when it should not? In fact, there is the whole question of how the # two different sections (file management and task management) should # interract sensibly. # This needs to be composed. We know the task type (from the tab) so what # we need to know is how to handle ids. should we generate a placeholder # id, or would it be better not to assign an id to begin with or else # just use id(new) self.task_id = self.basePopup.currentTask print 'trying to render task with serial ', self.task_id if self.task_id == None: for widget in self.data_widgets: widget.grid_remove() self.null_task_label.grid(row=1, column=1, columnspan=4, sticky='nswe') else: for widget in self.noData_widgets: widget.grid_remove() loc = SharedBeanServiceLocator() port = loc.getSharedBean() # need two calls, one for the Project and one for the version hm1 = {'serial': int(self.task_id)} wsstr_in1 = WSString(hm1) request1 = getFieldsWithMethod() request1._arg0 = 'org.pimslims.applet.server.TaskBean' request1._arg1 = 'getTest1Fields' request1._arg2 = wsstr_in1.str response1 = port.getFieldsWithMethod(request1) wsstr_out1 = WSString(response1._return) hm_tv = wsstr_out1.getStructHM() print 'RESULT ', hm_tv self.task_rep_title.set('Task: ' + self.task_id) self.task_rep_title.grid(row=1, column=1, columnspan=2, sticky='w') self.repository = self.basePopup.repList.currentRepository self.task_rep_label.grid(row=2, column=1, sticky='w') self.task_rep_value.set(self.repository.user + '@' + self.repository.name + ' ( ' + self.repository.connect + ' )') self.task_rep_value.grid(row=2, column=2, columnspan=2, sticky='w') # FIXME JMCI # This actually needs to be editable self.task_status_label.grid(row=3, column=1, columnspan=2, sticky='w') self.task_status_value.set(hm_tv['status']) #self.task_status_value.set('PENDING') self.task_status_value.grid(row=3, column=2, columnspan=2, sticky='w') par1 = 'N/A' if hm_tv['par1'] != 'valIsNullPointer': par1 = hm_tv['par1'] self.task_par1_label.grid(row=4, column=1, columnspan=2, sticky='w') self.task_par1_value.set(par1) self.task_par1_value.grid(row=4, column=2, columnspan=2, sticky='w') par2 = 'N/A' if hm_tv['par1'] != 'valIsNullPointer': par2 = hm_tv['par2'] self.task_par2_label.grid(row=5, column=1, columnspan=2, sticky='w') self.task_par2_value.set(par2) self.task_par2_value.grid(row=5, column=2, columnspan=2, sticky='w') # this will depend on the status #self.task_date_label.grid(row=4, column=1, columnspan=2, sticky='w') #self.task_date_value.set('11 FEB 2009:11:36') #self.task_date_value.grid(row=4, column=2, columnspan=2, sticky='w') # FIXME JMCI # This is not in the current model #self.task_details_label.grid(row=4, column=1, columnspan=2, sticky='w') #self.task_details_value.set(hm_pv['details']) #self.task_details_value.grid(row=4, column=2, columnspan=2, sticky='w') inputProject = 'N/A' # This needs to be populated from the fields hash # It is also going to be dependent on the precise task if hm_tv.has_key('inputVersion'): inputProjectName = hm_tv['inputVersion']['project']['name'] inputVersionTag = hm_tv['inputVersion']['versionTag'] inputProject = inputProjectName + '::' + inputVersionTag self.task_input_label.grid(row=6, column=1, sticky='w') self.task_input_value.set(inputProject) self.task_input_value.grid(row=6, column=2, sticky='w') self.button_file_in_browse.grid(row=6, column=3, sticky='e') outputProject = 'N/A' # This needs to be populated from the fields hash # It is also going to be dependent on the precise task if hm_tv.has_key('generatedVersion'): outputProjectName = hm_tv['generatedVersion']['project'][ 'name'] outputVersionTag = hm_tv['generatedVersion']['versionTag'] outputProject = outputProjectName + '::' + outputVersionTag self.task_output_label.grid(row=7, column=1, sticky='w') self.task_output_value.set(outputProject) self.task_output_value.grid(row=7, column=2, sticky='w') # it not clear when we would want to allow the project to be # set, but allow it anyway for now self.button_file_out_browse.grid(row=7, column=3, sticky='e') # FIXME JMCI # again, this really depends on what the status is. Need to decide # the transitions button_submit = Button(self, text='Submit', command=self.submit) button_submit.grid(row=8, column=2, sticky='w')
def __init__(self, guiParent, basePopup, callback=None): # Base popup required to handle notification of data model changes # e.g. new peak lists, so that the GUI can update to the latest # state self.basePopup = basePopup self.guiParent = guiParent # we need to be able to define a callback before exit self.callback = callback Frame.__init__(self, guiParent) # Basic principle is that we want to supply a root directory # and we will get a tree that will allow us to browse anything # below the directory. We will also have a button for going # up a directory. self.rootDir = '/home/jionides/work/CCPN/test_WMS_archive' self.icon_dict = { 'none': 'text-x-generic-template', 'text': 'text-x-generic', 'text/plain': 'text-x-generic', 'text/html': 'text-html', 'text/script': 'text-x-script', 'text/x-python': 'text-x-script', 'text/x-perl': 'text-x-script', 'image': 'image-x-generic', 'application': 'applications-other', 'video': 'video-x-generic', 'message': 'internet-mail', 'audio': 'audio-x-generic', 'chemical': 'applications-internet', 'application/x-tar': 'package-x-generic', 'application/msword': 'x-office-document', 'application/postscript': 'x-office-drawing', 'application/pdf': 'x-office-drawing', 'application/xml': 'text-x-script', 'application/x-python-code': 'application-x-executable', } self.grid_rowconfigure(1, weight=1) self.grid_columnconfigure(1, weight=1) self.fileTree = Tree(self) self.fileTree.grid(row=1, column=1, padx=10, pady=10, sticky='nsew') self.ok_button = Button(self, width=10, text='OK', command=self.isOk) #self.ok_button = Button(self, text='OK', command=self.isOk) self.ok_button.grid(row=2, column=1, padx=10, pady=10, sticky='e') self.cancel_button = Button(self, width=10, text='Cancel', command=self.isCancel) #self.cancel_button = Button(self,text='Cancel', command=self.isCancel) self.cancel_button.grid(row=2, column=1, padx=10, pady=10, sticky='w') files = listdir(self.rootDir) parents = [None] * len(files) icons = [] objects = [] texts = [] callbacks = [] for file in files: file = path.join(self.rootDir, file) text, icon, isDir = self.getData(file) icons.append(icon) texts.append(text) objects.append(file) if isDir: callbacks.append(self.openDir) else: callbacks.append(None) print 'updating', texts self.fileTree.update(parents, objects, texts, icons, callbacks)
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)
import sys import Tkinter from memops.gui.Button import Button popup_select = None def callback(text): global popup_select if (popup_select): print 'callback: selected =', popup_select.getSelected() def toggle(): global popup_select if (popup_select.getSelected()): popup_select.setSelected(False) else: popup_select.setSelected(True) root = Tkinter.Tk() popup_select = BooleanPulldownMenu(root, callback=callback, selected=False) popup_select.grid(row=0, column=0, columnspan=2) button = Button(root, text='toggle extra state', command=toggle) button.grid(row=1, column=0) button = Button(root, text='quit', command=sys.exit) button.grid(row=1, column=1) root.mainloop()
def __init__(self, parent, project, calcStore, *args, **kw): NmrCalcRunFrame.__init__(self, parent, project, calcStore, inputTypes=(PEAK_DATA, CONSTRAINT_DATA), chainSelection=True, *args, **kw) self.calcStore = calcStore self.optPeakList = None self.optConstraintList = None frame = self.tabbedFrame.frames[1] headingList = ['PeakList','Filter\nViolated?', 'Keep\nAssignments?','Shift List'] editWidgets = [None, None, None, None] editGetCallbacks = [None, self.toggleFilterViol, self.toggleKeepAssign, None] editSetCallbacks = [None, None, None, None] row = 0 subFrame = Frame(frame, grid=(row,0)) subFrame.expandGrid(0,1) label = Label(subFrame, text='File Name Prefix:', grid=(0,0)) self.filePrefixEntry = Entry(subFrame, text='aria', grid=(0,1), sticky="ew") self.filePrefixEntry.bind('<Leave>', self.updateEntryParams) label = Label(subFrame, text='CNS Executable:', grid=(1,0)) self.cnsExeEntry = Entry(subFrame, text='', grid=(1,1), sticky="ew") self.cnsExeEntry.bind('<Leave>', self.updateEntryParams) button = Button(subFrame, text='Select File',bd=1,bg='#C0E0FF', command=self.selectCnsExe, grid=(1,2)) label = Label(subFrame, text='Working Directory:', grid=(2,0)) self.workingDirEntry = Entry(subFrame, text='', grid=(2,1), sticky="ew") self.workingDirEntry.bind('<Leave>', self.updateEntryParams) button = Button(subFrame, text='Select File',bd=1,bg='#C0E0FF', command=self.selectWorkingDir, grid=(2,2)) label = Label(subFrame, text='Temporary Directory:', grid=(3,0)) self.tempDirEntry = Entry(subFrame, text='', grid=(3,1), sticky="ew") self.tempDirEntry.bind('<Leave>', self.updateEntryParams) button = Button(subFrame, text='Select File',bd=1,bg='#C0E0FF', command=self.selectTempDir, grid=(3,2)) row += 1 frame.expandGrid(row,0) self.grid_rowconfigure(row, weight=1) self.optPeakListMatrix = ScrolledMatrix(frame, headingList=headingList, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, multiSelect=True, grid=(row,0), callback=self.selectOptPeakList) row += 1 frame.expandGrid(row,0) headingList = ['Constraint List', 'Name', 'Filter\nViolated?', 'Ambiguous\nProtocol?',] editWidgets = [None, None, None, None] editGetCallbacks = [None, None, self.toggleFilterViol, self.toggleAmbig] editSetCallbacks = [None, None, None, None] self.optConstraintMatrix = ScrolledMatrix(frame, headingList=headingList, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, multiSelect=True, grid=(row,0), callback=self.selectConstraintList) self.optConstraintMatrix.doEditMarkExtraRules = self.doEditMarkExtraRules self.update(calcStore)
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, tipText='Hint to user') entry.grid(row=0, column=1, sticky=Tkinter.W) self.check = CheckButton(frame, text='Checkbutton', selected=True, callback=self.updateObjects, tipText='Hint to user') 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, tipText='Hint to user') 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 = (False, False, True, True) 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, tipText='Hint to user') 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] tipTexts = ['Name of the whatsit','Colour of the whatsit', 'The whatsit\'s number','The whatsit\'s keywords'] headingList = ['Name','Colour','Number','Keywords'] self.scrolledMatrix = ScrolledMatrix(self.toggleFrame, headingList=headingList, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, editWidgets=editWidgets, tipTexts=tipTexts, 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, tipText='Hint to user', 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)
root = Tkinter.Tk() root.top = root root.grid_rowconfigure(0, weight=1) root.grid_columnconfigure(0, weight=1) path = getDataPath() frame = ChemCompFrame(root, project, path = path) frame.grid(sticky=Tkinter.NSEW) def getSelected(): chemComp = frame.getSelectedChemComp() if (chemComp): if hasattr(chemComp,'chemComp'): ccType = 'chemCompVar' chemComp = chemComp.chemComp else: ccType = 'chemComp' showInfo('ChemComp', 'Selected %s = (%s, %s)' % (ccType,chemComp.molType, chemComp.ccpCode), parent=root) else: showInfo('ChemComp', 'No chemComp selected', parent=root) button = Button(root, text='Get selected', command=getSelected) button.grid() root.mainloop()
def __init__(self, guiParent, basePopup): self.basePopup = basePopup self.guiParent = guiParent self.basePopup.frameShortcuts['Project'] = self #self.registerNotify=basePopup.registerNotify #self.unregisterNotify=basePopup.unregisterNotify Frame.__init__(self, guiParent) # set up the grid self.grid_columnconfigure(0, weight=0, minsize=10) self.grid_columnconfigure(1, weight=0, minsize=50) self.grid_columnconfigure(2, weight=1, minsize=20) self.grid_columnconfigure(3, weight=0, minsize=40) self.grid_rowconfigure(0, weight=0, minsize=5) self.grid_rowconfigure(1, weight=0, minsize=10) self.grid_rowconfigure(2, weight=0, minsize=10) self.grid_rowconfigure(3, weight=0, minsize=10) # we could in theory choose to store the last visited # project in the user config file and load this on log in # if we then decide that login is mandatory then this # would give as a project from the start self.repository = None self.projectName = None self.versionTag = None # we define as much as possible once on startup and use the # grid manager to control the display thereafter # when no data self.noData_widgets = [] self.null_proj_label = Label(self, text='No Project selected') self.noData_widgets.append(self.null_proj_label) # when data self.data_widgets = [] self.proj_rep_title = Label(self, text='Project:', font='Helvetica16') self.data_widgets.append(self.proj_rep_title) self.proj_rep_label = Label(self, text='Repository:') self.data_widgets.append(self.proj_rep_label) self.proj_rep_value = Label(self, text='') self.data_widgets.append(self.proj_rep_value) # This is more complex than it seems. We need to have some # user information accoisated with this too (who has the lock) self.proj_status_label = Label(self, text = 'Status:') self.data_widgets.append(self.proj_status_label) self.proj_status_value = Label(self, text='') self.data_widgets.append(self.proj_status_value) self.proj_details_label = Label(self, text='Description:') self.proj_details = Text(self, width=75, height=6, text='') self.data_widgets.append(self.proj_details) info_modes = ['versions','tasks','raw data'] self.info_mode_select = PulldownList(self, self.tmpCall, info_modes) self.data_widgets.append(self.info_mode_select) initial_cols = ['Project','Version','Created by Task', 'Created from Project version'] self.proj_history_matrix = ScrolledMatrix(self, headingList=initial_cols, initialRows=7, doubleCallback=self.history_callback) self.data_widgets.append(self.proj_history_matrix) initial_cols = ['ID','Task','User','Status', 'Date'] self.proj_tasks_matrix = ScrolledMatrix(self, headingList=initial_cols, initialRows=7, doubleCallback=self.history_callback) self.data_widgets.append(self.proj_tasks_matrix) initial_cols = ['name','type','size','details'] self.proj_files_matrix = ScrolledMatrix(self, headingList=initial_cols, initialRows=7, doubleCallback=self.history_callback) self.data_widgets.append(self.proj_files_matrix) self.proj_export_button = Button(self, height=1, width=14,text='Export', command=self.export_project) self.data_widgets.append(self.proj_export_button) self.proj_import_button = Button(self, height=1, width=14,text='Import', command=self.export_project) self.data_widgets.append(self.proj_import_button) self.run_testtask1_button = Button(self, height=1, width=14,text='Run TestTask1', command=self.goto_task1_tab) self.data_widgets.append(self.run_testtask1_button) # FIXME JMCI # insert this inside this Frame directly: not worth abstracting out self.filter_frame = FilterFrame(self, self.basePopup, text='Filter') self.data_widgets.append(self.filter_frame) self.drawFrame()
def body(self, guiFrame): self.geometry('700x600') guiFrame.expandGrid(0, 0) tipTexts = [ 'A table of all of the reference isotope scheme definitions available to the project', 'A list of the residue isotopomers that comprise the selected isotope labelling scheme', 'A three-dimensional representation of residues and their isotopomer labelling' ] options = ['Reference Schemes', 'Isotopomers', 'Isotopomer Structure'] tabbedFrame = TabbedFrame(guiFrame, options=options, grid=(0, 0), tipTexts=tipTexts) self.tabbedFrame = tabbedFrame frameA, frameB, frameC = tabbedFrame.frames # # Schemes # frameA.expandGrid(0, 0) tipTexts = [ 'A short textual code that identifies the reference isotope scheme in graphical displays', 'The full name for the isotope scheme', 'A detailed description of the isotope scheme including user comments', 'The name of the CCPN data repository in which the isotope scheme is saved; "refData" is in the CCPn installation' ] headingList = ['Code', 'Name', 'Description', 'Save Location'] self.schemeNameEntry = Entry(self, text='', returnCallback=self.setSchemeName, width=20) self.schemeDetailsEntry = Entry(self, text='', returnCallback=self.setSchemeDetails, width=20) editWidgets = [ None, self.schemeNameEntry, self.schemeDetailsEntry, None ] editGetCallbacks = [ None, self.getSchemeName, self.getSchemeDetails, None ] editSetCallbacks = [ None, self.setSchemeName, self.setSchemeDetails, None ] self.schemeMatrix = ScrolledMatrix(frameA, headingList=headingList, callback=self.selectScheme, editWidgets=editWidgets, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, multiSelect=False, grid=(0, 0), tipTexts=tipTexts) self.schemeMatrix.doEditMarkExtraRules = self.schemeEditRules tipTexts = [ 'Make a new reference isotope scheme definition based on a copy of the scheme currently selected', 'Delete the selected isotope scheme', 'Make a new, blank isotope scheme' ] texts = ['Copy', 'Delete', 'New'] commands = [self.copyScheme, self.removeScheme, self.makeNewScheme] self.schemeButtons = ButtonList(frameA, texts=texts, commands=commands, grid=(1, 0), tipTexts=tipTexts) # # Isotopomers # frameB.expandGrid(3, 0) row = 0 frame = Frame(frameB, grid=(row, 0)) frame.expandGrid(0, 2) tipText = 'Selects which of the available isotope schemes to view/edit' label = Label(frame, text='Reference Scheme:', grid=(0, 0)) self.schemePulldown = PulldownList(frame, callback=self.setLabellingScheme, grid=(0, 1), tipText=tipText) row += 1 div = LabelDivider(frameB, text='Isotopomers', grid=(row, 0)) row += 1 frame = Frame(frameB, grid=(row, 0)) frame.expandGrid(1, 2) self.isotopomerFrame = frame self.abundanceWidget = MultiWidget(self, FloatEntry, relief='raised', borderwidth=2, callback=self.setDefaultAbundances, useImages=False) tipText = 'Opens a panel that allows you to set the basis/default abundances for C, H & N isotopes; used as the starting point for new isotopomer definitions' self.abundanceButton = Button(frame, text='Set Default\nAbundances', borderwidth=1, command=self.enterDefaultAbundances, grid=(0, 0), tipText=tipText) tipText = 'Sets the basis/default abundances for C, H & N isotopes to their natural abundance proportions' button = Button(frame, text='Set Natural\nAbundance Default', borderwidth=1, command=self.resetDefaultAbundance, grid=(0, 1), sticky='ew', tipText=tipText) label = Label(frame, text='Molecule Type:', grid=(0, 2), sticky='e') entries = standardResidueCcpCodes.keys() entries.sort() entries.reverse() tipText = 'Selects which type of bio-polymer to define residue isotopomer labelling for' self.molTypePulldown = PulldownList(frame, callback=self.setMolType, texts=entries, grid=(0, 3), tipText=tipText) row += 1 tipTexts = [ 'The CCPN code that identifies the kind of residue the isotopomer relates to', 'The number of the particular isotopomer (isotope pattern) within its residue type', 'The fraction of the total residues, of its kind, that the isotopomer make up' ] headingList = ['Ccp Code', 'Variant', 'Weight'] self.isotopomerWeightEntry = FloatEntry( self, text='', returnCallback=self.setIsotopomerWeight, width=6) editWidgets = [None, None, self.isotopomerWeightEntry] editGetCallbacks = [None, None, self.getIsotopomerWeight] editSetCallbacks = [None, None, self.setIsotopomerWeight] self.isotopomerMatrix = ScrolledMatrix( frameB, tipTexts=tipTexts, headingList=headingList, callback=self.selectIsotopomer, editWidgets=editWidgets, editSetCallbacks=editSetCallbacks, editGetCallbacks=editGetCallbacks, multiSelect=True, grid=(row, 0)) self.isotopomerMatrix.doEditMarkExtraRules = self.isotopomerEditRules row += 1 frame = Frame(frameB, grid=(row, 0), sticky='ew') frame.expandGrid(0, 0) tipTexts = [ 'Delete the selected residue isotopomers from the current isotope scheme', 'Make a new residue isotopomer definition by copying the details of the last selected isotopomer', 'Add a complete set of isotopomers to the isotope scheme, one for each residue type, based on the states default isotope abundances', 'For all residue isotopomers in the scheme, set the labelling of one kind of atom (the user is prompted) to its default isotopic incorporation ', 'Add a new residue isotopomer definition that uses the default isotopic incorporation' ] texts = [ 'Delete\nSelected', 'Copy\nSelected', 'Add Default\nAbundance Set', 'Set Atom Type\nTo Default', 'Add\nNew:' ] commands = [ self.removeIsotopomers, self.duplicateResidues, self.addDefaultIsotopomers, self.setAtomTypeDefault, self.addNewIsotopomer ] self.isotopomerButtons = ButtonList(frame, texts=texts, commands=commands, grid=(0, 0), tipTexts=tipTexts) tipText = 'Selects which kind of residue isotopomer may be added to the current isotope scheme' self.ccpCodePulldown = PulldownList(frame, callback=None, grid=(0, 1), sticky='e', tipText=tipText) row += 1 div = LabelDivider(frameB, text='Atom Labels', grid=(row, 0)) row += 1 frame = Frame(frameB, grid=(row, 0)) frame.expandGrid(1, 3) label = Label(frame, text='Chemical Element:', grid=(0, 0)) tipText = 'Selects which kind of atoms to select from the selected residue isotopomer; to display isotopic incorporation in the below table' self.elementPulldown = PulldownList(frame, callback=self.changeChemElement, grid=(0, 1), tipText=tipText) self.updateChemElements() label = Label(frame, text='Water Exchangeable Atoms:', grid=(0, 2)) tipText = 'Sets whether to show atoms considered as being "water exchangeable"; their isotopic labelling will rapidly equilibrate with aqueous solvent' self.exchangeCheck = CheckButton(frame, callback=self.updateAtomLabelsAfter, grid=(0, 3), selected=False, tipText=tipText) row += 1 # Tip texts set on update headingList = [ 'Atom\nName', 'Weighting\n13C' 'Weighting\n12C', '%12C', '%13C' ] self.atomLabelTupleWeightEntry = FloatEntry( self, text='', width=6, returnCallback=self.setAtomLabelWeight) self.atomsMatrix = ScrolledMatrix(frameB, headingList=headingList, callback=self.selectAtomLabel, multiSelect=True, grid=(row, 0)) self.atomsMatrix.doEditMarkExtraRules = self.atomsEditRules row += 1 tipTexts = [ 'For the selected atom sites, in the current isotopomer, set their isotopic incorporation to the default values', 'Spread the isotopic incorporation values from the last selected atom site to all selected atoms sites' ] texts = ['Reset Selected to Default Abundance', 'Propagate Abundances'] commands = [self.setAtomLabelsDefault, self.propagateAbundances] self.atomButtons = ButtonList(frameB, texts=texts, commands=commands, grid=(row, 0), tipTexts=tipTexts) # # View Frame # frameC.expandGrid(1, 0) row = 0 frame = Frame(frameC, grid=(row, 0), sticky='ew') frame.grid_columnconfigure(3, weight=1) label = Label(frame, text='Residue Type:', grid=(0, 0)) tipText = 'Selects which kind of residue, within the current isotope scheme, to show isotopomer structures for' self.viewCcpCodePulldown = PulldownList( frame, callback=self.selectViewCcpcode, grid=(0, 1), tipText=tipText) label = Label(frame, text='Isotopomer:', grid=(0, 2)) tipText = 'Selects which kind of isotopomer (labelling pattern) to display, from the selected residue type.' self.viewIsotopomerPulldown = PulldownList( frame, callback=self.selectViewIsotopomer, grid=(0, 3), tipText=tipText) row += 1 self.viewIsotopomerFrame = ViewIsotopomerFrame(frameC, None, grid=(row, 0)) # # Main # tipTexts = [ 'Save all changes to the reference isotope scheme to disk; the saves ALL changes to the CCPN installation for all projects to use', ] texts = ['Save Schemes'] commands = [self.saveSchemes] self.bottomButtons = UtilityButtonList(tabbedFrame.sideFrame, texts=texts, commands=commands, helpUrl=self.help_url, grid=(0, 0), sticky='e', tipTexts=tipTexts) self.updateChemElements() self.updateCcpCodes() self.updateSchemes() self.administerNotifiers(self.registerNotify)
def body(self, master): pseudoExpts = getSampledDimExperiments(self.parent.nmrProject) master.rowconfigure(0, weight=1) master.rowconfigure(1, weight=1) master.columnconfigure(0, weight=1) tipTexts = ['The experiment is pseudo-N dimensional, with a sampled axis', 'The experiment is the regular kind with only NMR frequency axes'] self.pseudoEntries = [x % len(self.params.npts) for x in PSEUDO_ENTRIES] self.pseudoButton = RadioButtons(master, entries=self.pseudoEntries, select_callback=self.changedPseudoMode, grid=(0,0), sticky='nw', tipTexts=tipTexts) frame = self.pseudoFrame = Frame(master) self.pseudoFrame.grid(row=1, column=0, sticky='nsew') row = 0 if pseudoExpts: tipText = 'Select from existing pseudo nD experiments to copy sampled axis values from' texts = [x.name for x in pseudoExpts] label = Label(frame, text='Existing pseudo expts: ') label.grid(row=row, column=0, sticky='e') self.pseudoList = PulldownList(frame, texts=texts, objects=pseudoExpts, tipText=tipText) self.pseudoList.grid(row=row, column=1, sticky='w') tipText = 'Transfer the sampled axis values from the existing experiment to the new one' Button(frame, text='Copy values down', command=self.copyValues, tipText=tipText, grid=(row,2)) row += 1 npts = self.params.npts[self.dim] tipText = 'Number of data points (planes) along sampled axis' label = Label(frame, text='Number of points: ') label.grid(row=row, column=0, sticky='e') self.nptsEntry = IntEntry(frame, text=npts, tipText=tipText, width=8, grid=(row,1)) tipText = 'Load the values for the sampled axis from a text file containing a list of numeric values' Button(frame, text='Load File', command=self.loadValues, tipText=tipText, grid=(row,2), sticky='ew') row += 1 tipText = 'The values (e.g. T1, T2) corresponding to each data point (plane) along sampled axis' label = Label(frame, text='Point values: ') label.grid(row=row, column=0, sticky='e') self.valueEntry = FloatEntry(frame, isArray=True, tipText=tipText) #minRows = self.params.npts[self.dim] #self.valueEntry = MultiWidget(frame, FloatEntry, callback=None, minRows=minRows, maxRows=None, # options=None, values=[], useImages=False) self.valueEntry.grid(row=row, column=1, columnspan=2, sticky='ew') row += 1 label = Label(frame, text='(requires comma-separated list, of length number of points)') label.grid(row=row, column=1, columnspan=2, sticky='w') row += 1 for n in range(row): frame.rowconfigure(n, weight=1) frame.columnconfigure(1, weight=1) buttons = UtilityButtonList(master, closeText='Ok', closeCmd=self.updateParams, helpUrl=self.help_url) buttons.grid(row=row, column=0, sticky='ew')
self.setLabel() if (self.set_callback): self.set_callback(self.get()) if __name__ == '__main__': import sys from memops.gui.Button import Button def getValue(): print 'index = %s, value = %s' % (labeled_scale.get(), labeled_scale.getValue()) def setCallback(index): print 'index = %s' % index root = Tkinter.Tk() labeled_scale = LabeledScale(root, values= (12.3, 34.5, 192, 12.3), set_callback=setCallback) labeled_scale.pack(side=Tkinter.TOP, expand=Tkinter.YES, fill=Tkinter.X) button = Button(root, text='get value', command=getValue) button.pack(side=Tkinter.TOP) button = Button(root, text='quit', command=sys.exit) button.pack(side=Tkinter.TOP) root.mainloop()
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)
def body(self, guiFrame): self.geometry('500x130') guiFrame.grid_columnconfigure(2, weight=1) guiFrame.grid_rowconfigure(3, weight=1) self.alarm_id = None row = 0 tipText = 'Browse for the directory into which project backups will be made' button = Button(guiFrame, text='Directory:', command=self.selectDir, grid=(row, 0), tipText=tipText, sticky='ew') repository = self.project.findFirstRepository(name='backup') if repository: text = repository.url.path else: # this is trouble, but should not happen text = '' tipText = 'Enter the name of the directory into which project backups will be made' self.dir_entry = Entry(guiFrame, text=text, tipText=tipText, width=40, returnCallback=self.applyAuto, grid=(row, 1), gridSpan=(1, 2), sticky='ew') row += 1 label = Label(guiFrame, text='Auto-backup:', grid=(row, 0)) if self.analysisProject.doAutoBackup: ind = 0 else: ind = 1 tipTexts = [ 'Toggle the timed automatic backup on', 'Toggle the timed automatic backup off' ] self.on_off_buttons = RadioButtons(guiFrame, entries=self.on_off_entries, tipTexts=tipTexts, select_callback=self.applyAuto, selected_index=ind, grid=(row, 1)) row += 1 tipText = 'The number of minutes to wait before automatic project backups' label = Label(guiFrame, text='Auto-backup frequency:', grid=(row, 0)) self.freq_entry = IntEntry(guiFrame, text=self.analysisProject.autoBackupFreq, returnCallback=self.applyAuto, tipText=tipText) self.freq_entry.grid(row=row, column=1) label = Label(guiFrame, text=' (minutes)', grid=(row, 2)) row = row + 1 # Blank for expansion row = row + 1 texts = ['Apply Auto Settings', 'Do Immediate Backup'] commands = [self.applyAuto, self.applyManual] tipTexts = [ 'Commit the specified settings and commence automated CCPN project backup', 'Backup the CCPN project now, into the specified backup directory' ] buttons = UtilityButtonList(guiFrame, texts=texts, commands=commands, doClone=False, helpMsg=self.help_msg, helpUrl=self.help_url, tipTexts=tipTexts, grid=(row, 0), gridSpan=(1, 3), sticky='nsew')
def update(self, objects=None, selected=None, labels=None, colors=None, fonts=None): if objects is None: if self.objects is None: self.objects = [] else: self.objects = objects if labels is None: if self.labels is None: self.labels = [] else: self.labels = labels if colors is None: if self.colors is None: self.colors = [] else: self.colors = colors if fonts is None: if self.fonts is None: self.fonts = [] else: self.fonts = fonts N = len(self.objects) for i in range(N): if i >= len(self.labels): self.labels.append('%d' % i) if self.objects[i] is None: self.labels[i] = 'None' if i >= len(self.colors): self.colors.append(self.cget('background')) if i >= len(self.fonts): self.fonts.append(self.font) if i >= len(self.buttons): command = lambda n=i, s=self: s.selectButton(n) button = Button(self, command=command, relief=self.buttonRelief, font=self.fonts[i], borderwidth=self.buttonBorderWidth) self.buttons.append(button) if len(self.buttons) > N: for i in range(N, len(self.buttons)): self.buttons[i].grid_forget() self.grid_columnconfigure(i, weight=0) row = 0 col = 0 for i in range(N): if i >= len(self.state): self.state.append(1) self.setButtonState(i, self.state[i]) self.buttons[i].config(text=labels[i], font=self.fonts[i]) self.buttons[i].grid(row=row, column=col, sticky=Tkinter.NSEW) self.grid_columnconfigure(col, weight=1) col += 1 if col >= self.maxRowObjects: row += 1 col = 0 if selected is not None: self.setSelected(selected)
def __init__(self, parent, project, closeButton=False, tempFiles=False, *args, **kw): ########################################################################### # INIT VARIABLES self.parent = parent self.project = project try: self.nmrProject = (project.currentNmrProject or project.newNmrProject(name='BLACKLEDGE_MODULE')) except: print '&&& Running MODULE popup from outside CCPN Analysis - debug only - no NmrCalc' self.nmrProject = None if self.nmrProject: self.calcStore = project.findFirstNmrCalcStore(name=MODULE, nmrProject=self.nmrProject) or \ project.newNmrCalcStore(name=MODULE, nmrProject=self.nmrProject) else: self.calcStore = None self.run = None self.inputStructure = None self.inputRdcConstraintList = None self.inputDistanceConstraintList = [None] self.inputUserDescriptionText = None # path to the module executable modPath = subprocess.Popen( ['which', 'module'], stdout=subprocess.PIPE).communicate()[0].strip() self.moduleExePath = modPath or ' NB. MODULE executable not found ' self.waiting = False # for debug this could be False if tempFiles: self.useTempFiles = True else: self.useTempFiles = False # create temp files for MODULE if self.useTempFiles: self.moduleTempDir = tempfile.mkdtemp(prefix='MODULE-') else: self.moduleTempDir = os.getcwd() #djo35# self.calcStore = self.resetCalcStore(name='BLACKLEDGE_MODULE') # END INIT OF VARIABLES ########################################################################### ########################################################################### # START GUI CODE Frame.__init__(self, parent, *args, **kw) self.expandGrid(0, 0) ## Single Frame # frame = Frame(self, grid=(0,0)) # or with Tabs? options = ['Launch', 'Output', 'Runs'] tabbedFrame = TabbedFrame(self, options=options, grid=(0, 0)) frameA, frameB, frameC = tabbedFrame.frames self.tabbedFrame = tabbedFrame frameA.expandGrid(14, 2) row = 0 div = LabelDivider(frameA, text='MODULE Setup', grid=(row, 0), gridSpan=(1, 4)) row += 1 # allow the user to choose MODULE if either the one in PATH is incorrect or not found button = Button(frameA, text='Select MODULE executable:',bd=1, \ command=self.selectExecutable, grid=(row,0), sticky="ew") self.moduleExeEntry = Entry(frameA, text=self.moduleExePath, grid=(row,1), gridSpan=(1,3), \ width=32, sticky="ew", bd=1) self.moduleExePath = self.moduleExeEntry.get() # separator "MODULE input" row += 1 div = LabelDivider(frameA, text='MODULE input', grid=(row, 0), gridSpan=(1, 5)) row += 1 label = Label(frameA, text='Structure:', grid=(row, 1)) self.inputStructurePulldown = PulldownList(frameA, self.changeInputStructure, \ grid=(row,2)) # self.constraintsFileEntry.bind('<Leave>', self.updateEntryParams) row += 1 label = Label(frameA, text='RDC constraints:', grid=(row, 1)) self.inputRdcConstraintsPulldown = PulldownList(frameA, self.changeInputRdcConstraintList, \ grid=(row,2)) #self.constraintsFileEntry.bind('<Leave>', self.updateEntryParams) row += 1 label = Label(frameA, text='(Optional input)', grid=(row, 0)) label = Label(frameA, text='Distance constraints:', \ grid=(row,1)) self.inputDistanceConstraintsPulldown = PulldownList(frameA, self.changeInputDistanceConstraintList, \ grid=(row,2)) #self.constraintsFileEntry.bind('<Leave>', self.updateEntryParams) row += 1 subFrameDepth = 4 subframe = LabelFrame(frameA, text='MODULE User Notes (store notes about how MODULE was run here)', \ grid=(row,0), gridSpan=(1,4)) subframe.expandGrid(subFrameDepth, 0) self.moduleUserText = ScrolledText(subframe) self.moduleUserText.grid(row=subFrameDepth, column=0, columnspan=4, sticky='nsew') # View Results row += subFrameDepth # row += 1 # div = LabelDivider(frameA, text='MODULE launch', grid=(row,0), gridSpan=(1,4)) row += 1 button = Button(frameA, text='Run MODULE', bd=1, command=self.executeModule, \ grid=(row,0), gridSpan=(1,4), sticky="ew", bg=MODULE_GREEN) # grid=(row,0), gridSpan=(1,2), sticky="ew", bg=MODULE_GREEN) ########################################################################### # Frame B (tab 2) Ouput frameB.expandGrid(4, 1) row = 0 subFrameDepth = 6 subframe = LabelFrame(frameB, text='MODULE Output', \ grid=(row,0), gridSpan=(1,5)) #subframe.grid_columnconfigure(2, weight=1) subframe.expandGrid(subFrameDepth, 0) self.moduleOutputText = ScrolledText(subframe) self.moduleOutputText.setState(state=Tkinter.DISABLED) self.moduleOutputText.grid(row=subFrameDepth, column=0, columnspan=4, sticky='nsew') # separator "MODULE input" row += 1 div = LabelDivider(frameB, text='MODULE RDC Back Values', grid=(row, 0), gridSpan=(1, 5)) row += 1 button = Button(frameB, text='Import MODULE Back Values file', bd=1, command=self.importModuleBackValues, \ grid=(row,0), gridSpan=(1,4), sticky="ew", bg=MODULE_BLUE) # grid=(row,0), gridSpan=(2,4), sticky="ew", bg=MODULE_BLUE) row += 1 self.rdcOutputTable = None frameB.grid_rowconfigure(row, weight=1) headings = ('#', 'Resonances', 'Value', 'Back Value', 'Diff.', 'Error') editWidgets = [None, None, None, None, None, None] editGetCallbacks = [None, None, None, None, None, None] editSetCallbacks = [None, None, None, None, None, None] self.rdcOutputTable = ScrolledMatrix(frameB, headingList=headings, multiSelect=False, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, initialRows=4) self.rdcOutputTable.grid(row=row, column=0, columnspan=4, sticky='nsew') row += 1 button = Button(frameB, text='Import MODULE Structure', bd=1, command=self.importModuleStructure, \ grid=(row,0), gridSpan=(1,4), sticky="ew", bg=MODULE_BLUE) # grid=(row,0), gridSpan=(2,4), sticky="ew", bg=MODULE_BLUE) ########################################################################### # Frame C (tab 3) NMR Calc display bits frameC.expandGrid(4, 1) row = 0 div = LabelDivider(frameC, text='Stored MODULE Runs', grid=(row, 0), gridSpan=(1, 5)) # NmrCalc Run scrolled matrix row += 1 self.runTable = None frameC.grid_rowconfigure(row, weight=1) headings = ('Run ID', 'notes', 'Status') # self.editRunNotes = DataEntry.askString('Run Notes', 'Edit notes about Run', tipText='Notes about Run', parent=self) # editWidgets = [None, self.editRunNotes, None] editWidgets = [None, None, None] editGetCallbacks = [None, None, None] editSetCallbacks = [None, None, None] self.runTable = ScrolledMatrix(frameC, headingList=headings, multiSelect=False, editWidgets=editWidgets, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, initialRows=4) self.runTable.grid(row=row, column=0, columnspan=4, sticky='nsew') row += 4 tipTexts = ['Load Selected Run', 'Delete Selected Run'] texts = ['Load Selected Run', 'Delete Selected'] commands = [self.loadRun, self.deleteRun] colours = [MODULE_GREEN, MODULE_RED] self.runButtons = ButtonList(frameC, texts=texts, tipTexts=tipTexts, commands=commands, grid=(row, 0), gridSpan=(1, 4)) self.runButtons.buttons[0].config(bg=MODULE_GREEN) self.runButtons.buttons[1].config(bg=MODULE_RED) ########################################################################### # Keep GUI up to date self.updateAfter() self.administerNotifiers(self.parent.registerNotify)
def body(self, master): fileName = self.fileName directory = os.path.dirname(fileName) if not directory: directory = os.getcwd() fileName = os.path.basename(fileName) m = template_re.match(fileName) if m: n = len(m.groups(2)) ss = '%%0%dd' % n template = re.sub(template_re, r'\1%s\3' % ss, fileName) else: template = fileName master.rowconfigure(0, weight=1) master.rowconfigure(1, weight=1) master.columnconfigure(1, weight=1) tipTexts = [ 'The experiment is pseudo-N dimensional, with a sampled axis', 'The experiment is the regular kind with only NMR frequency axes' ] self.pseudoButton = RadioButtons( master, entries=self.pseudoEntries, select_callback=self.changedPseudoMode, grid=(0, 0), sticky='nw', tipTexts=tipTexts) frame = self.pseudoFrame = Frame(master) self.pseudoFrame.grid(row=1, column=0, sticky='nsew') row = 0 npts = self.params.npts[self.dim] tipText = 'Number of data points (planes) along sampled axis' label = Label(frame, text='Number of points: ') label.grid(row=row, column=0, sticky='e') self.nptsEntry = IntEntry(frame, text=npts, tipText=tipText, width=8, grid=(row, 1)) tipText = 'Load the values for the sampled axis from a text file containing a list of numeric values' Button(frame, text='Load values from text file', command=self.loadValues, tipText=tipText, grid=(row, 2), sticky='ew') row = row + 1 tipText = 'The values (e.g. T1, T2) corresponding to each data point (plane) along sampled axis' label = Label(frame, text='Point values: ') label.grid(row=row, column=0, sticky='e') self.valueEntry = FloatEntry(frame, isArray=True, tipText=tipText) self.valueEntry.grid(row=row, column=1, columnspan=2, sticky='ew') row = row + 1 tipText = 'Fetch the Point values from the files given by the NMRPipe template' button = Button( frame, text='Fetch values from file(s) specified by template below', command=self.fetchValues, tipText=tipText) button.grid(row=row, column=1, columnspan=2, sticky='w') row = row + 1 tipText = 'The directory where the data files reside' button = Button(frame, text='Data directory: ', command=self.chooseDirectory) button.grid(row=row, column=0, sticky='e') self.directoryEntry = Entry(frame, text=directory, width=40, tipText=tipText) self.directoryEntry.grid(row=row, column=1, columnspan=2, sticky='ew') row = row + 1 tipText = 'The NMRPipe template for the data files, if you want to use these to fetch the point values from' button = Button(frame, text='NMRPipe template: ', command=self.chooseFile) button.grid(row=row, column=0, sticky='e') self.templateEntry = Entry(frame, text=template, tipText=tipText) self.templateEntry.grid(row=row, column=1, columnspan=2, sticky='ew') for n in range(row): frame.rowconfigure(n, weight=1) frame.columnconfigure(1, weight=1) buttons = UtilityButtonList(master, closeText='Ok', doClone=False, closeCmd=self.updateParams, helpUrl=self.help_url) buttons.grid(row=2, column=0, sticky='ew')
def body(self, guiFrame): self.geometry('600x350') project = self.project analysisProject = self.analysisProject guiFrame.grid_columnconfigure(1, weight=1) row = 0 label = Label(guiFrame, text=' Window:', grid=(0,0)) self.windowPulldown = PulldownList(guiFrame, grid=(0,1), tipText='The window that will be printed out', callback=self.selectWindow) 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') headings = ['Spectrum', 'Pos. Contours\nDrawn', 'Neg. Contours\nDrawn'] tipTexts = ['Spectrum in window', 'Whether the positive contours should be drawn', 'Whether the negative contours should be drawn'] editWidgets = [ None, None, None] editGetCallbacks = [ None, self.togglePos, self.toggleNeg] editSetCallbacks = [ None, None, None] 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') headings = [ 'Peak List', 'Symbols Drawn', 'Peak Font'] self.fontMenu = FontList(self, mode='Print', extraTexts=[no_peak_text]) editWidgets = [ None, None, self.fontMenu] editGetCallbacks = [ None, self.togglePeaks, self.getPeakFont ] editSetCallbacks = [ None, None, self.setPeakFont ] 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)
if (__name__ == '__main__'): from memops.gui.Button import Button from memops.gui.Util import createQuitButton def getText(): print 'getText:', text.getText() root = Tkinter.Tk() frame = Frame(root) frame.pack(side=Tkinter.TOP) button = Button(frame, text='get text', command=getText) button.pack(side=Tkinter.LEFT) button = createQuitButton(frame) button.pack(side=Tkinter.LEFT) text = ScrolledText( root, width=60, height=10, #text='in the beginning') text='in the beginning', xscroll=False) text.pack(side=Tkinter.TOP, expand=Tkinter.YES, fill=Tkinter.BOTH) root.mainloop()
texts = [ 'Text A', 'Text B', 'One color', 'Bicolor', 'Gradient', 'Other', 'Sub 1', 'Sub 2', 'Sub 3' ] objects = [ 1, 2, { 'color': 'red' }, 'Some text', 5.376574, None, 'A', 'B', 'C' ] cats = [None] * len(texts) sec = 'SubSection' cats[-1] = sec cats[-2] = sec cats[-3] = sec root = Tkinter.Tk() pulldownMenu = PulldownList(root, callback=callback, texts=texts, objects=objects, colors=colors, categories=cats) pulldownMenu.grid(row=0, column=0) button = Button(root, text='quit', command=sys.exit) button.grid(row=1, column=0) root.mainloop()
def __init__(self, guiParent, basePopup): self.guiParent = guiParent self.basePopup = basePopup #self.registerNotify=basePopup.registerNotify #self.unregisterNotify=basePopup.unregisterNotify self.task_id = None # should be set in parent initMethod() call now #self.basePopup.frameShortcuts['Task'].frameShortcuts['Test1'] = self # NOTE: JMCI # We can reasonably set the repository from the current repository. It is # harder to know how project/projectVersion and task interract # TODO # decide whether we really need this self.repository = self.basePopup.repList.currentRepository Frame.__init__(self, guiParent) # set up the grid self.grid_columnconfigure(0, weight=0, minsize=20) self.grid_columnconfigure(1, weight=0, minsize=30) self.grid_columnconfigure(2, weight=1, minsize=20) self.grid_columnconfigure(3, weight=0, minsize=20) self.grid_columnconfigure(4, weight=1, minsize=20) self.grid_rowconfigure(0, weight=0, minsize=20) self.grid_rowconfigure(1, weight=0, minsize=10) self.grid_rowconfigure(2, weight=0, minsize=10) self.grid_rowconfigure(3, weight=0, minsize=10) self.grid_rowconfigure(4, weight=0, minsize=20) # we define as much as possible once on startup and use the # grid manager to control the display thereafter # when no data self.noData_widgets = [] self.null_task_label = Label(self, text='No Task selected') self.noData_widgets.append(self.null_task_label) # when data self.data_widgets = [] self.task_rep_title = Label(self, text='Task:', font='Helvetica16') self.data_widgets.append(self.task_rep_title) self.task_rep_label = Label(self, text='Repository:') self.data_widgets.append(self.task_rep_label) self.task_rep_value = Label(self, text='') self.data_widgets.append(self.task_rep_value) self.task_status_label = Label(self, text='Status:') self.data_widgets.append(self.task_status_label) self.task_status_value = Label(self, text='') self.data_widgets.append(self.task_status_value) self.task_details_label = Label(self, text='Details:') self.data_widgets.append(self.task_details_label) self.task_details_value = Label(self, text='') self.data_widgets.append(self.task_details_value) self.task_date_label = Label(self, text='Date:') self.data_widgets.append(self.task_date_label) self.task_date_value = Label(self, text='') self.data_widgets.append(self.task_date_value) self.task_par1_label = Label(self, text='Par1:') self.data_widgets.append(self.task_par1_label) self.task_par1_value = Label(self, text='') self.data_widgets.append(self.task_par1_value) self.task_par2_label = Label(self, text='Par2:') self.data_widgets.append(self.task_par2_label) self.task_par2_value = Label(self, text='') self.data_widgets.append(self.task_par2_value) self.task_input_label = Label(self, text='Input Data:') self.data_widgets.append(self.task_input_label) self.task_input_value = Label(self, text='') self.data_widgets.append(self.task_input_value) self.button_file_in_browse = Button(self, text='Browse', command=self.tmpCall) self.data_widgets.append(self.button_file_in_browse) self.button_file_out_browse = Button(self, text='Browse', command=self.tmpCall) self.data_widgets.append(self.button_file_out_browse) self.task_output_label = Label(self, text='Output Data:') self.data_widgets.append(self.task_output_label) self.task_output_value = Label(self, text='') self.data_widgets.append(self.task_output_value) self.drawFrame()
def getColor(self): c = 3 * [0] for n in range(3): c[n] = float(self.labeled_scale[n].getValue()) / 100.0 return tuple(c) if __name__ == '__main__': import sys from memops.gui.Button import Button def quit(): global color_chooser print 'color:', color_chooser.getColor() sys.exit(0) root = Tkinter.Tk() color_chooser = ColorChooser(root, width=500, height=500) color_chooser.pack(side=Tkinter.TOP, expand=Tkinter.YES, fill=Tkinter.BOTH) button = Button(root, text='quit', command=quit) button.pack(side=Tkinter.TOP) root.mainloop()
if __name__ == '__main__': from memops.gui.Button import Button def get_me(): print 'get_me:', c.getSelected() n = 0 def toggle_me(): global n print 'toggle_me:', n c.toggleIndex(n) n = (n + 1) % 3 def my_callback(selected): print 'my_callback:', selected root = Tkinter.Tk() c = CheckButtons(root, ['one', 'two', 'three'], select_callback=my_callback, tipTexts=['Tip A', 'Tip B', 'Tip C']) c.grid() b = Button(root, text='get me', command=get_me) b.grid() b = Button(root, text='toggle me', command=toggle_me) b.grid() root.mainloop()
def body(self, guiFrame): spectraFrame = LabelFrame(guiFrame, text='Spectra', grid=(0, 0)) Label(spectraFrame, text='Diamagnetic Spectrum:', grid=(0, 0)) self.diaSpecPulldown = PulldownList(spectraFrame, callback=self.changeDiaSpec, grid=(0, 1)) Label(spectraFrame, text='Paramagnetic Spectrum:', grid=(1, 0)) self.paraSpecPulldown = PulldownList(spectraFrame, callback=self.changeParaSpec, grid=(1, 1)) pcsIOFrame = LabelFrame(guiFrame, text='PCS', grid=(1, 0)) Label(pcsIOFrame, text='Write Experimental PCS:', grid=(0, 0)) self.expPCSEntry = Entry(pcsIOFrame, text='pcsexp.npc', width=32, grid=(0, 1)) Button(pcsIOFrame, command=self.writePCSFileChange, grid=(0, 2), text='Choose File') Label(pcsIOFrame, text='Read Calculated PCS:', grid=(1, 0)) self.calPCSEntry = Entry(pcsIOFrame, text='pcscal.npc', width=32, grid=(1, 1)) Button(pcsIOFrame, command=self.readPCSFileChange, grid=(1, 2), text='Choose File') scriptFrame = LabelFrame(guiFrame, text='Paramagpy Script', grid=(2, 0)) Label(scriptFrame, text='PCS fitting script:', grid=(0, 0)) self.scriptEntry = Entry(scriptFrame, text='paramagpy_fit_pcs.py', width=32, grid=(0, 1)) Button(scriptFrame, command=self.writeScriptFileChange, grid=(0, 2), text='Choose File') commandFrame = LabelFrame(guiFrame, text='Commands', grid=(3, 0)) Button(commandFrame, command=self.writePCS, grid=(0, 0), text='Write PCS') Button(commandFrame, command=self.fitTensor, grid=(0, 1), text='Fit Tensor') Button(commandFrame, command=self.readPCS, grid=(0, 2), text='Read PCS') self.updateSpecPulldown()
elif (v < (float(scale['from']) - d)): d = -d scale.set(v + d) root = Tkinter.Tk() def func(args): print args scale = Scale(root, orient=Tkinter.HORIZONTAL, value=50.0, from_=1.0, to=99, oddNumbers=True, command=func, tipText='Some advice') scale.grid() scale.set(3) button = Button(root, text='hit me', command=func) button.grid() button = Button(root, text='Enable', command=scale.enable) button.grid() button = Button(root, text='Disable', command=scale.disable) button.grid() root.mainloop()
if __name__ == '__main__': from memops.gui.Button import Button def get_me(): print 'get_me:', r.get(), r.getIndex() def set_me(): c = r.getIndex() c = (c + 1) % 3 print 'set_me:', c r.setIndex(c) def my_callback(text): print 'my_callback:', text root = Tkinter.Tk() r = RadioButtons(root, ['one', 'two', 'three'], select_callback=my_callback, tipTexts=['Tip A', 'Tip B', 'Tip C']) r.grid() b = Button(root, text='get me', command=get_me) b.grid() b = Button(root, text='set me', command=set_me) b.grid() root.mainloop()
self.progress = float(value) else: raise 'Cannot set to a value exceeding the total' self.update() def setText(self, text=''): self.text = text self.label.set(self.text) if (__name__ == '__main__'): from memops.gui.Button import Button root = Tkinter.Tk() pb = None def makePB(): pb.set(0) pb.open() for i in range(100): time.sleep(0.01) pb.increment() b = Button(root, text="Hit Me", command=makePB) b.pack() pb = ProgressBar(root, text='Increments') root.mainloop()
def body(self): '''describes the body of this tab. It bascically consists of some field to fill out for the user at the top and a ScrolledGraph that shows the progess of the annealing procedure a the bottom. ''' frame = self.frame # frame.expandGrid(13,0) frame.expandGrid(15, 1) row = 0 text = 'Calculate Assignment Suggestions' command = self.runCalculations self.startButton = Button(frame, command=command, text=text) self.startButton.grid(row=row, column=0, sticky='nsew', columnspan=2) row += 1 Label(frame, text='Amount of runs: ', grid=(row, 0)) tipText = 'The amount of times the whole optimization procedure is performed, each result is safed' self.repeatEntry = IntEntry(frame, grid=(row, 1), width=7, text=10, returnCallback=self.updateRepeatEntry, tipText=tipText, sticky='nsew') self.repeatEntry.bind('<Leave>', self.updateRepeatEntry, '+') row += 1 Label(frame, text='Temperature regime: ', grid=(row, 0)) tipText = 'This list of numbers govern the temperature steps during the annealing, every number represents 1/(kb*t), where kb is the Boltzmann constant and t the temperature of one step.' self.tempEntry = Entry(frame, text=map(str, self.acceptanceConstantList), width=64, grid=(row, 1), isArray=True, returnCallback=self.updateAcceptanceConstantList, tipText=tipText, sticky='nsew') row += 1 Label(frame, text='Amount of attempts per temperature:', grid=(row, 0)) tipText = 'The amount of attempts to switch the position of two spinsystems in the sequence are performed for each temperature point' self.NAStepEntry = IntEntry(frame, grid=(row, 1), width=7, text=10000, returnCallback=self.updateStepEntry, tipText=tipText, sticky='nsew') self.NAStepEntry.bind('<Leave>', self.updateStepEntry, '+') row += 1 Label(frame, text='Fraction of peaks to leave out:', grid=(row, 0)) tipText = 'In each run a fraction of the peaks can be left out of the optimization, thereby increasing the variability in the outcome and reducing false negatives. In each run this will be different randomly chosen sub-set of all peaks. 0.1 (10%) can be a good value.' self.leaveOutPeaksEntry = FloatEntry(frame, grid=(row, 1), width=7, text=0.0, returnCallback=self.updateLeavePeaksOutEntry, tipText=tipText, sticky='nsew') self.leaveOutPeaksEntry.bind( '<Leave>', self.updateLeavePeaksOutEntry, '+') row += 1 Label(frame, text='Minmal amino acid typing score:', grid=(row, 0)) tipText = 'If automatic amino acid typing is selected, a cut-off value has to set. Every amino acid type that scores higher than the cut-off is taken as a possible type. This is the same score as can be found under resonance --> spin systems --> predict type. Value should be between 0 and 100' self.minTypeScoreEntry = FloatEntry(frame, grid=(row, 1), width=7, text=1.0, returnCallback=self.updateMinTypeScoreEntry, tipText=tipText, sticky='nsew') self.minTypeScoreEntry.bind( '<Leave>', self.updateMinTypeScoreEntry, '+') row += 1 Label(frame, text='Minimal colabelling fraction:', grid=(row, 0)) tipText = 'The minimal amount of colabelling the different nuclei should have in order to still give rise to a peak.' self.minLabelEntry = FloatEntry(frame, grid=(row, 1), width=7, text=0.1, returnCallback=self.updateMinLabelEntry, tipText=tipText, sticky='nsew') self.minLabelEntry.bind('<Leave>', self.updateMinLabelEntry, '+') row += 1 Label(frame, text='Use sequential assignments:', grid=(row, 0)) tipText = 'When this option is select the present sequential assignments will be kept in place' self.useAssignmentsCheck = CheckButton( frame, selected=True, tipText=tipText, grid=(row, 1)) row += 1 Label(frame, text='Use tentative assignments:', grid=(row, 0)) tipText = 'If a spin system has tentative assignments this can be used to narrow down the amount of possible sequential assignments.' self.useTentativeCheck = CheckButton( frame, selected=True, tipText=tipText, grid=(row, 1)) row += 1 Label(frame, text='Use amino acid types:', grid=(row, 0)) tipText = 'Use amino acid types of the spin systems. If this option is not checked the spin systems are re-typed, only resonance names and frequencies are used' self.useTypeCheck = CheckButton( frame, selected=True, tipText=tipText, grid=(row, 1)) row += 1 Label(frame, text='Include untyped spin systems:', grid=(row, 0)) tipText = 'Also include spin system that have no type information. Amino acid typing will be done on the fly.' self.useAlsoUntypedSpinSystemsCheck = CheckButton( frame, selected=True, tipText=tipText, grid=(row, 1)) row += 1 Label(frame, text='Use dimensional assignments:', grid=(row, 0)) tipText = 'If one or more dimensions of a peak is already assigned, assume that this assignment is the only option. If not the check the program will consider all possibilities for the assignment of the dimension.' self.useDimensionalAssignmentsCheck = CheckButton( frame, selected=True, tipText=tipText, grid=(row, 1)) row += 1 Label(frame, text='Chain:', grid=(row, 0)) self.molPulldown = PulldownList( frame, callback=self.changeMolecule, grid=(row, 1)) self.updateChains() row += 1 Label(frame, text='Residue ranges: ', grid=(row, 0)) tipText = 'Which residues should be included. Example: "10-35, 62-100, 130".' self.residueRangeEntry = Entry(frame, text=None, width=64, grid=(row, 1), isArray=True, returnCallback=self.updateResidueRanges, tipText=tipText, sticky='nsew') self.updateResidueRanges(fromChain=True) row += 1 self.energyPlot = ScrolledGraph(frame, symbolSize=2, width=600, height=200, title='Annealing', xLabel='temperature step', yLabel='energy') self.energyPlot.grid(row=row, column=0, columnspan=2, sticky='nsew')