Exemplo n.º 1
0
 def OnPathChange(self, path):
     assert doout(value)
     # FIXME: Should this check if the input is a real valid dir?
     # Alternative the BindingString can be marked as read-only
     # (need to develop) and only settable via a direct call to
     # __set__
     self.widget.SetPath(path)
Exemplo n.º 2
0
    def __init__(self, name, group=None, **kwargs):
        self.group = group
        if group is not None:
            self._groups[group].append(self)

        assert doout(name, kwargs)
        BindingWidget.__init__(self, name, **kwargs)
Exemplo n.º 3
0
def load_package(cls, package, reloading, results):
    for modname in dir(package):
        if modname.startswith('_'):
            continue

        mod = getattr(package, modname)
        if not isinstance(mod, types.ModuleType):
            continue

        doout('checking', modname)
        try:
            reload(mod)
        except ImportError, e:
            results.append(e)
        except Exception, e:
            results.append(e)
Exemplo n.º 4
0
    def __init__(self, name, group=None, **kwargs):
        self.group = group
        if group is not None:
            self._groups[group].append(self)

        assert doout(name, kwargs)
        BindingWidget.__init__(self, name, **kwargs)
Exemplo n.º 5
0
def load_package(cls, package, reloading, results):
    for modname in dir(package):
        if modname.startswith('_'):
            continue

        mod = getattr(package, modname)
        if not isinstance(mod, types.ModuleType):
            continue

        doout('checking', modname)
        try:
            reload(mod)
        except ImportError, e:
            results.append(e)
        except Exception, e:
            results.append(e)
Exemplo n.º 6
0
    def __init__(self, name, **kwargs):
        assert doout(name)
        self.name = name

        self.doconfig = kwargs.get('config', True)
        self.defval = kwargs.get('default', None)
        self.install()
Exemplo n.º 7
0
 def OnPathChange(self, path):
     assert doout(value)
     # FIXME: Should this check if the input is a real valid dir?
     # Alternative the BindingString can be marked as read-only
     # (need to develop) and only settable via a direct call to
     # __set__
     self.widget.SetPath(path)
Exemplo n.º 8
0
    def OnValueChange(self, value):
        assert doout(value)
        newvalue = min(self.max, max(self.min, value))

        if value != newvalue:
            self._set('value', newvalue)

        self.widget.SetValue(newvalue)
Exemplo n.º 9
0
    def __init__(self, name, group, **kwargs):
        self.group = group
        self._groups[group].append(self)

        self.ftime = True

        assert doout(name, kwargs)
        BindingWidget.__init__(self, name, **kwargs)
Exemplo n.º 10
0
    def __init__(self, name, group, **kwargs):
        self.group = group
        self._groups[group].append(self)

        self.ftime = True

        assert doout(name, kwargs)
        BindingWidget.__init__(self, name, **kwargs)
Exemplo n.º 11
0
    def OnValueChange(self, value):
        assert doout(value)
        newvalue = min(self.max, max(self.min, value))

        if value != newvalue:
            self._set('value', newvalue)

        self.widget.SetValue(newvalue)
Exemplo n.º 12
0
    def OnItemsChange(self, value):
        assert doout(value)
        # FIXME:
        # A more complex policy is needed to ensure that if string x is selected
        # it remains selected after we clear the combobox or if for example the previous
        self.widget.Clear()
        self.widget.SetItems(value)

        self.stringselection = self.stringselection  # make sure it's selected if possible
Exemplo n.º 13
0
 def OnStringSelectionChange(self, value):
     assert doout(value)
     retval = self.widget.SetStringSelection(value)
     # The variable must contain the reality and not what was sent, because the operation may fail
     # if the "value" is not in the list of items (use _set to avoid an infinite loop)
     self._set('stringselection', self.widget.GetStringSelection())
     # No event was emitted ... manual selection update
     self._set('selection', self.widget.GetSelection())
     return retval
