def _create_editor(self, mode): editor = e = create_editor(mode, self) self._last_idx += 1 e.grid(row=self._last_idx, column=0, sticky='we') self._editors[mode] = editor self._indexes[mode] = self._last_idx editor.bind('<<PropertyChanged>>', self._on_variable_changed) return editor
def _create_editor(self, master, pname, wdata): editor = None wtype = wdata.get('editor', None) #I don't have class name at this moment #so setup class specific values on update_property_widget editor = create_editor(wtype, master) def make_on_change_cb(pname, editor): def on_change_cb(event): self._on_property_changed(pname, editor) return on_change_cb editor.bind('<<PropertyChanged>>', make_on_change_cb(pname, editor)) return editor
def _create_properties(self): """Populate a frame with a list of all editable properties""" # Layout selector self._fselector = fm = ttk.Frame(self._sframe.innerframe) label = ttk.Label(fm, text='Manager:') label.pack(side='left') self.layout_selector = combo = create_editor('choice_key', fm) combo.parameters(state='readonly', values=self.managers) combo.pack(side='left', expand=True) combo.bind('<<PropertyChanged>>', self._layout_manager_changed) self._manager_options = self.managers.keys() fm.grid(row=0, sticky='w') # Layout Options editors self._rcbag = {} # bag for row/column prop editors # main options frame self._fprop = f = ttk.Labelframe(self._sframe.innerframe, text=_('Options:'), padding=4) f.grid(row=1, sticky='nswe') # hack to resize correctly when properties are hidden label = ttk.Frame(f) label.grid() label_tpl = "{0}:" row = 0 col = 0 groups = ( ('00', properties.MANAGER_PROPERTIES, properties.LAYOUT_OPTIONS), ) for gcode, plist, propdescr in groups: for name in plist: kwdata = propdescr[name] labeltext = label_tpl.format(name) label = ttk.Label(self._fprop, text=labeltext, anchor=tk.W) label.grid(row=row, column=col, sticky=tk.EW, pady=2) widget = self._create_editor(self._fprop, name, kwdata) widget.grid(row=row, column=col+1, sticky=tk.EW, pady=2) row += 1 self._propbag[gcode+name] = (label, widget) # Grid row properties self._fgr_label = _("Grid row '{0}' options:") self._fgr = fgr = ttk.LabelFrame(self._sframe.innerframe, text=self._fgr_label, padding=5) fgr.grid(row=2, column=0, sticky=tk.NSEW, pady='10 0') name_format = 'row_{0}' # row_{name} row = 0 label_tpl = "{0}:" for pname in properties.GRID_RC_PROPERTIES: kwdata = properties.LAYOUT_OPTIONS[pname] alias = name_format.format(pname) labeltext = label_tpl.format(pname) label = ttk.Label(fgr, text=labeltext, anchor=tk.W) label.grid(row=row, column=0, sticky=tk.EW, pady=2) widget = self._create_editor(fgr, alias, kwdata) widget.grid(row=row, column=1, sticky=tk.EW, pady=2) self._rcbag[alias] = (label, widget) row = row + 1 fgr.columnconfigure(1, weight=1) # Grid column properties self._fgc_label = _("Grid column '{0}' options:") self._fgc = fgc = ttk.LabelFrame(self._sframe.innerframe, text=self._fgc_label, padding=5) fgc.grid(row=3, column=0, sticky=tk.NSEW, pady='10 0') name_format = 'col_{0}' # row_{name} row = 0 label_tpl = "{0}:" for pname in properties.GRID_RC_PROPERTIES: kwdata = properties.LAYOUT_OPTIONS[pname] alias = name_format.format(pname) labeltext = label_tpl.format(pname) label = ttk.Label(fgc, text=labeltext, anchor=tk.W) label.grid(row=row, column=0, sticky=tk.EW, pady=2) widget = self._create_editor(fgc, alias, kwdata) widget.grid(row=row, column=1, sticky=tk.EW, pady=2) self._rcbag[alias] = (label, widget) row = row + 1 fgc.columnconfigure(1, weight=1)