def __init__(self, name, klass, parent, id, custom_class=True): np.PropertyOwner.__init__(self) # initialise instance logger self._logger = logging.getLogger(self.__class__.__name__) # initialise instance self.parent = parent self.id = id # id used for internal purpose events # initialise instance properties self.name = name_p = np.NameProperty(name) self.classname = klass self.klass = klass_p = np.ClassProperty(klass, name="class") # Name of the object's class: read/write or read only if not custom_class: klass_p.readonly = True # only used for StatusBar, ToolBar and also non-standalone MenuBar # Name of object's wxWidget class; base and klass are mostly the same, except e.g. wxDialog: self.base = klass # not editable; e.g. wxFrame or wxComboBox; used to find the code generator # If true, the user can change the value of the 'class' property: self.custom_class = custom_class if getattr(self, '_custom_base_classes', False): self.custom_base = np.TextPropertyD("", multiline=False, default_value=None) else: self.custom_base = None self.extracode = np.CodeProperty() self.extracode_pre = np.CodeProperty() self.extracode_post = np.CodeProperty() self.extraproperties = np.ExtraPropertiesProperty() self.widget = None # this is the reference to the actual wxWindow widget, created when required self._dont_destroy = False EventsMixin.__init__(self)
def get_property_handler(self, prop_name): """\ returns a custom handler function for the property 'prop_name', used when loading this object from an xml file. handler must provide three methods: 'start_elem', 'end_elem' and 'char_data' """ # ALB 2004-12-05 return EventsMixin.get_property_handler(self, prop_name)
def __init__(self, name, klass, parent, id, custom_class=True): np.PropertyOwner.__init__(self) # initialise instance logger self._logger = logging.getLogger(self.__class__.__name__) # initialise instance self.parent = parent self.id = id # id used for internal purpose events # initialise instance properties self.name = name_p = np.NameProperty(name) self.klass = klass_p = np.TextProperty( klass, name="class" ) # Name of the object's class: read/write or read only if not custom_class: klass_p.readonly = True # validation for class klass_p.validation_re = re.compile(r'^[a-zA-Z_]+[\w:.0-9-]*$') # Name of object's wxWidget class; base and klass are mostly the same, except e.g. wxDialog: self.base = np.TextProperty(klass, "base") # If true, the user can change the value of the 'class' property: self.custom_class = custom_class if getattr(self, '_custom_base_classes', False): self.custom_base = np.TextPropertyD("", multiline=False) else: self.custom_base = None self.extracode = cp.CodePropertyD() # code property self.extraproperties = cp.ExtraPropertiesProperty() self.widget = None # this is the reference to the actual wxWindow widget, created when required self._rmenu = None # popup menu self._dont_destroy = False EventsMixin.__init__(self)
def __init__(self, name, klass, parent, id, property_window, show=True, custom_class=True): # property_window: widget inside which Properties of this object # are displayed # name: name of the object # klass: name of the object's class # custom_class: if true, the user can chage the value of the 'class' # property # dictionary of properties relative to this object; the properties that # control the layout (i.e. the behaviour when inside a sizer) are not # contained here, but in a separate list (see ManagedBase) # the keys of the dict are the names of the properties self.properties = {} self.parent = parent # id used for internal purpose events self.id = id self.name = name self.klass = klass self.base = klass self.custom_class = custom_class self._dont_destroy = False self.access_functions = { 'name' : (lambda : self.name, self.set_name), 'class' : (lambda : self.klass, self.set_klass) } # these two properties are special and are not listed in # 'self.properties' self.name_prop = TextProperty(self, 'name', None, label=_("name")) self.klass_prop = TextProperty(self, 'class', None, readonly=not custom_class, label=_("class")) if custom_class: self.klass_prop.tooltip = _("If you change the default value, " \ "it will be interpreted as the name " \ "of the subclass of the widget. " \ "How this name affects code generation "\ "depends on the kind (i.e. language) " \ "of output. See the docs for " \ "more details.") # ALB 2007-08-31: custom base classes support if getattr(self, '_custom_base_classes', False): self.custom_base = "" def get_custom_base(): return self.custom_base def set_custom_base(val): self.custom_base = val self.access_functions['custom_base'] = (get_custom_base, set_custom_base) p = self.properties['custom_base'] = TextProperty( self, 'custom_base', can_disable=True, enabled=False) p.label = _('Base class(es)') p.tooltip = _("""\ A comma-separated list of custom base classes. The first will be invoked \ with the same parameters as this class, while for the others the default \ constructor will be used. You should probably not use this if \ "overwrite existing sources" is not set.""") self.notebook = None self.property_window = property_window # popup menu self._rmenu = None # this is the reference to the actual wxWindow widget; it is created # only if needed, i.e. when it should become visible self.widget = None if show: self.show_widget(True) property_window.SetSize((250, 340)) property_window.Show(True) # ALB 2004-12-05 EventsMixin.__init__(self) # code property import code_property self.properties['extracode'] = code_property.CodeProperty(self) self.properties['extraproperties'] = code_property.ExtraPropertiesProperty(self)
def __init__(self, name, klass, parent, id, property_window, show=True, custom_class=True): # property_window: widget inside which Properties of this object # are displayed # name: name of the object # klass: name of the object's class # custom_class: if true, the user can chage the value of the 'class' # property # dictionary of properties relative to this object; the properties that # control the layout (i.e. the behaviour when inside a sizer) are not # contained here, but in a separate list (see ManagedBase) # the keys of the dict are the names of the properties self.properties = {} self.parent = parent # id used for internal purpose events self.id = id self.name = name self.klass = klass self.base = klass self.custom_class = custom_class self._dont_destroy = False self.access_functions = { 'name': (lambda: self.name, self.set_name), 'class': (lambda: self.klass, self.set_klass) } # these two properties are special and are not listed in # 'self.properties' self.name_prop = TextProperty(self, 'name', None, label=_("name")) self.klass_prop = TextProperty(self, 'class', None, readonly=not custom_class, label=_("class")) if custom_class: self.klass_prop.tooltip = _("If you change the default value, " \ "it will be interpreted as the name " \ "of the subclass of the widget. " \ "How this name affects code generation "\ "depends on the kind (i.e. language) " \ "of output. See the docs for " \ "more details.") # ALB 2007-08-31: custom base classes support if getattr(self, '_custom_base_classes', False): self.custom_base = "" def get_custom_base(): return self.custom_base def set_custom_base(val): self.custom_base = val self.access_functions['custom_base'] = (get_custom_base, set_custom_base) p = self.properties['custom_base'] = TextProperty(self, 'custom_base', can_disable=True, enabled=False) p.label = _('Base class(es)') p.tooltip = _("""\ A comma-separated list of custom base classes. The first will be invoked \ with the same parameters as this class, while for the others the default \ constructor will be used. You should probably not use this if \ "overwrite existing sources" is not set.""") self.notebook = None self.property_window = property_window # popup menu self._rmenu = None # this is the reference to the actual wxWindow widget; it is created # only if needed, i.e. when it should become visible self.widget = None if show: self.show_widget(True) property_window.SetSize((250, 340)) property_window.Show(True) # ALB 2004-12-05 EventsMixin.__init__(self) # code property import code_property self.properties['extracode'] = code_property.CodeProperty(self) self.properties[ 'extraproperties'] = code_property.ExtraPropertiesProperty(self)