Exemplo n.º 14
0
    def rd(self, bindname, obj):
        assert doout()
        if not self.doconfig:
            return self.getdefault(obj)

        rdfunc = getattr(self.config, self.rdattr)
        value = rdfunc(bindname, self.getdefault(obj))
        self.config.Flush()
        return value
Exemplo n.º 15
0
    def rd(self, bindname, obj):
        assert doout()
        if not self.doconfig:
            return self.getdefault(obj)

        rdfunc = getattr(self.config, self.rdattr)
        value = rdfunc(bindname, self.getdefault(obj))
        self.config.Flush()
        return value
Exemplo n.º 16
0
    def __init__(self, name, **kwargs):
        assert doout(name)
        self.name = name

        self.defaults = dict()

        self.doconfig = kwargs.get('config', True)
        self.defval = kwargs.get('default', self.__class__.defclass())
        self.install()
Exemplo n.º 17
0
    def __init__(self, name, **kwargs):
        assert doout(name)
        self.name = name

        self.defaults = dict()

        self.doconfig = kwargs.get('config', True)
        self.defval = kwargs.get('default', self.__class__.defclass())
        self.install()
Exemplo n.º 18
0
    def __init__(self, name, **kwargs):
        assert doout(name)
        self.name = name
        self.wname = kwargs.get('wname', None)

        self.install()
        self.bindname = self.makebindname(self.owner)
        self.findwidget()
        self.createvars(**kwargs)
        self.dobindings()
Exemplo n.º 19
0
    def OnItemsChange(self, value):
        assert doout(value)
        # FIXME: A more complex policy is needed to ensure that if
        # string x is selected it remains selected after we clear the
        # combobox or if for example the previous
        self.widget.Clear()
        self.widget.SetItems(value)

        # make sure it's selected if possible
        self.stringselection = self.stringselection
Exemplo n.º 20
0
    def __init__(self, name, **kwargs):
        assert doout(name)
        self.name = name
        self.wname = kwargs.get('wname', None)

        self.install()
        self.bindname = self.makebindname(self.owner)
        self.findwidget()
        self.createvars(**kwargs)
        self.dobindings()
Exemplo n.º 21
0
 def OnStringSelectionChange(self, value):
     assert doout(value)
     retval = self.widget.SetStringSelection(value)
     # The variable must contain the reality and not what was sent,
     # because the operation may fail if the "value" is not in the
     # list of items (use _set to avoid an infinite loop)
     self._set('stringselection', self.widget.GetStringSelection())
     # No event was emitted ... manual selection update
     self._set('selection', self.widget.GetSelection())
     return retval
Exemplo n.º 22
0
    def OnRadioButton(self, event):
        assert doout(event)
        event.Skip()
        # self.value = event.GetInt()
        # This avoids a callback to
        value = event.GetInt()
        self._set('value', value)

        # Manage the group
        for radio in self._groups[self.group]:
            if radio != self:
                radio._set('value', not value)
Exemplo n.º 23
0
    def findwidget(self):
        assert doout()
        if not self.wname:
            self.wname = 'm_' + self.wprefix.lower() + self.name.lower()

        for attr in dir(self.owner):
            if attr.lower() == self.wname:
                self.widget = getattr(self.owner, attr, None)
                break

        assert getattr(self, 'widget', None),\
            'Failed to acquire widget - ' + self.wname
Exemplo n.º 24
0
    def OnRadioButton(self, event):
        assert doout(event)
        event.Skip()
        # self.value = event.GetInt()
        # This avoids a callback to
        value = event.GetInt()
        self._set('value', value)

        # Manage the group
        for radio in self._groups[self.group]:
            if radio != self:
                radio._set('value', not value)
Exemplo n.º 25
0
    def findwidget(self):
        assert doout()
        if not self.wname:
            self.wname = 'm_' + self.wprefix.lower() + self.name.lower()

        for attr in dir(self.owner):
            if attr.lower() == self.wname:
                self.widget = getattr(self.owner, attr, None)
                break

        assert getattr(self, 'widget', None),\
            'Failed to acquire widget - ' + self.wname
