示例#1
0
    def __init__(self, name, parent, pos=None):
        assert self.WX_CLASS
        np.PropertyOwner.__init__(self)
        # initialise instance logger
        self._logger = logging.getLogger(self.__class__.__name__)

        self.widget = None  # this is the reference to the actual wxWindow widget, created when required
        self._dont_destroy = False  # for notebook pages, this will be set to True
        self.item = None  # the TreeCtrl item

        # initialise instance properties
        self.name = np.NameProperty(name)
        if self.IS_TOPLEVEL: self.names = {}  # XXX change to set

        # initialise structure
        self.parent = parent
        if self.CHILDREN is None:
            # variable number of children
            self.children = _UniqueList([])
        elif self.CHILDREN:
            # fixed number of children
            self.children = _UniqueList([None] * self.CHILDREN)
        else:
            # no children
            self.children = None
        self.id = wx.NewId()  # id used for internal purpose events
        if isinstance(pos, str):
            setattr(self.parent, pos, self)
            self.pos = pos
        else:
            self.parent.add_item(self, pos)

        # the toplevel parent keeps track of the names
        if self.IS_NAMED:
            self.toplevel_parent.names[name] = 1
示例#2
0
    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)
示例#3
0
    def __init__(self, name, parent, index):
        assert self.WX_CLASS
        np.PropertyOwner.__init__(self)

        self.widget = None  # this is the reference to the actual wxWindow widget, created when required
        self.item = None  # the TreeCtrl item

        # initialise instance properties
        self.name = np.NameProperty(name)

        # initialise structure
        self.parent = parent
        if self.CHILDREN is None:
            # variable number of children
            self.children = _UniqueList([])
        elif self.CHILDREN:
            # fixed number of children
            self.children = _UniqueList([None] * self.CHILDREN)
        else:
            # no children
            self.children = None
        self.id = wx.NewId()  # id used for internal purpose events
        if isinstance(index, str):
            setattr(self.parent, index, self)
            self.attribute_name = index
        else:
            self.parent.add_item(self, index)

        # the toplevel parent keeps track of the names ( see next two methods ...contained_name() )
        if self.IS_TOPLEVEL:
            # either derived from edit_windows.TopLevelBase or a toplevel Menu/ToolBar where IS_TOPLEVEL is set True
            self.names = set([self.name])
            self._NUMBERS = {}  # for finding new names
        elif self.IS_NAMED:
            self.toplevel_parent.track_contained_name(new_name=name)
示例#4
0
    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)