def editOption(self, row): currentValue = options.get(row.name, self.source) vd.addUndo(options.set, row.name, currentValue, self.source) if isinstance(row.value, bool): options.set(row.name, not currentValue, self.source) else: options.set(row.name, self.editCell(1, value=currentValue), self.source)
def toggleProfiling(t): if not t.profile: t.profile = cProfile.Profile() t.profile.enable() if not options.profile: options.set('profile', 'vdprofile') else: t.profile.disable() t.profile = None options.set('profile', '') status('profiling ' + ('ON' if t.profile else 'OFF'))
class OptionsSheet(Sheet): _rowtype = Option # rowdef: Option rowtype = 'options' precious = False columns = ( ColumnAttr('option', 'name'), Column( 'value', getter=lambda col, row: col.sheet.diffOption(row.name), setter=lambda col, row, val: options.set(row.name, val, col.sheet. source), ), Column('default', getter=lambda col, row: options.get(row.name, 'global')), Column( 'description', width=40, getter=lambda col, row: options._get(row.name, 'global').helpstr), ColumnAttr('replayable'), ) colorizers = [ CellColorizer( 3, None, lambda s, c, r, v: v.value if r and c in s.columns[1:3] and r.name.startswith('color_') else None), ] nKeys = 1 def diffOption(self, optname): val = options.get(optname, self.source) default = options.get(optname, 'global') return val if val != default else '' def editOption(self, row): currentValue = options.get(row.name, self.source) vd.addUndo(options.set, row.name, currentValue, self.source) if isinstance(row.value, bool): options.set(row.name, not currentValue, self.source) else: options.set(row.name, self.editCell(1, value=currentValue), self.source) def reload(self): self.rows = [] for k in options.keys(): opt = options._get(k) self.addRow(opt) self.columns[ 1].name = 'global_value' if self.source == 'override' else 'sheet_value'
def editOption(self, row): if isinstance(row.value, bool): options.set(row.name, not options.get(row.name, self.source), self.source) else: options.set(row.name, self.editCell(1), self.source)