Exemplo n.º 26
0
    def OnValueChange(self, value):
        assert doout(value)
        self.widget.SetValue(value)

        if self.ftime:
            # Need this flag, because during initial config, members of
            # the group are not all there and they all have the right value
            self.ftime = False
            return

        # Manage the group
        for radio in self._groups[self.group]:
            if radio != self:
                radio.widget.SetValue(not value)
Exemplo n.º 27
0
 def addcallback(self, callback):
     assert doout(callback)
     # im_self ensures if the object is not there it will not be found
     bindname = self.makebindname(callback.im_self)
     try:
         self.callbacks[bindname][callback.im_self] = callback
     except KeyError:
         pass
     else:
         # Tell the callback the current value
         # (it will for example check/uncheck a checkbox)
         # callback(self.__get__(self, self.__class__))
         callback(self.__get__(callback.im_self,
                               callback.im_self.__class__))
Exemplo n.º 28
0
    def OnValueChange(self, value):
        assert doout(value)
        self.widget.SetValue(value)

        if self.ftime:
            # Need this flag, because during initial config, members of
            # the group are not all there and they all have the right value
            self.ftime = False
            return

        # Manage the group
        for radio in self._groups[self.group]:
            if radio != self:
                radio.widget.SetValue(not value)
Exemplo n.º 29
0
 def addcallback(self, callback):
     assert doout(callback)
     # im_self ensures if the object is not there it will not be found
     bindname = self.makebindname(callback.im_self)
     try:
         self.callbacks[bindname][callback.im_self] = callback
     except KeyError:
         pass
     else:
         # Tell the callback the current value
         # (it will for example check/uncheck a checkbox)
         # callback(self.__get__(self, self.__class__))
         callback(self.__get__(callback.im_self,
                               callback.im_self.__class__))
Exemplo n.º 30
0
def load_submodule(cls, submod, reloading, results):
    load_methods(cls, submod, reloading)

    if hasattr(submod, '__package__'):
        doout('submod.__package_', submod.__package__)
        doout('submod.__name__', submod.__name__)
        if submod.__package__ and submod.__package__ == submod.__name__:
            doout('loading package', submod.__name__)
            load_package(cls, submod, reloading, results)
Exemplo n.º 31
0
def load_submodule(cls, submod, reloading, results):
    load_methods(cls, submod, reloading)

    if hasattr(submod, '__package__'):
        doout('submod.__package_', submod.__package__)
        doout('submod.__name__', submod.__name__)
        if submod.__package__ and submod.__package__ == submod.__name__:
            doout('loading package', submod.__name__)
            load_package(cls, submod, reloading, results)
Exemplo n.º 32
0
    def OnItemsChange(self, value):
        assert doout(value)
        # FIXME: A more complex policy is needed to ensure that if
        # string x is selected it remains selected after we clear the
        # combobox or if for example the previous
        self.widget.Clear()
        self.widget.SetItems(value)

        # make sure it's selected if possible
        strsel = self.stringselection
        selection = 0 if strsel not in value else value.index(strsel)

        self.widget.SetSelection(selection)  # because we did a clear
        # self._('selection', selection)  # update the selection
        self.stringselection = self.widget.GetStringSelection()
Exemplo n.º 33
0
    def OnItemsChange(self, value):
        assert doout(value)
        # FIXME: A more complex policy is needed to ensure that if
        # string x is selected it remains selected after we clear the
        # combobox or if for example the previous
        self.widget.Clear()
        self.widget.SetItems(value)

        # make sure it's selected if possible
        strsel = self.stringselection
        selection = 0 if strsel not in value else value.index(strsel)

        self.widget.SetSelection(selection)  # because we did a clear
        # self._('selection', selection)  # update the selection
        self.stringselection = self.widget.GetStringSelection()
