def on_change_val(self, event): val = self.get_value() for i in range(len(val)): handler = val[i][1].strip() if handler and self.validator_re.match(handler) is None: self.set_value(self.val) return event.Skip() GridProperty.on_change_val(self, event)
def display(self, panel): GridProperty.display(self, panel) self.btn.Hide() wx.grid.EVT_GRID_CELL_CHANGE(self.grid, self.on_change_val) tooltip = """\ You can use this property to add some extra custom properties to this widget. For each property "prop" with value "val", wxGlade will generate a \ "widget.SetProp(val)" line (or a "<prop>val</prop>" line for XRC).""" self.grid.SetToolTip(wx.ToolTip(tooltip))
def __init__(self, owner): cols = [(_('Event'), GridProperty.STRING), (_('Handler'), GridProperty.STRING)] GridProperty.__init__(self, owner, 'events', None, cols, len(owner.events), False, False, False, label=_('events')) self._pos = {} for index, name in enumerate(owner.events): self._pos[name] = index self.validator_re = re.compile(r'^\s*[\w-]+\s*$') self.set_value([[name, ''] for name in owner.events])
def display(self, parent): GridProperty.display(self, parent) attr = wx.grid.GridCellAttr() attr.SetReadOnly(True) self.grid.SetColAttr(0, attr) self.grid.AutoSizeColumn(0, False) self.grid.AutoSizeColumn(1, False) wx.grid.EVT_GRID_CELL_CHANGE(self.grid, self.on_change_val) szr = self.panel.GetSizer() szr.Show(self.btn_sizer, False) szr.Layout()
def __init__(self, owner): setattr(owner, 'extraproperties', []) def get(): return getattr(owner, 'extraproperties') def set(val): return setattr(owner, 'extraproperties', val) owner.access_functions['extraproperties'] = (get, set) cols = [(_('Property'), GridProperty.STRING), (_('Value'), GridProperty.STRING)] self.label = _('Extra properties for this widget') GridProperty.__init__(self, owner, 'extraproperties', None, cols, can_insert=False)
def display(self, panel): GridProperty.display(self, panel) self.btn.Hide() wx.grid.EVT_GRID_CELL_CHANGE(self.grid, self.on_change_val) tooltip = """\ You can use this property to add some extra custom properties to this widget. For each property "prop" with value "val", wxGlade will generate a \ "widget.SetProp(val)" line (or a "<prop>val</prop>" line for XRC). NOTE: at the moment, this property is supported only by the following code \ generators: Python C++ XRC Perl""" self.grid.SetToolTip(wx.ToolTip(tooltip))
def __init__(self, owner): setattr(owner, "extraproperties", []) def get(): return getattr(owner, "extraproperties") def set(val): return setattr(owner, "extraproperties", val) owner.access_functions["extraproperties"] = (get, set) cols = [(_("Property"), GridProperty.STRING), (_("Value"), GridProperty.STRING)] self.label = _("Extra properties for this widget") GridProperty.__init__(self, owner, "extraproperties", None, cols, can_insert=False)
def set_value(self, val): if isinstance(val, dict): val = [[k, val[k]] for k in sorted(val.keys())] GridProperty.set_value(self, val)
def remove_row(self, event): GridProperty.remove_row(self, event) self.on_change_val(event)
def add_row(self, event): GridProperty.add_row(self, event) self.on_change_val(event)