def fillInUI(self, parent): self.toplevel_widget = parent.winfo_toplevel() self.toplevel_widget.withdraw() row = 0 import Tkinter from CGLtk import Hybrid from chimera import widgets from SurfaceZone import zonable_surface_models sm = widgets.ModelOptionMenu(parent, labelpos='w', label_text='Surface ', listFunc=zonable_surface_models, command=self.surface_menu_cb) sm.grid(row=row, column=0, sticky='w') self.surface_menu = sm row = row + 1 rs = Hybrid.Scale(parent, 'Radius ', 0, 30, .1, 2) rs.frame.grid(row=row, column=0, sticky='ew') row = row + 1 rs.callback(self.radius_changed_cb) rs.entry.bind('<KeyPress-Return>', self.radius_changed_cb) self.radius = rs # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width=40, anchor='w', justify='left') msg.grid(row=row, column=0, sticky='ew') row = row + 1 self.message_label = msg self.surface_menu_cb() # Set slider for current surface
def fillInUI(self, parent): self.morph_maps = {} # Writable maps for pairs of end-point maps. self.default_f_range = (0.0, 1.0, 0.1) self.play_stop_button = self.buttonWidgets['Play'] import Tkinter from CGLtk import Hybrid frame = parent frame.columnconfigure(0, weight=1) row = 0 h = Tkinter.Label(parent, text='Interpolate between two maps') h.grid(row=row, column=0, sticky='w') row += 1 from VolumeViewer import volume_list, Volume_Menu vlist = volume_list() vm1 = Volume_Menu(parent, 'First map', open_button=True, show_on_open=True) vm1.frame.grid(row=row, column=0, sticky='w') if len(vlist) >= 1: vm1.set_volume(vlist[0]) row += 1 self.map_menu_1 = vm1 vm2 = Volume_Menu(parent, 'Second map', open_button=True, show_on_open=True) vm2.frame.grid(row=row, column=0, sticky='w') if len(vlist) >= 2: vm2.set_volume(vlist[1]) row += 1 self.map_menu_2 = vm2 self.scale = Hybrid.Scale(parent, 'Fraction ', 0.0, 1.0, 0.01, 0) self.scale.frame.grid(row=row, column=0, sticky='ew') self.scale.callback(self.scale_changed_cb) self.scale.entry.bind('<KeyPress-Return>', self.scale_changed_cb) row += 1 op = Hybrid.Popup_Panel(parent) opf = op.frame opf.grid(row=row, column=0, sticky='news') opf.grid_remove() opf.columnconfigure(0, weight=1) self.options_panel = op.panel_shown_variable row += 1 orow = 0 cb = op.make_close_button(opf) cb.grid(row=orow, column=1, sticky='e') fr = Tkinter.Frame(opf) fr.grid(row=orow, column=0, sticky='w') orow += 1 fmin, fmax, fstep = self.default_f_range fn = Hybrid.Entry(fr, 'Movie start ', 5, fmin) fn.frame.grid(row=0, column=0, sticky='w') fx = Hybrid.Entry(fr, ' end ', 5, fmax) fx.frame.grid(row=0, column=1, sticky='w') fs = Hybrid.Entry(fr, ' step ', 5, fstep) fs.frame.grid(row=0, column=2, sticky='w') self.f_range_variables = (fn.variable, fx.variable, fs.variable) um = Hybrid.Checkbutton(opf, 'Undisplay original maps', True) um.button.grid(row=orow, column=0, sticky='w') orow += 1 self.undisplay_maps = um.variable mu = Hybrid.Checkbutton_Entries(opf, False, 'Multiplier for second map', (4, '1.0')) mu.frame.grid(row=orow, column=0, sticky='w') orow += 1 self.use_multiplier, self.map_2_multiplier = mu.variables ta = Hybrid.Checkbutton(opf, 'Adjust threshold for constant volume', False) ta.button.grid(row=orow, column=0, sticky='w') orow += 1 self.adjust_thresholds = ta.variable am = Hybrid.Checkbutton(opf, 'Add to first map instead of interpolating', False) am.button.grid(row=orow, column=0, sticky='w') orow += 1 self.add_maps = am.variable am.callback(self.add_mode_cb) rt = Hybrid.Checkbutton(opf, 'Round trip when recording movie', True) rt.button.grid(row=orow, column=0, sticky='w') orow += 1 self.roundtrip = rt.variable # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width=40, anchor='w', justify='left') msg.grid(row=row, column=0, sticky='ew') row = row + 1 self.message_label = msg
def fillInUI(self, parent): self.default_radius = 1 self.default_color = (1,0.6,0.8,.5) # Pink eraser t = parent.winfo_toplevel() self.toplevel_widget = t t.withdraw() parent.columnconfigure(0, weight = 1) row = 0 import Tkinter from CGLtk import Hybrid sh = Hybrid.Checkbutton(parent, 'Show volume-erasing sphere ', True) sh.button.grid(row = row, column = 0, sticky = 'w') row = row + 1 self.show_sphere_var = sh.variable sh.callback(self.show_sphere_cb) crf = Tkinter.Frame(parent) crf.grid(row = row, column = 0, sticky = 'ew') crf.columnconfigure(2, weight = 1) row = row + 1 cl = Tkinter.Label(crf, text = 'Color') cl.grid(row = 0, column = 0, sticky = 'w') from CGLtk.color import ColorWell sc = ColorWell.ColorWell(crf, color = self.default_color, callback = self.change_sphere_color_cb) sc.grid(row = 0, column = 1, sticky = 'w') self.sphere_color = sc rs = Hybrid.Scale(crf, ' Radius ', 0, 30, .1, 2) rs.frame.grid(row = 0, column = 2, sticky = 'ew') row = row + 1 rs.callback(self.change_radius_cb) rs.entry.bind('<KeyPress-Return>', self.change_radius_cb) self.sphere_radius_scale = rs mmf = Tkinter.Frame(parent) mmf.grid(row = row, column = 0, sticky = 'w') row = row + 1 mb = Hybrid.Option_Menu(mmf, 'Use mouse ', 'button 1', 'button 2', 'button 3', 'ctrl button 1', 'ctrl button 2', 'ctrl button 3') mb.variable.set('button 2') mb.frame.grid(row = 0, column = 0, sticky = 'w') mb.add_callback(self.bind_mouse_button_cb) self.mouse_button = mb mbl = Tkinter.Label(mmf, text = ' to move sphere') mbl.grid(row = 0, column = 1, sticky = 'w') ka = Tkinter.Label(parent, text = 'Erase using keyboard accelerator "es".') ka.grid(row = row, column = 0, sticky = 'w') row = row + 1 from Accelerators import add_accelerator add_accelerator('es', 'Erase volume data inside sphere', self.Erase) add_accelerator('eo', 'Erase volume data outside sphere', self.erase_outside_sphere)
def fillInUI(self, parent): self.default_radius = 100 self.surface_model = None self.surface_piece = None self.toplevel_widget = parent.winfo_toplevel() self.toplevel_widget.withdraw() parent.columnconfigure(0, weight=1) row = 0 import Tkinter from CGLtk import Hybrid # Radius rs = Hybrid.Scale(parent, 'Radius ', 1, 1000, 0.01, self.default_radius) rs.frame.grid(row=row, column=0, sticky='ew') row = row + 1 rs.callback(self.radius_changed_cb) rs.entry.bind('<KeyPress-Return>', self.radius_changed_cb) self.radius = rs # Interpolation factor between icosahedron and sphere sf = Hybrid.Scale(parent, 'Sphere factor ', 0, 1, .01, 0) sf.frame.grid(row=row, column=0, sticky='ew') row = row + 1 sf.callback(self.sphere_factor_changed_cb) sf.entry.bind('<KeyPress-Return>', self.sphere_factor_changed_cb) self.sphere_factor = sf # Orientation menu self.orient_222 = 'xyz 2-fold axes' self.orient_222r = 'xyz 2-fold axes, alt' self.orient_2n3 = 'x 2-fold, z 3-fold' self.orient_2n3r = 'x 2-fold, z 3-fold, alt' self.orient_2n5 = 'x 2-fold, z 5-fold' self.orient_2n5r = 'x 2-fold, z 5-fold, alt' self.orient_n25 = 'y 2-fold, z 5-fold' self.orient_n25r = 'y 2-fold, z 5-fold, alt' io = Hybrid.Option_Menu(parent, 'Orientation ', self.orient_222, self.orient_222r, self.orient_2n3, self.orient_2n3r, self.orient_2n5, self.orient_2n5r, self.orient_n25, self.orient_n25r) io.frame.grid(row=row, column=0, sticky='w') io.add_callback(self.show_cb) row = row + 1 self.orientation = io.variable # Subdivision factor sf = Tkinter.Frame(parent) sf.grid(row=row, column=0, sticky='w') row = row + 1 sb = Hybrid.Entry(sf, 'Subdivision factor ', 5, '1') sb.frame.grid(row=0, column=0, sticky='w') self.subdivision_factor = sb.variable sb.entry.bind('<KeyPress-Return>', self.show_cb) sp = Tkinter.Label(sf, text='') sp.grid(row=0, column=1, sticky='w') self.subdivision_spacing = sp # Surface style: filled, mesh st = Hybrid.Radiobutton_Row(parent, 'Surface style: ', ('solid', 'mesh'), self.style_changed_cb) st.frame.grid(row=row, column=0, sticky='w') st.variable.set('mesh', invoke_callbacks=False) row = row + 1 self.surface_style = st.variable # Color cf = Tkinter.Frame(parent) cf.grid(row=row, column=0, sticky='w') row = row + 1 cl = Tkinter.Label(cf, text='Color') cl.grid(row=0, column=0, sticky='w') initial_color = (.7, .7, .7, 1) from CGLtk.color import ColorWell cw = ColorWell.ColorWell(cf, callback=self.color_changed_cb) cw.showColor(initial_color) cw.grid(row=0, column=1, sticky='w') self.color = cw # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width=40, anchor='w', justify='left') msg.grid(row=row, column=0, sticky='ew') row = row + 1 self.message_label = msg import SimpleSession chimera.triggers.addHandler(SimpleSession.SAVE_SESSION, self.save_session_cb, None)
def fillInUI(self, parent): self.filter_widgets = fw = [] self.toplevel_widget = parent.winfo_toplevel() self.toplevel_widget.withdraw() parent.columnconfigure(0, weight=1) # Allow scalebar to expand. row = 0 import Tkinter from CGLtk import Hybrid self.gaussian = 'Gaussian' self.median = 'Median 3x3x3' self.bin = 'Bin' self.laplacian = 'Laplacian' self.fourier = 'Fourier Transform' self.scale = 'Scale' ft = Hybrid.Option_Menu(parent, 'Filter type:', self.gaussian, self.median, self.bin, self.laplacian, self.fourier, self.scale) ft.button.configure(indicatoron = False) ft.frame.grid(row = row, column = 0, sticky = 'w') row += 1 self.filter_type = ft.variable ft.add_callback(self.filter_type_changed_cb) ws = Hybrid.Scale(parent, 'Width ', 1.0, 10.0, 0.0, 1.0) ws.frame.grid(row = row, column = 0, sticky = 'ew') row += 1 ws.callback(self.filter_parameter_changed_cb) ws.entry.bind('<KeyPress-Return>', self.filter_cb) self.sdev = ws Hybrid.Balloon_Help(ws.label, 'Width is one standard deviation.', delay = 0.5) fw.append((self.gaussian, ws.frame)) mi = Hybrid.Scale(parent, 'Iterations ', 0, 5, 1, 1, 2) mi.frame.grid(row = row, column = 0, sticky = 'ew') row += 1 mi.callback(self.filter_parameter_changed_cb) mi.entry.bind('<KeyPress-Return>', self.filter_cb) self.median_iterations = mi fw.append((self.median, mi.frame)) bs = Hybrid.Entry(parent, 'Bin size', 5, '2') bs.frame.grid(row = row, column = 0, sticky = 'w') row += 1 self.binsize = bs.variable bs.entry.bind('<KeyPress-Return>', self.filter_cb) fw.append((self.bin, bs.frame)) sf = Tkinter.Frame(parent) sf.grid(row = row, column = 0, sticky = 'w') row += 1 fw.append((self.scale, sf)) sh = Hybrid.Entry(sf, 'Shift', 5, '0') sh.frame.grid(row = 0, column = 0, sticky = 'w') self.shift = sh.variable sh.entry.bind('<KeyPress-Return>', self.filter_cb) sc = Hybrid.Entry(sf, 'Scale', 5, '1') sc.frame.grid(row = 0, column = 1, sticky = 'w') self.scale_factor = sc.variable sc.entry.bind('<KeyPress-Return>', self.filter_cb) vt = Hybrid.Option_Menu(sf, 'Value type', 'same', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'float32', 'float64') vt.frame.grid(row = 0, column = 2, sticky = 'w') self.value_type = vt.variable op = Hybrid.Popup_Panel(parent) opf = op.frame opf.grid(row = row, column = 0, sticky = 'news') opf.grid_remove() opf.columnconfigure(0, weight=1) self.options_panel = op.panel_shown_variable row += 1 orow = 0 cb = op.make_close_button(opf) cb.grid(row = orow, column = 1, sticky = 'e') sr = Hybrid.Checkbutton(opf, 'Displayed subregion only', True) sr.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.use_subregion = sr.variable ss = Hybrid.Checkbutton(opf, 'Displayed subsampling only', False) ss.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.use_step = ss.variable ta = Hybrid.Checkbutton(opf, 'Adjust threshold for constant volume', True) ta.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.adjust_thresholds = ta.variable iu = Hybrid.Checkbutton(opf, 'Immediate update', False) iu.button.grid(row = orow, column = 0, sticky = 'w') orow += 1 self.immediate_update = iu.variable self.filter_type_changed_cb() self.set_scale_range(initial = True)
def fillInUI(self, parent): t = parent.winfo_toplevel() self.toplevel_widget = t t.withdraw() parent.columnconfigure(0, weight=1) row = 0 import Tkinter from CGLtk import Hybrid rs = Hybrid.Scale(parent, ' Radius ', 0, 1000, .1, '') rs.frame.grid(row=row, column=0, sticky='ew') row = row + 1 # rs.callback(self.flatten_cb) rs.entry.bind('<KeyPress-Return>', self.flatten_cb) self.radius = rs.variable # Mesh mf = Tkinter.Frame(parent) mf.grid(row=row, column=0, sticky='w') row = row + 1 sm = Hybrid.Checkbutton(mf, 'Show triangle mesh,', True) sm.button.grid(row=0, column=0, sticky='w') self.show_mesh = sm.variable self.show_mesh.add_callback(self.show_mesh_cb) cl = Tkinter.Label(mf, text='color') cl.grid(row=0, column=1, sticky='w') initial_color = (.5, .5, .5, 1) from CGLtk.color import ColorWell mc = ColorWell.ColorWell(mf, callback=self.mesh_color_changed_cb) mc.grid(row=0, column=2, sticky='w') self.mesh_color = mc mc.showColor(initial_color) mo = Hybrid.Entry(mf, ' z offset ', 5, '0') mo.frame.grid(row=0, column=3, sticky='w') self.mesh_offset = mo.variable mo.entry.bind('<KeyPress-Return>', self.mesh_offset_changed_cb) # Orthographic camera mode. import chimera c = chimera.viewer.camera oc = Hybrid.Checkbutton(parent, 'Use orthographic camera mode.', c.ortho) oc.button.grid(row=row, column=0, sticky='w') row = row + 1 self.orthographic = oc.variable self.orthographic.add_callback(self.orthographic_cb) # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width=40, anchor='w', justify='left') msg.grid(row=row, column=0, sticky='ew') row = row + 1 self.message_label = msg
def create(self, dialog, master): from chimera import tkoptions from chimera.preferences import saveui import Tkinter, Pmw self.dialog = dialog self.master = master self.saveui = saveui.SaveUI(master, self) self.interfaceVar = Tkinter.StringVar(master) self.interfaceVar.set(self.Interface_LightsBasic) w = Pmw.Group(master, tag_pyclass=Tkinter.Menubutton, tag_indicatoron=True, tag_relief=Tkinter.RAISED, tag_borderwidth=2, tag_textvariable=self.interfaceVar) w.pack(side=Tkinter.LEFT) mb = w.component("tag") self.interfaceMenu = Tkinter.Menu(mb, tearoff=Tkinter.NO) mb.config(menu=self.interfaceMenu) self.interfaceMenu.add_radiobutton(label=self.Interface_LightsBasic, variable=self.interfaceVar, value=self.Interface_LightsBasic, command=self._chooseInterface) self.interfaceMenu.add_radiobutton(label=self.Interface_LightsAdvanced, variable=self.interfaceVar, value=self.Interface_LightsAdvanced, command=self._chooseInterface) self.interfaceMenu.add_radiobutton(label=self.Interface_Shininess, variable=self.interfaceVar, value=self.Interface_Shininess, command=self._chooseInterface) self.simpleFrame = Tkinter.Frame(w.interior()) self.simpleFrame.pack(side=Tkinter.LEFT) self.simpleFrame.pack_forget() f = self.simpleFrame t = Tkinter.Label(f, text="key light:") t.grid(row=0, column=0, sticky=Tkinter.E, padx=3) t = Tkinter.Frame(f, background="red") t.grid(row=0, column=1, sticky=Tkinter.NSEW, padx=1, pady=1) t = Tkinter.Label(f, text="fill light:") t.grid(row=1, column=0, sticky=Tkinter.E, padx=3) t = Tkinter.Frame(f, background="#009F00") t.grid(row=1, column=1, sticky=Tkinter.NSEW, padx=1, pady=1) brightness, contrast = self._calculateBrightnessContrast() from CGLtk import Hybrid lbl = Tkinter.Label(f, text="brightness:") lbl.grid(row=2, column=0, sticky=Tkinter.W) self.brightness = Hybrid.Scale(f, "", 0.1, 5, 0.05, brightness) self.brightness.callback(self._setBrightnessContrast) self.brightness.frame.grid(row=3, column=0, columnspan=2) lbl = Tkinter.Label(f, text="key-to-fill ratio:") lbl.grid(row=4, column=0, sticky=Tkinter.W) self.contrast = Hybrid.Scale(f, "", 1, 20, 0.1, contrast) self.contrast.callback(self._setBrightnessContrast) self.contrast.frame.grid(row=5, column=0, columnspan=2) import chimera.help chimera.help.register(self.contrast.frame, balloon="TV news: 1.5, Sitcom: 2,\n" "Drama: 4, Action Sequence: 8,\n" "Horror movie: 10, Film Noir: 16") qf = Tkinter.Frame(f) qf.grid(row=6, column=0, columnspan=2, sticky='ew') s = self.lensViewer.haveShader() q = {False: 'normal', True: 'glossy'}[s] self.quality = self._QualityOption(qf, 0, 'quality', q, self._qualityCB) if not self.lensViewer.haveShaderSupport(): self.quality.disable() self.advancedFrame = Tkinter.Frame(w.interior()) self.advancedFrame.pack(side=Tkinter.LEFT) self.advancedFrame.pack_forget() self.whichLight = Pmw.RadioSelect(self.advancedFrame, buttontype="radiobutton", command=self._setLight) self.whichLight.pack(side=Tkinter.TOP) self.whichLight.add("key light", fg="red") self.whichLight.add("fill light", fg="#009F00") f = Tkinter.Frame(self.advancedFrame) f.pack(side=Tkinter.LEFT) self.active = tkoptions.BooleanOption(f, 0, "active", 1, self._setActive) self.diffuse = tkoptions.ColorOption(f, 1, "diffuse color", None, self._setDiffuse, noneOkay=False) self.diffuseScale = tkoptions.FloatOption(f, 2, "diffuse scale", 1, self._setDiffuseScale, min=-5, max=5) self.specular = tkoptions.ColorOption(f, 3, "specular color", None, self._setSpecular, noneOkay=False) self.specularScale = tkoptions.FloatOption(f, 4, "specular scale", 1, self._setSpecularScale, min=-5, max=5) self.direction = tkoptions.Float3TupleOption(f, 5, "direction", (0, 0, 0), self._setDirection) self.shininessFrame = Tkinter.Frame(w.interior()) self.shininessFrame.pack(side=Tkinter.LEFT) self.shininessFrame.pack_forget() f = Tkinter.Frame(self.shininessFrame) f.pack(side=Tkinter.LEFT) mat = chimera.Material.lookup("default") rgb, b = normalizedColor(mat.specular, self.restoreShinyBrightness) self.shininess = tkoptions.SliderOption(f, 0, "shininess", mat.shininess, self._setShininess, min=1, max=128, step=1) self.shinySpecular = tkoptions.ColorOption(f, 1, "specular color", rgb, self._setShininess, noneOkay=False) self.shinyBrightness = tkoptions.SliderOption(f, 2, "brightness", b, self._setShininess, min=0.1, max=10.0, step=0.1) self.updatedShininess = False f = self._makeGraphics(master) f.pack(expand=Tkinter.TRUE, fill=Tkinter.BOTH, ipadx=5, ipady=5) self.whichLight.invoke("key light") self._chooseInterface()