Exemplo n.º 34
0
    def __get__(self, obj, cls=None):
        assert doout(obj, cls)
        if obj is None:
            # this prevents early auto-setting if for example a decorator does a "dir" of the class
            # attributes even before the registry object has been created and allows access to the object itself
            return self

        objbindname = self.makebindname(obj)

        try:
            return self.ncache[objbindname]
        except KeyError:
            value = self.rd(objbindname)
            value = self.postrd(value)
            self.ncache[objbindname] = value
            return value
Exemplo n.º 35
0
    def __get__(self, obj, cls=None):
        assert doout(obj, cls)
        if obj is None:
            # this prevents early auto-setting if for example a
            # decorator does a "dir" of the class attributes even
            # before the registry object has been created and allows
            # access to the object itself
            return self

        objbindname = self.makebindname(obj)

        try:
            return self.ncache[objbindname]
        except KeyError:
            value = self.rd(objbindname, obj)
            value = self.postrd(value, obj)
            self.ncache[objbindname] = value
            return value
Exemplo n.º 36
0
    def __set__(self, obj, value, cb=True):
        assert doout(obj, value)
        objbindname = self.makebindname(obj)
        try:
            if self.ncache[objbindname] == value:
                return
        except KeyError:
            pass

        self.ncache[objbindname] = value
        wrvalue = self.prewr(value)
        self.wr(objbindname, wrvalue)
        # self.config.Flush()

        # Report to any callback
        # if obj is not None:
        if cb:
            map(lambda callback: callback(value),
                self.callbacks[objbindname].itervalues())
Exemplo n.º 37
0
    def __set__(self, obj, value, cb=True):
        assert doout(obj, value)
        objbindname = self.makebindname(obj)
        try:
            if self.ncache[objbindname] == value:
                return
        except KeyError:
            pass

        self.ncache[objbindname] = value
        wrvalue = self.prewr(value)
        self.wr(objbindname, wrvalue)
        # self.config.Flush()

        # Report to any callback
        # if obj is not None:
        if cb:
            map(lambda callback: callback(value),
                self.callbacks[objbindname].itervalues())
Exemplo n.º 38
0
    def OnValueChange(self, value):
        assert doout(value)

        if value == self.value:
            self.widget.SetValue(value)
            return

        if self.group is not None:
            if not value:  # in a group and being set to False ... no
                self._set('value', True)
                if not self.wdiget.GetValue():  # check the widget
                    self.widget.SetValue(True)

            else:  # being set to True
                self.widget.SetValue('value', True)
                for checkbox in self._groups[self.group]:
                    if checkbox != self:
                        checkbox._set('value', False)
                        checkbox.widget.SetValue(False)
            return

        # Not in a group
        self.widget.SetValue(value)
Exemplo n.º 39
0
    def OnValueChange(self, value):
        assert doout(value)

        if value == self.value:
            self.widget.SetValue(value)
            return

        if self.group is not None:
            if not value:  # in a group and being set to False ... no
                self._set('value', True)
                if not self.wdiget.GetValue():  # check the widget
                    self.widget.SetValue(True)

            else:  # being set to True
                self.widget.SetValue('value', True)
                for checkbox in self._groups[self.group]:
                    if checkbox != self:
                        checkbox._set('value', False)
                        checkbox.widget.SetValue(False)
            return

        # Not in a group
        self.widget.SetValue(value)
Exemplo n.º 40
0
    def OnCheckBox(self, event):
        assert doout(event)
        event.Skip()
        # self.value = event.GetInt()
        # This avoids a callback to
        value = event.GetInt()

        if self.group is not None:
            if not value:  # in a group and being set to False ... no
                self.widget.SetValue(True)
                if not self.value:  # check the value
                    self._set('value', True)

            else:
                self._set('value', True)
                # in a grou and being set to True
                for checkbox in self._groups[self.group]:
                    if checkbox != self:
                        checkbox._set('value', False)
                        checkbox.widget.SetValue(False)
            return

        # Not in a group
        self._set('value', value)
