def doUI(self, parent): self.scrFrame = Pmw.ScrolledFrame(self, frame_relief='sunken', horizflex='expand') self.scrFrame.grid(row=0, column=0, padx=5, columnspan=2, sticky='nsew') self.rowFrame = self.scrFrame.component('frame') self.addB = Tkinter.Button(self, command=self._addCB) plus_image = chimage.get("plus.gif", self.addB) self.addB.configure(image=plus_image) self.addB._image = plus_image help.register(self.addB, balloon="Add a row below currently selected row") self.addB.grid(row=1, column=0, pady=5, padx=0, sticky='n') self.delB = Tkinter.Button(self, command=self._delCB) minus_image = chimage.get("minus.gif", self.delB) self.delB.configure(image=minus_image) self.delB._image = minus_image help.register(self.delB, balloon="Delete the currently selected row") self.delB.grid(row=1, column=1, pady=5, padx=0, sticky='nw') self.delB.configure(state="disabled") self.rowconfigure(0, weight=10) self.rowconfigure(1, weight=0) self.columnconfigure(1, weight=10)
def populateButtonFrame(self): self.closeButton = Tkinter.Button(self.buttonFrame, text="Close Demo", command=self.Clear) self.closeButton.pack(side='right', pady=5) self.saveAsButton = Tkinter.Button(self.buttonFrame, text="Save As", command=self.SaveAs) self.saveAsButton.pack(side='right', pady=5) self.saveButton = Tkinter.Button(self.buttonFrame, text="Save", command=self.Save) self.saveButton.pack(side='right', pady=5) self.openButton = Tkinter.Button(self.buttonFrame, text="Open Demo", command=self.Open) self.openButton.pack(side='right', pady=5) self.runButton = Tkinter.Button(self.buttonFrame, text="Run", command=self.Run) self.runButton.pack(side='right', pady=5) help.register(self.openButton, balloon="Open a Demo file in editor") help.register(self.saveButton, balloon="Save Demo to file") help.register(self.saveAsButton, balloon="Save Demo to new file") help.register(self.closeButton, balloon="Close current Demo") help.register(self.runButton, balloon="Run a Demo from current panels in editor")
def _showButton(self, name): callback, minGroups, maxGroups, balloon = _buttonInfo[name] kw = {} numSelected = len(self.groupsTable.hlist.info_selection()) state = 'normal' if minGroups and numSelected < minGroups \ or maxGroups != None and numSelected > maxGroups: state = 'disabled' kw['state'] = state kw['pady'] = 0 kw['command'] = lambda cb=callback, s=self: apply(cb, (s.selected(),)) # determine where to add the button... self.shownButtons.append(name) self.shownButtons.sort() index = self.shownButtons.index(name) if index == len(self.shownButtons)-1: addFunc = self.actionButtons.add else: addFunc = self.actionButtons.insert kw['beforeComponent'] = self.shownButtons[index+1] but = apply(addFunc, (name,), kw) but.config(default='disabled') if balloon: help.register(but, balloon=balloon)
def doUI(self, parent): self.scrFrame = Pmw.ScrolledFrame(self, frame_relief='sunken', horizflex='expand') self.scrFrame.grid(row=0, column=0,padx=5, columnspan=2, sticky='nsew') self.rowFrame = self.scrFrame.component('frame') self.addB = Tkinter.Button(self, command=self._addCB) plus_image = chimage.get("plus.gif",self.addB) self.addB.configure(image=plus_image) self.addB._image = plus_image help.register(self.addB, balloon="Add a row below currently selected row") self.addB.grid(row=1,column=0,pady=5,padx=0,sticky='n') self.delB = Tkinter.Button(self, command=self._delCB) minus_image = chimage.get("minus.gif",self.delB) self.delB.configure(image=minus_image) self.delB._image = minus_image help.register(self.delB, balloon="Delete the currently selected row") self.delB.grid(row=1,column=1,pady=5,padx=0,sticky='nw') self.delB.configure(state="disabled") self.rowconfigure(0, weight=10) self.rowconfigure(1, weight=0) self.columnconfigure(1, weight=10)
def populateTextFrame(self): self.textLabel = Tkinter.Label(self.textFrame, text="Text", font="helvetica -14 bold") self.textLabel.grid(row=0, sticky='w', pady=5) self.textInput = Pmw.ScrolledText( self.textFrame, text_pyclass=HtmlText, text_relief='sunken', text_wrap='word', #text_height=10, #text_width=50 ) self.textInput.grid(row=1, sticky='nsew', padx=5) self.previewCheckB = Tkinter.Checkbutton(self.textFrame, text="Preview", command=self.previewCB) self.previewCheckB.grid(row=2, sticky='e', pady=10) help.register(self.previewCheckB, balloon="Preview text as rendered HTML") self.textFrame.rowconfigure(0, weight=1) self.textFrame.rowconfigure(1, weight=30) self.textFrame.rowconfigure(2, weight=1) self.textFrame.columnconfigure(0, weight=1)
def populateButtonFrame(self): self.closeButton = Tkinter.Button(self.buttonFrame, text="Close Demo", command=self.Clear) self.closeButton.pack(side='right', pady=5) self.saveAsButton = Tkinter.Button(self.buttonFrame, text="Save As", command=self.SaveAs) self.saveAsButton.pack(side='right', pady=5) self.saveButton = Tkinter.Button(self.buttonFrame, text="Save", command=self.Save) self.saveButton.pack(side='right', pady=5) self.openButton = Tkinter.Button(self.buttonFrame, text="Open Demo", command=self.Open) self.openButton.pack(side='right', pady=5) self.runButton = Tkinter.Button(self.buttonFrame, text="Run", command=self.Run) self.runButton.pack(side='right', pady=5) help.register(self.openButton, balloon="Open a Demo file in editor") help.register(self.saveButton, balloon="Save Demo to file") help.register(self.saveAsButton, balloon="Save Demo to new file") help.register(self.closeButton, balloon="Close current Demo") help.register(self.runButton, balloon="Run a Demo from current panels in editor")
def _notifyEncodingComplete(self, exit_status): """this is called from outside of this module, probably from the director, to notify me (the gui) that encoding has completed""" #self.actionLabel.configure(text="Stopped", fg='black') self.statusLine.configure(textvariable='') #self.encButton.configure(image=self.movie_img) self.encButton.configure(text="Make movie") help.register(self.encButton, balloon="Make a movie from currently captured frames") ## re-enable buttons self.clearButton.configure(state='normal') self.recButton.configure(state='normal') self.encButton.configure(command=self.startEncoding) if exit_status == EXIT_SUCCESS: self.actionLabel.configure(text="Successfully encoded!!", fg='red') elif exit_status == EXIT_CANCEL: self.actionLabel.configure(text="Canceled encoding!!", fg='red') elif exit_status == EXIT_ERROR: self.actionLabel.configure(text="Encoding error", fg='red')
def _showButton(self, name): callback, minGroups, maxGroups, balloon = _buttonInfo[name] kw = {} numSelected = len(self.groupsTable.hlist.info_selection()) state = 'normal' if minGroups and numSelected < minGroups \ or maxGroups != None and numSelected > maxGroups: state = 'disabled' kw['state'] = state kw['pady'] = 0 kw['command'] = lambda cb=callback, s=self: apply(cb, (s.selected(), )) # determine where to add the button... self.shownButtons.append(name) self.shownButtons.sort() index = self.shownButtons.index(name) if index == len(self.shownButtons) - 1: addFunc = self.actionButtons.add else: addFunc = self.actionButtons.insert kw['beforeComponent'] = self.shownButtons[index + 1] but = apply(addFunc, (name, ), kw) but.config(default='disabled') if balloon: help.register(but, balloon=balloon)
def _notifyEncodingStart(self): self.statusLine.configure(textvariable=self.frame_num_var) self.actionLabel.configure(text="Encoding", fg='red') #self.encButton.configure(image=self.abort_img, command=self.abortEncoding) self.encButton.configure(text="Cancel movie", command=self.abortEncoding) help.register(self.encButton, balloon="Cancel encoding of movie") ## establish constraints self.clearButton.configure(state='disabled') self.recButton.configure(state='disabled')
def fillInUI(self, parent): self.computePageSize = 1 self.buttonInfo = {} self.columnInfo = {} self.noteBook = Pmw.NoteBook(parent) buts = self.noteBook.add("Buttons") help.register(self.noteBook.tab("Buttons"), balloon='configure action buttons') cols = self.noteBook.add("Columns") help.register(self.noteBook.tab("Columns"), balloon='configure model table columns') dbl = self.noteBook.add("Double Click") help.register(self.noteBook.tab("Double Click"), balloon= 'select actions for double click in model table') self.noteBook.pack(expand='yes', fill='both') # fill in 'Buttons' page Tkinter.Label(buts, text='Checked buttons will be in' ' frequent-actions list\n' 'Others will be in infrequent-actions list').grid( row=0, column=0, columnspan=3) # fill in 'Columns' page Tkinter.Label(cols, text='Checked columns will be shown' ' in model table').grid(row=0, column=0, columnspan=4) self.showColorVar = Tkinter.IntVar(cols) self.showColorVar.set(self.prefs['showColor']) self.colDivider = Tkinter.Frame(cols, background='black') self.showColorButton = Tkinter.Checkbutton(cols, text="Show model color behind model name", command=self.modelPanel._buildTable, variable=self.showColorVar) # fill in 'Double Click' page dbl.rowconfigure(0, weight=1) dbl.columnconfigure(0, weight=1) dbl.columnconfigure(1, weight=1) self.dblCommandsList = Pmw.ScrolledListBox(dbl, hscrollmode='none', labelpos='nw', label_text="Execution list", items=self.prefs['executionList'], selectioncommand=self._removeDblCmdCB) self.dblCommandsList.grid(row=0, column=0, sticky='nsew') help.register(self.dblCommandsList, balloon='list of functions to execute when model\n' 'is double-clicked in model panel;\n' 'click on function to remove from list') self.dblCommandMenu = Pmw.ScrolledListBox(dbl, hscrollmode='none', labelpos='nw', label_text='Function menu', selectioncommand=self._addDblCmdCB) self.dblCommandMenu.grid(row=0, column=1, sticky='nsew') help.register(self.dblCommandMenu, balloon='click on function to add to execution list')
def _notifyRecordingStop(self): self.showStatus("Stopped recording", blankAfter=20) self.actionLabel.configure(text="Stopped", fg='black') ## restore button states to normal #self.recButton.configure(image=self.rec_img, command=self.startRecording) self.recButton.configure(text="Record", state='normal', command=self.startRecording) help.register(self.recButton, balloon="Start capturing frames from the graphics window") self.encButton.configure(state='normal') self.clearButton.configure(state='normal')
def categoriesChanged(self): "Called by Preferences when list of categories changes." cList = self._pref.categories() cList.sort() self.menu.setitems(cList) for category in cList: ui = self._pref.ui(category, self.frame) if not ui: continue help.register(ui, "UsersGuide/preferences.html#%s" % category)
def fillInUI(self, parent): self.computePageSize = 1 self.buttonInfo = {} self.columnInfo = {} self.noteBook = Pmw.NoteBook(parent) buts = self.noteBook.add("Buttons") help.register(self.noteBook.tab("Buttons"), balloon='configure action buttons') cols = self.noteBook.add("Columns") help.register(self.noteBook.tab("Columns"), balloon='configure groups table columns') dbl = self.noteBook.add("Double Click") help.register( self.noteBook.tab("Double Click"), balloon='select actions for double click in groups table') self.noteBook.pack(expand='yes', fill='both') # fill in 'Buttons' page Tkinter.Label(buts, text='Checked buttons will be shown' ' in group panel').grid(row=0, column=0, columnspan=3) # fill in 'Columns' page Tkinter.Label(cols, text='Checked columns will be shown' ' in groups table').grid(row=0, column=0, columnspan=4) # fill in 'Double Click' page dbl.rowconfigure(0, weight=1) dbl.columnconfigure(0, weight=1) dbl.columnconfigure(1, weight=1) self.dblCommandsList = Pmw.ScrolledListBox( dbl, hscrollmode='none', labelpos='nw', label_text="Execution list", items=self.prefs['executionList'], selectioncommand=self._removeDblCmdCB) self.dblCommandsList.grid(row=0, column=0, sticky='nsew') help.register(self.dblCommandsList, balloon='list of functions to execute when group\n' 'is double-clicked in group panel;\n' 'click on function to remove from list') self.dblCommandMenu = Pmw.ScrolledListBox( dbl, hscrollmode='none', labelpos='nw', label_text='Function menu', selectioncommand=self._addDblCmdCB) self.dblCommandMenu.grid(row=0, column=1, sticky='nsew') help.register(self.dblCommandMenu, balloon='click on function to add to execution list')
def _buildTable(self): if hasattr(self, 'modelTable'): # can't dynamically add columns to Tix widget; # destroy and recreate selected = self.selected() self.modelTable.grid_forget() self.modelTable.destroy() else: selected = None self.modelTable = Tix.ScrolledHList(self.parent, width="%d" % self.parent.winfo_pixels("3i"), options="""hlist.columns %d hlist.header 1 hlist.selectMode extended hlist.indicator 0""" % len(filter(lambda s: s == 1, self.shownColumns))) help.register(self.modelTable, balloon=self.modelTableHelp) self.modelTable.hlist.config(browsecmd=self._selChange, command=self._dblClick) self.textStyle = Tix.DisplayStyle("text", refwindow=self.modelTable) # get a style for checkbutton columns... self.checkButtonStyle = Tix.DisplayStyle("window", refwindow=self.modelTable, anchor="center") self.colorWellStyle = Tix.DisplayStyle("window", refwindow=self.modelTable, anchor="center") colNum = 0 self.columnMap = [] showFullTitles = False last = self._confDialog.prefs["lastUse"] from time import time now = self._confDialog.prefs["lastUse"] = time() if last is None or now - last > 777700: # about 3 months showFullTitles = True for index in range(len(_columnNames)): if not self.shownColumns[index]: continue self.columnMap.append(index) text = _columnNames[index] if _valueTypes[index] == 'toggle' \ and not showFullTitles: text = text[:1] self.modelTable.hlist.header_create(colNum, itemtype='text', text=text) colNum = colNum + 1 self.parent.columnconfigure(10, weight=1) self.parent.rowconfigure(10, weight=1) self.modelTable.grid(row=10, column=10, sticky='nsew', rowspan=11) self._fillTable(selected=selected, fromScratch=1)
def categoriesChanged(self): "Called by Preferences when list of categories changes." cList = self._pref.categories() cList.sort() self.menu.setitems(cList) for category in cList: ui = self._pref.ui(category, self.frame) if not ui: continue help.register(ui, "UsersGuide/preferences.html#%s" % category)
def _buildTable(self): if hasattr(self, 'modelTable'): # can't dynamically add columns to Tix widget; # destroy and recreate selected = self.selected() self.modelTable.grid_forget() self.modelTable.destroy() else: selected = None self.modelTable = Tix.ScrolledHList(self.parent, width="%d" % self.parent.winfo_pixels("3i"), options="""hlist.columns %d hlist.header 1 hlist.selectMode extended hlist.indicator 0""" % len(filter(lambda s: s == 1, self.shownColumns))) help.register(self.modelTable, balloon=self.modelTableHelp) self.modelTable.hlist.config(browsecmd=self._selChange, command=self._dblClick) self.textStyle = Tix.DisplayStyle("text", refwindow=self.modelTable) # get a style for checkbutton columns... self.checkButtonStyle = Tix.DisplayStyle("window", refwindow=self.modelTable, anchor="center") self.colorWellStyle = Tix.DisplayStyle("window", refwindow=self.modelTable, anchor="center") colNum = 0 self.columnMap = [] showFullTitles = False last = self._confDialog.prefs["lastUse"] from time import time now = self._confDialog.prefs["lastUse"] = time() if last is None or now - last > 777700: # about 3 months showFullTitles = True for index in range(len(_columnNames)): if not self.shownColumns[index]: continue self.columnMap.append(index) text = _columnNames[index] if _valueTypes[index] == 'toggle' \ and not showFullTitles: text = text[:1] self.modelTable.hlist.header_create(colNum, itemtype='text', text=text) colNum = colNum + 1 self.parent.columnconfigure(10, weight=1) self.parent.rowconfigure(10, weight=1) self.modelTable.grid(row=10, column=10, sticky='nsew', rowspan=11) self._fillTable(selected=selected, fromScratch=1)
def newButton(self, butName, balloon=None): self.computePageSize = 1 # 'Buttons' tab... for bn in self.buttonInfo.keys(): self.buttonInfo[bn]['widget'].grid_forget() butPage = self.noteBook.page("Buttons") bdict = {} v = Tkinter.IntVar(butPage) if not self.prefs['shownButs'].has_key(butName): self.prefs['shownButs'][butName] = 1 elif not self.prefs['shownButs'][butName]: # take button out of list self.groupPanel._hideButton(butName) v.set(self.prefs['shownButs'][butName]) bdict['variable'] = v bdict['widget'] = Tkinter.Checkbutton( butPage, variable=v, command=lambda s=self, b=butName: s._butChangeCB(b), text=butName) self.buttonInfo[butName] = bdict if balloon: help.register(bdict['widget'], balloon=balloon) numButs = len(self.buttonInfo) # figure out size of columns [3 columns] third = numButs / 3.0 if third > int(third): third = int(third) + 1 row = 1 col = 0 keys = self.buttonInfo.keys() keys.sort() for bn in keys: self.buttonInfo[bn]['widget'].grid(row=row, column=col, sticky='w') row = row + 1 if row > third: col = col + 1 row = 1 # 'Double Click' tab... (callback, minGroups, maxGroups, balloon) = _buttonInfo[butName] if minGroups is None or minGroups < 2: if maxGroups is None or maxGroups > 0: cmds = list(self.dblCommandMenu.get(None)) cmds.append(butName) cmds.sort() self.dblCommandMenu.setlist(cmds)
def _notifyRecordingStart(self): ## <-------code that updates the gui---------> # self.actionLabel.configure(text="Recording", fg='red') ## set button states to disabled #self.recButton.configure(image=self.pause_img, command=self.stopRecording) self.recButton.configure(text="Stop", state='normal', command=self.stopRecording) help.register(self.recButton, balloon="Stop capturing frames from graphics window") self.clearButton.configure(state='disabled') self.encButton.configure(state='disabled') self.disableInputOptions()
def newButton(self, butName, balloon=None): self.computePageSize = 1 # 'Buttons' tab... for bn in self.buttonInfo.keys(): self.buttonInfo[bn]['widget'].grid_forget() butPage = self.noteBook.page("Buttons") bdict = {} v = Tkinter.IntVar(butPage) if not self.prefs['shownButs'].has_key(butName): self.prefs['shownButs'][butName] = 1 elif not self.prefs['shownButs'][butName]: # take button out of list self.groupPanel._hideButton(butName) v.set(self.prefs['shownButs'][butName]) bdict['variable'] = v bdict['widget'] = Tkinter.Checkbutton(butPage, variable=v, command=lambda s=self, b=butName: s._butChangeCB(b), text=butName) self.buttonInfo[butName] = bdict if balloon: help.register(bdict['widget'], balloon=balloon) numButs = len(self.buttonInfo) # figure out size of columns [3 columns] third = numButs / 3.0 if third > int(third): third = int(third) + 1 row = 1 col = 0 keys = self.buttonInfo.keys() keys.sort() for bn in keys: self.buttonInfo[bn]['widget'].grid(row=row, column=col, sticky='w') row = row + 1 if row > third: col = col + 1 row = 1 # 'Double Click' tab... (callback, minGroups, maxGroups, balloon) = _buttonInfo[butName] if minGroups is None or minGroups < 2: if maxGroups is None or maxGroups > 0: cmds = list(self.dblCommandMenu.get(None)) cmds.append(butName) cmds.sort() self.dblCommandMenu.setlist(cmds)
def newButton(self, butName, balloon=None, defaultFrequent=1): self.computePageSize = 1 # 'Buttons' tab... for bn in self.buttonInfo.keys(): self.buttonInfo[bn]['widget'].grid_forget() butPage = self.noteBook.page("Buttons") bdict = {} v = Tkinter.IntVar(butPage) if not self.prefs['freqButs'].has_key(butName): self.setDictPref('freqButs', butName, defaultFrequent) v.set(self.prefs['freqButs'][butName]) bdict['variable'] = v bdict['widget'] = Tkinter.Checkbutton( butPage, variable=v, command=lambda s=self, b=butName: s._butChangeCB(b), text=butName, highlightthickness=0) self.buttonInfo[butName] = bdict if balloon: help.register(bdict['widget'], balloon=balloon) numButs = len(self.buttonInfo) # figure out size of columns [3 columns] third = numButs / 3.0 if third > int(third): third = int(third) + 1 row = 1 col = 0 keys = self.buttonInfo.keys() keys.sort(lambda a, b: cmp(a.lower(), b.lower())) for bn in keys: self.buttonInfo[bn]['widget'].grid(row=row, column=col, sticky='w') row = row + 1 if row > third: col = col + 1 row = 1 # 'Double Click' tab... minModels, maxModels = _buttonInfo[butName][1:3] if minModels is None or minModels < 2: if maxModels is None or maxModels > 0: cmds = list(self.dblCommandMenu.get(None)) cmds.append(butName) cmds.sort() self.dblCommandMenu.setlist(cmds)
def newButton(self, butName, balloon=None, defaultFrequent=1): self.computePageSize = 1 # 'Buttons' tab... for bn in self.buttonInfo.keys(): self.buttonInfo[bn]['widget'].grid_forget() butPage = self.noteBook.page("Buttons") bdict = {} v = Tkinter.IntVar(butPage) if not self.prefs['freqButs'].has_key(butName): self.setDictPref('freqButs', butName, defaultFrequent) v.set(self.prefs['freqButs'][butName]) bdict['variable'] = v bdict['widget'] = Tkinter.Checkbutton(butPage, variable=v, command=lambda s=self, b=butName: s._butChangeCB(b), text=butName, highlightthickness=0) self.buttonInfo[butName] = bdict if balloon: help.register(bdict['widget'], balloon=balloon) numButs = len(self.buttonInfo) # figure out size of columns [3 columns] third = numButs / 3.0 if third > int(third): third = int(third) + 1 row = 1 col = 0 keys = self.buttonInfo.keys() keys.sort(lambda a, b: cmp(a.lower(), b.lower())) for bn in keys: self.buttonInfo[bn]['widget'].grid(row=row, column=col, sticky='w') row = row + 1 if row > third: col = col + 1 row = 1 # 'Double Click' tab... minModels, maxModels = _buttonInfo[butName][1:3] if minModels is None or minModels < 2: if maxModels is None or maxModels > 0: cmds = list(self.dblCommandMenu.get(None)) cmds.append(butName) cmds.sort() self.dblCommandMenu.setlist(cmds)
def _showButton(self, name): callback, minModels, maxModels, moleculesOnly, balloon, \ defaultFrequent = _buttonInfo[name] kw = {} state = 'normal' if self._shouldDisable(minModels, maxModels, moleculesOnly): state = 'disabled' kw['state'] = state kw['pady'] = 0 # if you click a button fast enough, you can get around it's # upcoming disabling... def cmd(cb=callback, s=self, mo=moleculesOnly, minm=minModels, maxm=maxModels): if not s._shouldDisable(minm, maxm, mo): cb(s.selected(moleculesOnly=mo)) kw['command'] = cmd # determine where to add the button... freqPrefs = self._confDialog.prefs['freqButs'] if freqPrefs.has_key(name): isFrequent = freqPrefs[name] else: isFrequent = defaultFrequent if isFrequent: buttons = self.frequentButtons actionButtons = self.freqActionButtons else: buttons = self.infrequentButtons actionButtons = self.infreqActionButtons buttons.append(name) buttons.sort(lambda a, b: cmp(a.lower(), b.lower())) index = buttons.index(name) if index == len(buttons) - 1: addFunc = actionButtons.add else: addFunc = actionButtons.insert kw['beforeComponent'] = buttons[index + 1] but = apply(addFunc, (name, ), kw) but.config(default='disabled') if balloon: help.register(but, balloon=balloon)
def fillInUI(self, parent): self.computePageSize = 1 self.buttonInfo = {} self.columnInfo = {} self.noteBook = Pmw.NoteBook(parent) buts = self.noteBook.add("Buttons") help.register(self.noteBook.tab("Buttons"), balloon='configure action buttons') cols = self.noteBook.add("Columns") help.register(self.noteBook.tab("Columns"), balloon='configure groups table columns') dbl = self.noteBook.add("Double Click") help.register(self.noteBook.tab("Double Click"), balloon= 'select actions for double click in groups table') self.noteBook.pack(expand='yes', fill='both') # fill in 'Buttons' page Tkinter.Label(buts, text='Checked buttons will be shown' ' in group panel').grid(row=0, column=0, columnspan=3) # fill in 'Columns' page Tkinter.Label(cols, text='Checked columns will be shown' ' in groups table').grid(row=0, column=0, columnspan=4) # fill in 'Double Click' page dbl.rowconfigure(0, weight=1) dbl.columnconfigure(0, weight=1) dbl.columnconfigure(1, weight=1) self.dblCommandsList = Pmw.ScrolledListBox(dbl, hscrollmode='none', labelpos='nw', label_text="Execution list", items=self.prefs['executionList'], selectioncommand=self._removeDblCmdCB) self.dblCommandsList.grid(row=0, column=0, sticky='nsew') help.register(self.dblCommandsList, balloon='list of functions to execute when group\n' 'is double-clicked in group panel;\n' 'click on function to remove from list') self.dblCommandMenu = Pmw.ScrolledListBox(dbl, hscrollmode='none', labelpos='nw', label_text='Function menu', selectioncommand=self._addDblCmdCB) self.dblCommandMenu.grid(row=0, column=1, sticky='nsew') help.register(self.dblCommandMenu, balloon='click on function to add to execution list')
def _buildTable(self): if hasattr(self, 'groupsTable'): # can't dynamically add columns to Tix widget; # destroy and recreate selected = self.selected() self.groupsTable.grid_forget() self.groupsTable.destroy() else: selected = None self.groupsTable = Tix.ScrolledHList(self.parent, width="%d" % self.parent.winfo_pixels("3i"), options="""hlist.columns %d hlist.background #0000bfffffff hlist.header 1 hlist.selectMode extended hlist.indicator 0""" % len(filter(lambda s: s == 1, self.shownColumns))) help.register(self.groupsTable, balloon=self.groupsTableHelp) self.groupsTable.hlist.config(browsecmd=self._selChange, command=self._dblClick) self.textStyle = Tix.DisplayStyle("text", background="#0000bfffffff", refwindow=self.groupsTable) # get a style for checkbutton columns... self.checkButtonStyle = Tix.DisplayStyle("window", background="#0000bfffffff", refwindow=self.groupsTable, anchor="center") colNum = 0 self.columnMap = [] for index in range(len(_columnNames)): if not self.shownColumns[index]: continue self.columnMap.append(index) self.groupsTable.hlist.header_create(colNum, itemtype='text', text=_columnNames[index]) colNum = colNum + 1 self.parent.columnconfigure(10, weight=1) self.parent.rowconfigure(10, weight=1) self.groupsTable.grid(row=10, column=10, sticky='nsew') self._fillTable(selected=selected, fromScratch=1)
def _buildTable(self): if hasattr(self, 'groupsTable'): # can't dynamically add columns to Tix widget; # destroy and recreate selected = self.selected() self.groupsTable.grid_forget() self.groupsTable.destroy() else: selected = None self.groupsTable = Tix.ScrolledHList(self.parent, width="%d" % self.parent.winfo_pixels("3i"), options="""hlist.columns %d hlist.background #0000bfffffff hlist.header 1 hlist.selectMode extended hlist.indicator 0""" % len(filter(lambda s: s == 1, self.shownColumns))) help.register(self.groupsTable, balloon=self.groupsTableHelp) self.groupsTable.hlist.config(browsecmd=self._selChange, command=self._dblClick) self.textStyle = Tix.DisplayStyle("text", background="#0000bfffffff", refwindow=self.groupsTable) # get a style for checkbutton columns... self.checkButtonStyle = Tix.DisplayStyle("window", background="#0000bfffffff", refwindow=self.groupsTable, anchor="center") colNum = 0 self.columnMap = [] for index in range(len(_columnNames)): if not self.shownColumns[index]: continue self.columnMap.append(index) self.groupsTable.hlist.header_create(colNum, itemtype='text', text=_columnNames[index]) colNum = colNum + 1 self.parent.columnconfigure(10, weight=1) self.parent.rowconfigure(10, weight=1) self.groupsTable.grid(row=10, column=10, sticky='nsew') self._fillTable(selected=selected, fromScratch=1)
def _showButton(self, name): callback, minModels, maxModels, moleculesOnly, balloon, \ defaultFrequent = _buttonInfo[name] kw = {} state = 'normal' if self._shouldDisable(minModels, maxModels, moleculesOnly): state = 'disabled' kw['state'] = state kw['pady'] = 0 # if you click a button fast enough, you can get around it's # upcoming disabling... def cmd(cb=callback, s=self, mo=moleculesOnly, minm=minModels, maxm=maxModels): if not s._shouldDisable(minm, maxm, mo): cb(s.selected(moleculesOnly=mo)) kw['command'] = cmd # determine where to add the button... freqPrefs = self._confDialog.prefs['freqButs'] if freqPrefs.has_key(name): isFrequent = freqPrefs[name] else: isFrequent = defaultFrequent if isFrequent: buttons = self.frequentButtons actionButtons = self.freqActionButtons else: buttons = self.infrequentButtons actionButtons = self.infreqActionButtons buttons.append(name) buttons.sort(lambda a, b: cmp(a.lower(), b.lower())) index = buttons.index(name) if index == len(buttons)-1: addFunc = actionButtons.add else: addFunc = actionButtons.insert kw['beforeComponent'] = buttons[index+1] but = apply(addFunc, (name,), kw) but.config(default='disabled') if balloon: help.register(but, balloon=balloon)
def createMenu(self): "Create Tools and Favorites menu items on menu bar" from chimera import help from chimera.tkgui import app, MENU_TOOLS, MENU_FAVORITES from CGLtk.MenuBalloon import MenuBalloon menu = Tkinter.Menu(app.menubar, title="Tools") balloon = MenuBalloon(menu) app.menubar.entryconfigure(MENU_TOOLS, menu=menu) help.register(menu, "UsersGuide/menu.html#menutools") favorites = Tkinter.Menu(app.menubar, title="Favorites") app.menubar.entryconfigure(MENU_FAVORITES, menu=favorites) help.register(menu, "UsersGuide/menu.html#menufavorites") from chimera.tkgui import updateAquaMenuBar updateAquaMenuBar(app.menubar) self.menu = menu self.menuBalloon = balloon self.remakeToolsMenu() self.favorites = favorites self.remakeFavorites()
def createMenu(self): "Create Tools and Favorites menu items on menu bar" from chimera import help from chimera.tkgui import app, MENU_TOOLS, MENU_FAVORITES from CGLtk.MenuBalloon import MenuBalloon menu = Tkinter.Menu(app.menubar, title="Tools") balloon = MenuBalloon(menu) app.menubar.entryconfigure(MENU_TOOLS, menu=menu) help.register(menu, "UsersGuide/menu.html#menutools") favorites = Tkinter.Menu(app.menubar, title="Favorites") app.menubar.entryconfigure(MENU_FAVORITES, menu=favorites) help.register(menu, "UsersGuide/menu.html#menufavorites") from chimera.tkgui import updateAquaMenuBar updateAquaMenuBar(app.menubar) self.menu = menu self.menuBalloon = balloon self.remakeToolsMenu() self.favorites = favorites self.remakeFavorites()
def __init__(self, pref, master=None, *args, **kw): self._pref = pref apply(ModelessDialog.__init__, (self, master) + args, kw) help.register(self.buttonWidgets["Save"], balloon="Save category") help.register(self.buttonWidgets["Restore"], balloon="Restore category to saved defaults") help.register(self.buttonWidgets["Reset"], balloon="Reset category to factory defaults")
def populateListFrame(self): self.panelsLabel = Tkinter.Label(self.pListFrame, text="Panels", font="helvetica -14 bold") self.panelsLabel.grid(row=0, column=0, columnspan=4, sticky='w') self.panelList = Pmw.ScrolledListBox(self.pListFrame, labelmargin=10, listbox_height=5, listbox_width=20, listbox_selectmode=Tkinter.SINGLE, selectioncommand=self.refreshPanelCB, listbox_exportselection=False) #dblclickcommand=self.showPanelEntry) self.panelList.grid(row=1, column=0, padx=10, columnspan=4, sticky='nsew') this_dir = os.path.split(Demo.__file__)[0] self.upButton = Tkinter.Button(self.pListFrame, command=self.panelUp) up_image=chimage.get("arrow_up.gif", self.upButton)#text="/\\") self.upButton.configure(image=up_image, state="disabled") self.upButton._image = up_image help.register(self.upButton, balloon="Move currently selected panel up") self.upButton.grid(row=2,column=0,sticky='s') self.downButton=Tkinter.Button(self.pListFrame, command=self.panelDown) down_image=chimage.get("arrow_down.gif", self.downButton)#text="/\\") self.downButton.configure(image=down_image, state="disabled") self.downButton._image = down_image help.register(self.downButton, balloon="Move currently selected panel down") self.downButton.grid(row=3,column=0,sticky='n') self.deleteButton = Tkinter.Button(self.pListFrame, text="Delete", command=self.deletePanel, state="disabled") help.register(self.deleteButton, balloon="Delete currently selected panel") self.deleteButton.grid(row=2,column=1,rowspan=2) self.newButton = Tkinter.Button(self.pListFrame, text="New", command=self.newPanelCB) help.register(self.newButton, balloon="Add a new panel") self.newButton.grid(row=2, column=2,rowspan=2) #self.editGlobalB = Tkinter.Button(self.pListFrame, text="Edit Demo Options", # command=self.editGlobalCB) #help.register(self.editGlobalB, balloon="Edit global options for Demo") #self.editGlobalB.grid(row=4,column=0,columnspan=4, sticky='w') self.pListFrame.rowconfigure(0, weight=1) self.pListFrame.rowconfigure(1, weight=20) self.pListFrame.rowconfigure(2, weight=1) self.pListFrame.rowconfigure(3, weight=1) self.pListFrame.rowconfigure(4, weight=1)
def __init__(self, pref, master=None, *args, **kw): self._pref = pref apply(ModelessDialog.__init__, (self, master) + args, kw) help.register(self.buttonWidgets["Save"], balloon="Save category") help.register(self.buttonWidgets["Restore"], balloon="Restore category to saved defaults") help.register(self.buttonWidgets["Reset"], balloon="Reset category to factory defaults")
def populateTextFrame(self): self.textLabel = Tkinter.Label(self.textFrame, text="Text", font="helvetica -14 bold") self.textLabel.grid(row=0, sticky='w', pady=5) self.textInput = Pmw.ScrolledText(self.textFrame, text_pyclass = HtmlText, text_relief = 'sunken', text_wrap = 'word', #text_height=10, #text_width=50 ) self.textInput.grid(row=1,sticky='nsew',padx=5) self.previewCheckB = Tkinter.Checkbutton(self.textFrame, text="Preview", command = self.previewCB) self.previewCheckB.grid(row=2, sticky='e',pady=10) help.register(self.previewCheckB, balloon="Preview text as rendered HTML") self.textFrame.rowconfigure(0,weight=1) self.textFrame.rowconfigure(1, weight=30) self.textFrame.rowconfigure(2, weight=1) self.textFrame.columnconfigure(0,weight=1)
def populateListFrame(self): self.panelsLabel = Tkinter.Label(self.pListFrame, text="Panels", font="helvetica -14 bold") self.panelsLabel.grid(row=0, column=0, columnspan=4, sticky='w') self.panelList = Pmw.ScrolledListBox( self.pListFrame, labelmargin=10, listbox_height=5, listbox_width=20, listbox_selectmode=Tkinter.SINGLE, selectioncommand=self.refreshPanelCB, listbox_exportselection=False) #dblclickcommand=self.showPanelEntry) self.panelList.grid(row=1, column=0, padx=10, columnspan=4, sticky='nsew') this_dir = os.path.split(Demo.__file__)[0] self.upButton = Tkinter.Button(self.pListFrame, command=self.panelUp) up_image = chimage.get("arrow_up.gif", self.upButton) #text="/\\") self.upButton.configure(image=up_image, state="disabled") self.upButton._image = up_image help.register(self.upButton, balloon="Move currently selected panel up") self.upButton.grid(row=2, column=0, sticky='s') self.downButton = Tkinter.Button(self.pListFrame, command=self.panelDown) down_image = chimage.get("arrow_down.gif", self.downButton) #text="/\\") self.downButton.configure(image=down_image, state="disabled") self.downButton._image = down_image help.register(self.downButton, balloon="Move currently selected panel down") self.downButton.grid(row=3, column=0, sticky='n') self.deleteButton = Tkinter.Button(self.pListFrame, text="Delete", command=self.deletePanel, state="disabled") help.register(self.deleteButton, balloon="Delete currently selected panel") self.deleteButton.grid(row=2, column=1, rowspan=2) self.newButton = Tkinter.Button(self.pListFrame, text="New", command=self.newPanelCB) help.register(self.newButton, balloon="Add a new panel") self.newButton.grid(row=2, column=2, rowspan=2) #self.editGlobalB = Tkinter.Button(self.pListFrame, text="Edit Demo Options", # command=self.editGlobalCB) #help.register(self.editGlobalB, balloon="Edit global options for Demo") #self.editGlobalB.grid(row=4,column=0,columnspan=4, sticky='w') self.pListFrame.rowconfigure(0, weight=1) self.pListFrame.rowconfigure(1, weight=20) self.pListFrame.rowconfigure(2, weight=1) self.pListFrame.rowconfigure(3, weight=1) self.pListFrame.rowconfigure(4, weight=1)
def createReportPanel(self): self.createTitle(1, "Provide Information") self.createExplanation( 1, "The information included in the Gathered Information area" " below may be insufficient to diagnose the problem." " So please provide a description of how the problem" " occurred and an email address that can used to contact" " your for more information.", height=5, width=60) ## consider using htmltext here instead of fields - no need for them, ## since they can't be changed..... self.entry_widgets = {} self.entryFrame = Tkinter.Frame(self.pInterior(1)) self.name_entry = tkoptions.StringOption(self.entryFrame, 0, 'Contact Name', None, None, balloon="Your name") self.entry_widgets['name'] = self.name_entry self.email_entry = tkoptions.StringOption( self.entryFrame, 1, 'E-mail Address', None, None, balloon= "Who to notify when the bug is fixed or to ask for additional information" ) self.entry_widgets['email'] = self.email_entry desc_label = Tkinter.Label(self.entryFrame, text="Description:", justify='right') desc_label.grid(row=2, column=0, sticky=Tkinter.E, pady=10) self.description_text = Pmw.ScrolledText(self.entryFrame, text_pyclass=HtmlText, text_relief='sunken', text_height=6, text_width=50, text_wrap='word') self.description_text.grid(row=2, column=1, sticky='news', pady=10) self.entry_widgets['description'] = self.description_text self.entryFrame.rowconfigure(2, weight=1) from chimera import help help.register(self.description_text, balloon=BugReport.ADDL_INFO) info_label = Tkinter.Label(self.entryFrame, text="Gathered \nInformation:", justify='right') info_label.grid(row=3, column=0, sticky=Tkinter.E, pady=10) self.gathered_info = Pmw.ScrolledText(self.entryFrame, text_pyclass=HtmlText, text_relief='sunken', text_height=4, text_width=50, text_wrap='word') self.gathered_info.grid(row=3, column=1, sticky='news', pady=10) self.entry_widgets['info'] = self.gathered_info help.register(self.gathered_info, balloon="Chimera-supplied information") self.file_chooser = tkoptions.InputFileOption( self.entryFrame, 4, 'File Attachment', None, None, balloon='Choose a file to upload') self.entry_widgets['filename'] = self.file_chooser self.platform_entry = tkoptions.StringOption( self.entryFrame, 5, 'Platform*', None, None, balloon="Your operating system and windowing system") self.entry_widgets['platform'] = self.platform_entry self.version_entry = tkoptions.StringOption( self.entryFrame, 6, 'Chimera Version*', None, None, balloon="Specific version of chimera") self.entry_widgets['version'] = self.version_entry self.include_model_info = Tkinter.IntVar(self.entryFrame) self.include_model_info.set(True) Tkinter.Checkbutton( self.entryFrame, variable=self.include_model_info, text="Include open model names in bug report").grid(row=7, column=0, columnspan=2) self.entryFrame.columnconfigure(1, weight=1) self.entryFrame.pack(side='top', fill='both', expand=True)
def fillInUI(self, parent): self.refMolList = MoleculeScrolledListBox( parent, autoselect="single", labelpos="nw", label_text="Reference structure:") self.refChainList = MoleculeChainScrolledListBox( parent, labelpos="nw", label_text="Reference chain:", listbox_selectmode='extended') self.matchMolList = MoleculeScrolledListBox( parent, labelpos="nw", label_text="Structure(s) to match:", listbox_selectmode='extended') self.matchChainList = ChainMenus(parent) def doSync(): if self.chainMatchVar.get() != CP_SPECIFIC_SPECIFIC: return self.matchChainList.syncUp(self.refChainList) self.refChainList.configure(selectioncommand=doSync) parent.rowconfigure(0, weight=1) parent.columnconfigure(0, weight=1) parent.columnconfigure(1, weight=1) seqFrame = Tkinter.Frame(parent) seqFrame.grid(row=1, column=0, columnspan=2, sticky="nsew") seqFrame.columnconfigure(0, weight=1) seqFrame.columnconfigure(1, weight=1) pairingGroup = Pmw.Group(seqFrame, tag_text="Chain pairing") pairingGroup.grid(row=0, column=0, columnspan=2, sticky="w", padx=2) pairingGroup.interior().columnconfigure(0, weight=1) self.chainMatchVar = Tkinter.StringVar(parent) self.chainMatchVar.set(prefs[CHAIN_PAIRING]) radiobuttonInfo = [ (CP_BEST, "Best-aligning pair of chains\n\tbetween reference and match structure" ), (CP_SPECIFIC_BEST, "Specific chain in reference structure\n\twith best-aligning chain in match structure" ), (CP_SPECIFIC_SPECIFIC, "Specific chain(s) in reference structure\n\twith specific chain(s) in match structure" ), ] for i in range(len(radiobuttonInfo)): val, text = radiobuttonInfo[i] radio = Tkinter.Radiobutton(pairingGroup.interior(), command=self._chainMatchCB, text=text, justify='left', value=val, variable=self.chainMatchVar) radio.grid(row=i, column=0, sticky='w') self._chainMatchCB() self.seqAlgorithmMenu = Pmw.OptionMenu( seqFrame, initialitem=prefs[SEQUENCE_ALGORITHM], labelpos='w', label_text="Alignment algorithm:", items=[SA_NEEDLEMAN_WUNSCH, SA_SMITH_WATERMAN]) self.seqAlgorithmMenu.grid(row=1, column=0, sticky='w') matrixNames = SmithWaterman.matrices.keys() matrixNames.sort() if prefs[MATRIX] in SmithWaterman.matrices: initialMatrix = prefs[MATRIX] else: if defaults[MATRIX] in SmithWaterman.matrices: initialMatrix = defaults[MATRIX] else: initialMatrix = matrixNames[0] prefs[MATRIX] = initialMatrix self.matrixMenu = Pmw.OptionMenu(seqFrame, initialitem=initialMatrix, labelpos='w', label_text="Matrix:", items=matrixNames) self.matrixMenu.grid(row=1, column=1, sticky='w') gapFrame = Tkinter.Frame(seqFrame) gapFrame.grid(row=2, column=0, columnspan=2, sticky='ew') gapFrame.columnconfigure(0, weight=1) gapFrame.columnconfigure(1, weight=1) self.gapOpenEntry = Pmw.EntryField(gapFrame, labelpos='w', label_text="Gap opening penalty", validate='real', entry_width=2, entry_justify='right', value="%g" % (prefs[GAP_OPEN])) self.gapOpenEntry.grid(row=0, column=0) self.gapExtendEntry = Pmw.EntryField( gapFrame, labelpos='w', label_text="Gap extension penalty", validate='real', entry_width=2, entry_justify='right', value="%g" % (prefs[GAP_EXTEND])) self.gapExtendEntry.grid(row=0, column=1) self._entries = [self.gapOpenEntry, self.gapExtendEntry] self.ssParams = SSParams(seqFrame, prefs, useSSCB=self._useSSCB) self.ssParams.grid(row=3, column=0, columnspan=2, sticky='ew') self.computeSSVar = Tkinter.IntVar(parent) self.computeSSVar.set(prefs[COMPUTE_SS]) self._computeSSButton = Tkinter.Checkbutton( seqFrame, text="Compute secondary structure assignments", variable=self.computeSSVar) self._computeSSGridArgs = {'row': 4, 'sticky': 'w', 'columnspan': 2} if self.ssParams.useSSVar.get(): self._computeSSButton.grid(**self._computeSSGridArgs) self.showSeqVar = Tkinter.IntVar(parent) self.showSeqVar.set(prefs[SHOW_SEQUENCE]) Tkinter.Checkbutton(seqFrame, text="Show pairwise alignment(s)", variable=self.showSeqVar).grid(row=5, column=0, sticky='w', columnspan=2) matchGroup = Pmw.Group(parent, tag_text="Matching") matchGroup.grid(row=2, column=0, columnspan=2, sticky="nsew", padx=2) matchGroup.interior().columnconfigure(0, weight=1) self.iterVar = Tkinter.IntVar(parent) self.iterVar.set(prefs[ITERATE]) Tkinter.Checkbutton(matchGroup.interior(), justify="left", text="Iterate by pruning long atom pairs" " until no pair exceeds:", variable=self.iterVar).grid(row=0, column=0, sticky='w') self.iterEntry = Pmw.EntryField(matchGroup.interior(), validate='real', entry_width=3, entry_justify="right", value="%.1f" % prefs[ITER_CUTOFF], labelpos='e', label_text="angstroms") self.iterEntry.grid(row=1, column=0) self._entries.append(self.iterEntry) self.structSeqVar = Tkinter.IntVar(parent) self.structSeqVar.set(False) Tkinter.Checkbutton(parent, text="After superposition, compute" " structure-based multiple sequence alignment", variable=self.structSeqVar).grid(row=3, sticky='w', columnspan=2) f = Tkinter.Frame(parent) f.grid(row=4, column=0, columnspan=2, sticky='ew') from chimera import help b = Tkinter.Button(f, text="Save settings", pady=0, command=self._saveSettings) b.grid(row=0, column=0) help.register(b, balloon="Save current settings") b = Tkinter.Button(f, text="Reset to defaults", pady=0, command=self._restoreSettings) b.grid(row=0, column=1) help.register(b, balloon="Reset dialog to factory defaults") f.columnconfigure(0, weight=1) f.columnconfigure(1, weight=1) # set up state of gap-open entry self._useSSCB()
def addWidgets(self, parent): label = Tkinter.Label(parent, text=self.name) label.grid(column=0, padx=5, pady=1, sticky='e') self.label = label help.register(self.label, balloon=self.help) return label.grid_info()['row']
def createReportPanel(self): self.createTitle(1, "Provide Information") self.createExplanation(1, "The information included in the Gathered Information area" " below may be insufficient to diagnose the problem." " So please provide a description of how the problem" " occurred and an email address that can used to contact" " your for more information.", height=5, width=60) ## consider using htmltext here instead of fields - no need for them, ## since they can't be changed..... self.entry_widgets = {} self.entryFrame = Tkinter.Frame(self.pInterior(1)) self.name_entry = tkoptions.StringOption(self.entryFrame, 0, 'Contact Name', None, None, balloon="Your name") self.entry_widgets['name'] = self.name_entry self.email_entry = tkoptions.StringOption(self.entryFrame, 1, 'E-mail Address', None, None, balloon="Who to notify when the bug is fixed or to ask for additional information") self.entry_widgets['email'] = self.email_entry desc_label = Tkinter.Label(self.entryFrame, text="Description:", justify='right') desc_label.grid(row=2, column=0, sticky=Tkinter.E, pady=10) self.description_text = Pmw.ScrolledText(self.entryFrame, text_pyclass=HtmlText, text_relief='sunken', text_height=6, text_width=50, text_wrap='word') self.description_text.grid(row=2, column=1, sticky='news', pady=10) self.entry_widgets['description'] = self.description_text self.entryFrame.rowconfigure(2, weight=1) from chimera import help help.register(self.description_text, balloon=BugReport.ADDL_INFO) info_label = Tkinter.Label(self.entryFrame, text="Gathered \nInformation:", justify='right') info_label.grid(row=3, column=0, sticky=Tkinter.E, pady=10) self.gathered_info = Pmw.ScrolledText(self.entryFrame, text_pyclass=HtmlText, text_relief='sunken', text_height=4, text_width=50, text_wrap='word') self.gathered_info.grid(row=3, column=1, sticky='news', pady=10) self.entry_widgets['info'] = self.gathered_info help.register(self.gathered_info, balloon="Chimera-supplied information") self.file_chooser = tkoptions.InputFileOption(self.entryFrame, 4, 'File Attachment', None, None, balloon='Choose a file to upload') self.entry_widgets['filename'] = self.file_chooser self.platform_entry = tkoptions.StringOption(self.entryFrame, 5, 'Platform*', None, None, balloon="Your operating system and windowing system") self.entry_widgets['platform'] = self.platform_entry self.version_entry = tkoptions.StringOption(self.entryFrame, 6, 'Chimera Version*', None, None, balloon="Specific version of chimera") self.entry_widgets['version'] = self.version_entry self.include_model_info = Tkinter.IntVar(self.entryFrame) self.include_model_info.set(True) Tkinter.Checkbutton(self.entryFrame, variable=self.include_model_info, text="Include open model names in bug report").grid( row=7, column=0, columnspan=2) self.entryFrame.columnconfigure(1, weight=1) self.entryFrame.pack(side='top', fill='both', expand=True)
def addWidgets(self, parent): label = Tkinter.Label(parent, text=self.name) label.grid(column=0, padx=5, pady=1, sticky='e') self.label = label help.register(self.label, balloon=self.help) return label.grid_info()['row']
def fillInUI(self, parent): row = 0 parent.columnconfigure(0, weight=1) parent.rowconfigure(row, weight=1) self.chainList = MoleculeChainScrolledListBox(parent, selectioncommand=self._updateIterRef, listbox_selectmode='multiple') self.chainList.grid(row=row, column=0, sticky='nsew') row += 1 mols = {} for chain in self.chainList.get(): mol = chain.molecule if mol in mols: continue mols[mol] = chain self.chainList.setvalue(mols.values()) f = Tkinter.Frame(parent) f.grid(row=row, column=0, sticky='w') row += 1 self.distCutoff = FloatOption(f, 0, "Residue-residue distance cutoff (angstroms)", prefs[DIST_CUTOFF], None, balloon="""\ residues whose principal atoms are further apart than this distance will not be aligned in the generated sequence alignment""") self.distCutoff.min = 0.0 class MatchTypeOption(SymbolicEnumOption): values = ["any", "all"] labels = ["at least one other", "all others"] f = Tkinter.Frame(parent) f.grid(row=row, column=0, sticky='w') row += 1 self.matchType = MatchTypeOption(f, 0, "Residue aligned in column if within cutoff of", prefs[ANYALL], None, balloon="""\ whether a residue needs to match the distance cutoff to all other residues in its column, or just to one residue in the column""") class GapCharOption(SymbolicEnumOption): values = [".", "-", "~"] labels = [". (period)", "- (dash)", "~ (tilde)"] f = Tkinter.Frame(parent) f.grid(row=row, column=0, sticky='w') row += 1 self.gapChar = GapCharOption(f, 0, "Gap character", prefs[GAPCHAR], None, balloon="""\ character used to depict gaps in alignment""") self.circularVar = Tkinter.IntVar(parent) self.circularVar.set(prefs[CIRCULAR]) Tkinter.Checkbutton(parent, variable=self.circularVar, text= "Allow for circular permutation").grid(row=row, column=0, sticky='w') row += 1 self.iterateVar = Tkinter.IntVar(parent) self.iterateVar.set(prefs[ITERATE]) Tkinter.Checkbutton(parent, command=self._iterParamsDisplay, text="Iterate superposition/alignment...", variable=self.iterateVar).grid( row=row, column=0, columnspan=2, sticky='w') row += 1 self.iterParams = Pmw.Group(parent, hull_padx=2, tag_text="Iteration Parameters") self.iterParams.grid(row=row, column=0, columnspan=2) row += 1 inside = self.iterParams.interior() Tkinter.Label(inside, text="Iterate alignment:").grid( row=0, column=0, rowspan=2, sticky='e') self.iterConvergeVar = Tkinter.IntVar(parent) self.iterConvergeVar.set(prefs[ITER_CONVERGE]) f = Tkinter.Frame(inside) f.grid(row=0, column=1, sticky='w') Tkinter.Radiobutton(f, value=False, text="at most", variable=self.iterConvergeVar).grid(row=0, column=0) self.iterLimit = Pmw.EntryField(f, labelpos='e', label_text="times", validate={'min': 1, 'validator': 'numeric'}, value=str(prefs[ITER_AMOUNT]), entry_width=2, entry_justify="center") self.iterLimit.grid(row=0, column=1) Tkinter.Radiobutton(inside, text="until convergence", value=True, variable=self.iterConvergeVar).grid( row=1, column=1, sticky='w') inside.rowconfigure(2, minsize="0.1i") Tkinter.Label(inside, text="Superimpose full columns:" ).grid(row=3, rowspan=2, column=0, sticky='e') self.iterAllColsVar = Tkinter.IntVar(parent) self.iterAllColsVar.set(prefs[ITER_ALL_COLS]) Tkinter.Radiobutton(inside, text="across entire alignment", value=True, variable=self.iterAllColsVar).grid( row=3, column=1, sticky='w') f = Tkinter.Frame(inside) f.grid(row=4, column=1, sticky='w') Tkinter.Radiobutton(f, text="in stretches of at least", variable=self.iterAllColsVar, value=False).grid(row=0, column=0) self.stretchLen = Pmw.EntryField(f, labelpos='e', label_text="consecutive columns", validate={'min': 2, 'validator': 'numeric'}, value=str(prefs[ITER_CONSECUTIVE_COLS]), entry_width=1, entry_justify="center") self.stretchLen.grid(row=0, column=1) self.referenceMenu = Pmw.OptionMenu(inside, labelpos='w', items=Pmw.ScrolledListBox.get(self.chainList), label_text="Reference chain for matching:") self.referenceMenu.grid(row=5, column=0, columnspan=2) self._iterParamsDisplay() f = Tkinter.Frame(parent) f.grid(row=row, column=0, columnspan=2, sticky='ew') row += 1 from chimera import help b = Tkinter.Button(f, text="Save settings", pady=0, command=self._saveSettings) b.grid(row=0, column=0) help.register(b, balloon="Save current settings") b = Tkinter.Button(f, text="Reset to defaults", pady=0, command=self._restoreSettings) b.grid(row=0, column=1) help.register(b, balloon="Reset dialog to factory defaults") f.columnconfigure(0, weight=1) f.columnconfigure(1, weight=1)
def __init__(self): from chimera import tkgui self.frame = Tkinter.Frame(tkgui.app) self.frame.columnconfigure(1, weight=1) help.register(self.frame, "UsersGuide/chimerawindow.html#emulator") sep = Tkinter.Frame(self.frame, relief='sunken', bd=2) sep.grid(row=0, column=0, columnspan=3, sticky='ew') self.histDialog = HistoryDialog(self) listbox = self.histDialog.listbox.component('listbox') import tkFont font = tkFont.Font(font=listbox.cget('font')) pixels = font.metrics('linespace') self.cmd = Pmw.ComboBox( self.frame, fliparrow=True, history=False, labelpos='w', label_text="Command:", listheight=10 * (pixels + 4), entry_exportselection=False, selectioncommand=self._selCmdCB, scrolledlist_items=[self.recordLabel, self.hideLabel]) self.cmd.grid(row=1, column=0, columnspan=3, sticky='ew') self.histDialog.populate() chimera.tkgui.addKeyboardFunc(self.graphicsKeyboardCB) entry = self.cmd.component('entry') entry.bind('<Up>', self.histDialog.up) entry.bind('<Control-p>', self.histDialog.up) entry.bind('<Down>', self.histDialog.down) entry.bind('<Control-n>', self.histDialog.down) entry.bind('<Map>', self.monitorSel) entry.bind('<Unmap>', self.unmonitorSel) entry.bind('<Control-u>', self.cmdClear) entry.bind('<Return>', self.processCommand) self.vars = [] self.buttons = [] buttonFrame = Tkinter.Frame(self.frame) buttonFrame.grid(row=2, column=0, columnspan=3, sticky='ew') Tkinter.Label(buttonFrame, text="Active models: ").pack(side='left') for id in range(10): state = 'disabled' active = 0 models = chimera.openModels.list(id) models = filter( lambda m: not isinstance(m, chimera.PseudoBondGroup), models) if models: state = 'normal' if models[0].openState.active: active = 1 var = Tkinter.IntVar(self.frame) self.vars.append(var) var.set(active) selButton = Tkinter.Checkbutton( buttonFrame, variable=var, state=state, text="%d" % id, command=lambda x=id, s=self: s.selButtonPush(x)) selButton.pack(side='left') self.buttons.append(selButton) self.allVar = Tkinter.IntVar(self.frame) self.allVar.set(0) self.allButton = Tkinter.Checkbutton(buttonFrame, text="All", variable=self.allVar, command=self.allButtonPush) self.allButton.pack(side='left') chimera.triggers.addHandler('OpenState', self.activeHandler, None) chimera.triggers.addHandler('OpenModels', self.activeHandler, None) self.show() # read startup files global ui ui = self for sf in preferences.get(MIDAS_CATEGORY, STARTUP_FILES): from OpenSave import tildeExpand sf = tildeExpand(sf) if os.path.exists(sf): midas_text.message("Processing Midas start-up file %s" % sf) midas_text.processCommandFile(sf)
def fillInUI(self, parent): self.computePageSize = 1 self.buttonInfo = {} self.columnInfo = {} self.noteBook = Pmw.NoteBook(parent) buts = self.noteBook.add("Buttons") help.register(self.noteBook.tab("Buttons"), balloon='configure action buttons') cols = self.noteBook.add("Columns") help.register(self.noteBook.tab("Columns"), balloon='configure model table columns') dbl = self.noteBook.add("Double Click") help.register(self.noteBook.tab("Double Click"), balloon='select actions for double click in model table') self.noteBook.pack(expand='yes', fill='both') # fill in 'Buttons' page Tkinter.Label(buts, text='Checked buttons will be in' ' frequent-actions list\n' 'Others will be in infrequent-actions list').grid( row=0, column=0, columnspan=3) # fill in 'Columns' page Tkinter.Label(cols, text='Checked columns will be shown' ' in model table').grid(row=0, column=0, columnspan=4) self.showColorVar = Tkinter.IntVar(cols) self.showColorVar.set(self.prefs['showColor']) self.colDivider = Tkinter.Frame(cols, background='black') self.showColorButton = Tkinter.Checkbutton( cols, text="Show model color behind model name", command=self.modelPanel._buildTable, variable=self.showColorVar) # fill in 'Double Click' page dbl.rowconfigure(0, weight=1) dbl.columnconfigure(0, weight=1) dbl.columnconfigure(1, weight=1) self.dblCommandsList = Pmw.ScrolledListBox( dbl, hscrollmode='none', labelpos='nw', label_text="Execution list", items=self.prefs['executionList'], selectioncommand=self._removeDblCmdCB) self.dblCommandsList.grid(row=0, column=0, sticky='nsew') help.register(self.dblCommandsList, balloon='list of functions to execute when model\n' 'is double-clicked in model panel;\n' 'click on function to remove from list') self.dblCommandMenu = Pmw.ScrolledListBox( dbl, hscrollmode='none', labelpos='nw', label_text='Function menu', selectioncommand=self._addDblCmdCB) self.dblCommandMenu.grid(row=0, column=1, sticky='nsew') help.register(self.dblCommandMenu, balloon='click on function to add to execution list')
def fillInUI(self, parent): #recCtrlFrame = Tkinter.Frame(parent) #recCtrlFrame.grid(row=0,column=0,columnspan=2, sticky='w', pady=10, padx=10) ##--------Record button-----------## self.recButton = Tkinter.Button(parent, text="Record", command=self.startRecording) #self.rec_img = chimage.get(os.path.join(self.this_dir, "record.png"), self.recButton) #self.pause_img = chimage.get(os.path.join(self.this_dir, "pause.png"), self.recButton) #self.recButton.configure(image=self.rec_img, relief='flat') #self.recButton._rec_image = self.rec_img #self.recButton._pause_image = self.pause_img help.register(self.recButton, balloon="Start capturing frames from the graphics window") self.recButton.grid(row=0,column=0, sticky='w', pady=5, padx=10) ## --------------------------------- ##--------Encode button-----------## self.encButton = Tkinter.Button(parent, text="Make movie", command = self.startEncoding) #self.movie_img = chimage.get(os.path.join(self.this_dir, "movie.png"), self.encButton) #self.abort_img = chimage.get(os.path.join(self.this_dir, "abort_movie.png"), self.encButton) #self.encButton.configure(image=self.movie_img, relief='flat') #self.encButton._movie_img = self.movie_img #self.encButton._abort_img = self.abort_img help.register(self.encButton, balloon="Make a movie from currently captured frames") self.encButton.grid(row=0,column=1, sticky='w') ## can't encode yet - don't have any frames cached ! self.encButton.configure(state='disabled') ## ------------------------------------ ##--------Reset button-----------## self.clearButton = Tkinter.Button(parent, text="Reset", command=self.resetRecording) help.register(self.clearButton, balloon="Clear all saved frames") self.clearButton.configure(state='disabled') self.clearButton.grid(row=1, column=0, sticky='w', pady=5, padx=10) ## --------------------------------- ## ------Reset after encode------------- self.autoResetVar = Tkinter.IntVar(parent) self.autoResetVar.set(1) autoResetChB = Tkinter.Checkbutton(parent, text="Reset after encode", variable = self.autoResetVar, command = self.resetModeCB ) autoResetChB.grid(row=1,column=1, sticky='w') ## ------------------------------------- #-------Movie format--------------------------- self.movieFmtOption = MovieFmtTkOption(parent, 2, 'Output format', default_format, self.chooseFmtCB) ## ------------------------------------------------ ## -------------Output path ------------------ outputFrame = Tkinter.Frame(parent) from OpenSave import tildeExpand initialfile = os.path.join(tildeExpand("~"), DEFAULT_OUTFILE) from OpenSave import SaveModeless class OutputPathDialog(SaveModeless): default = 'Set Movie Path' title = 'Select movie output file' def SetMoviePath(self): self.Save() setattr(OutputPathDialog, OutputPathDialog.default, OutputPathDialog.SetMoviePath) # Work around OpenSave bug ofo = tkoptions.OutputFileOption(outputFrame, 0, 'Output file', initialfile, None, balloon = 'Output file save location ' ) ofo.dialogType = OutputPathDialog self.outFileOption = ofo outputFrame.grid(row=3, column=0, columnspan=3, sticky='ew', pady=10) outputFrame.columnconfigure(1, weight=1) ## ------------------------------------------- statsGroup = Pmw.Group(parent, tag_text="Status") statsGroup.grid(row=0, column=2, rowspan=3, padx=20, sticky='nsew') #statsGroup.configure(hull_width=1000) self.frame_num_var = Tkinter.StringVar(parent) self.time_left_var = Tkinter.StringVar(parent) self.actionLabel = Tkinter.Label(statsGroup.interior(), text="Stopped") numFramesLabel = Tkinter.Label(statsGroup.interior(), text = "# Frames:")#, frameResLabel = Tkinter.Label(statsGroup.interior(), text = "Resolution:")#, estLengthLabel = Tkinter.Label(statsGroup.interior(), text = "Est. Length:")#, #statsGroup.interior().rowconfigure(0,weight=1) statsGroup.interior().columnconfigure(2,weight=1) self.accum_frames_var = Tkinter.StringVar(parent) self.accum_frames_var.set('0') self.frame_res_var = Tkinter.StringVar(parent) self.frame_res_var.set('%dx%d' % chimera.viewer.windowSize) self.accum_secs_var = Tkinter.StringVar(parent) self.accum_secs_var.set('0s.') numFramesVal = Tkinter.Label(statsGroup.interior(), textvariable = self.accum_frames_var) frameResVal = Tkinter.Label(statsGroup.interior(), textvariable = self.frame_res_var) estLengthVal = Tkinter.Label(statsGroup.interior(), textvariable = self.accum_secs_var) self.actionLabel.grid(row=0,column=0, columnspan=2, pady=2, sticky='w') numFramesLabel.grid(row=1,column=0, pady=2, sticky='w') frameResLabel.grid(row=2, column=0, pady=2, sticky='w') estLengthLabel.grid(row=3, column=0, pady=2, sticky='w') numFramesVal.grid(row=1, column=1, padx=5, sticky='w') frameResVal.grid(row=2, column=1, padx=5, sticky='w') estLengthVal.grid(row=3, column=1, padx=5, sticky='w') parent.columnconfigure(2, weight=1) parent.columnconfigure(3, weight=2) parent.rowconfigure(9, weight=1) dummyFrame = Tkinter.Frame(parent, relief='groove', borderwidth=1) Tkinter.Frame(dummyFrame).pack() dummyFrame.grid(row=4,column=0,columnspan=3, pady=10, sticky='ew') ## -------------- Frame options ----------------------- frmOptChBFrame = Tkinter.Frame(parent, background="gray") frmOptChBFrame.grid(row=5, column=0,columnspan=3, pady=5, sticky='ew') frmOptChBFrame.columnconfigure(1, weight=1) self.frmOptionsVar = Tkinter.IntVar(frmOptChBFrame) frmOptionsChB = Tkinter.Checkbutton(frmOptChBFrame, indicatoron=False, selectcolor='', background="gray", offrelief='flat', overrelief='flat', text = "Options...", relief='flat', variable=self.frmOptionsVar, command = self.showFrmOptionsCB) r_arrow_img=chimage.get("rightarrow.png", frmOptionsChB) frmOptionsChB.configure(image=r_arrow_img) frmOptionsChB._image = r_arrow_img d_arrow_img=chimage.get("downarrow.png", frmOptionsChB) frmOptionsChB.configure(selectimage=d_arrow_img) frmOptionsChB._selectimage = d_arrow_img #frmOptionsChB.configure(relief='sunken') #print frmOptionsChB.configure().keys() frmOptionsChB.grid(row=0, column=0, sticky='w') frmOptionsLabel = Tkinter.Label(frmOptChBFrame, text="Frame Options", background="gray") frmOptionsLabel.grid(row=0,column=1, sticky='w', padx=5) self.frmOptionsFrame = Tkinter.Frame(parent) self.populateFrmOptionsFrame() ## --------------------------------------------------- ## --------------------- Movie options ----------------- movOptChBFrame = Tkinter.Frame(parent, background="gray") movOptChBFrame.grid(row=7, column=0,columnspan=3, pady=5, sticky='ew') movOptChBFrame.columnconfigure(1, weight=1) self.movOptionsVar = Tkinter.IntVar(movOptChBFrame) movOptionsChB = Tkinter.Checkbutton(movOptChBFrame, indicatoron=False, selectcolor='', background="gray", offrelief='flat', overrelief='flat', text = "Options...", relief='flat', variable=self.movOptionsVar, command = self.showMovOptionsCB) movOptionsChB.configure(image=r_arrow_img) movOptionsChB._image = r_arrow_img movOptionsChB.configure(selectimage=d_arrow_img) movOptionsChB._selectimage = d_arrow_img movOptionsChB.grid(row=0, column=0, sticky='w', pady=0) movOptionsLabel = Tkinter.Label(movOptChBFrame, text="Movie Options", background="gray") movOptionsLabel.grid(row=0,column=1, sticky='w', padx=5) self.movOptionsFrame = Tkinter.Frame(parent) self.populateMovOptionsFrame() self.movOptionsFrame.columnconfigure(0, weight=1)