Exemplo n.º 41
0
    def OnCheckBox(self, event):
        assert doout(event)
        event.Skip()
        # self.value = event.GetInt()
        # This avoids a callback to
        value = event.GetInt()

        if self.group is not None:
            if not value:  # in a group and being set to False ... no
                self.widget.SetValue(True)
                if not self.value:  # check the value
                    self._set('value', True)

            else:
                self._set('value', True)
                # in a grou and being set to True
                for checkbox in self._groups[self.group]:
                    if checkbox != self:
                        checkbox._set('value', False)
                        checkbox.widget.SetValue(False)
            return

        # Not in a group
        self._set('value', value)
Exemplo n.º 42
0
 def OnTextEnter(self, event):
     assert doout(event)
     event.Skip()
     self.value = event.GetString()
     self.items.append(self.value)
     self.stringselection = self.value
Exemplo n.º 43
0
 def OnText(self, event):
     assert doout(event)
     event.Skip()
     self.value = event.GetString()
Exemplo n.º 44
0
 def OnComboBox(self, event):
     assert doout(event)
     event.Skip()
     self._set('selection', event.GetInt())
     self._set('stringselection', event.GetString())
Exemplo n.º 45
0
 def __init__(self, name, **kwargs):
     assert doout(name, kwargs)
     BindingWidget.__init__(self, name, **kwargs)
Exemplo n.º 46
0
 def OnKillFocus(self, event):
     assert doout(event)
     event.Skip()
     self._set('value', self.widget.GetValue())
Exemplo n.º 47
0
 def OnTextEnter(self, event):
     assert doout(event)
     event.Skip()
     self.value = event.GetString()
     self.items.append(self.value)
     self.stringselection = self.value
Exemplo n.º 48
0
 def OnSelectionChange(self, value):
     assert doout(value)
     self.widget.SetSelection(value)
Exemplo n.º 49
0
 def OnComboBox(self, event):
     assert doout(event)
     event.Skip()
     self._set('selection', event.GetInt())
     self._set('stringselection', event.GetString())
Exemplo n.º 50
0
 def __init__(self, name, **kwargs):
     assert doout(name, kwargs)
     BindingWidget.__init__(self, name, **kwargs)
Exemplo n.º 51
0
 def OnTextChange(self, value):
     assert doout(value)
     self.widget.SetValue(value)
Exemplo n.º 52
0
 def OnText(self, event):
     assert doout(event)
     event.Skip()
     self._set('value', event.GetString())
Exemplo n.º 53
0
 def OnText(self, event):
     assert doout(event)
     event.Skip()
     self.value = event.GetString()
Exemplo n.º 54
0
 def OnKillFocus(self, event):
     assert doout(event)
     event.Skip()
     self._set('value', self.widget.GetValue())
Exemplo n.º 55
0
 def OnTextChange(self, value):
     assert doout(value)
     self.widget.SetValue(value)
Exemplo n.º 56
0
 def wr(self, bindname, value):
     assert doout(value)
     if self.doconfig:
         wrfunc = getattr(self.config, self.wrattr)
         wrfunc(bindname, value)
         self.config.Flush()
Exemplo n.º 57
0
 def OnFilePickerChanged(self, event):
     assert doout(event)
     event.Skip()
     # value can also be gotten from self.widget
     self._set('path', event.GetPath())
Exemplo n.º 58
0
 def OnFilePickerChanged(self, event):
     assert doout(event)
     event.Skip()
     # value can also be gotten from self.widget
     self._set('path', event.GetPath())
Exemplo n.º 59
0
 def OnSelectionChange(self, value):
     assert doout(value)
     self.widget.SetSelection(value)
Exemplo n.º 60
0
 def wr(self, bindname, value):
     assert doout(value)
     if self.doconfig:
         wrfunc = getattr(self.config, self.wrattr)
         wrfunc(bindname, value)
         self.config.Flush()