예제 #1
0
 def setTip(self, tip):
     """
     Sets the `tip' for this widget.
     """
     if self.delegate('will_set_tip'):
         try:
             self._doSetTip(tip)
         except:
             raise ViewError, _("Unable to set tip")
         return True
     return False
예제 #2
0
    def setParent(self, parent):
        """
        Set the parent of the widget.

        Called with None as parent, unparent the widget.

        If called with a non-None parent and already parent, throws a
        ViewParentingError.
        """
        if self.getParent() is not None and parent is not None:
            raise ViewParentingError, _("View %s is already parented to %s."
                                        ) % (self, self.getParent())
        super(View, self).setParent(parent)
예제 #3
0
    def idle(self):
        """
        Make the widget *not* look `busy'.

        Returns the result of the delegation (i.e., True if delegates
        agreed to doing it). Raises a ViewError if anything bad
        happens.
        """
        if self.delegate('will_idle'):
            try:
                self._doIdle()
            except:
                raise ViewError, _("Unable to idle")
            return True
        return False
예제 #4
0
 def enable(self):
     """
     Make the widget responsive to user interaction.
     
     Returns the result of the delegation (i.e., True if delegates
     agreed to doing it). Raises a ViewError if anything bad
     happens.
     """
     if self.delegate('will_enable'):
         try:
             self._doEnable()
         except:
             raise ViewError, _("Unable to enable")
         return True
     return False
    def removeChild(self, child):
        """
        Remove a child from the container. Returns the result of the
        delegation

        Do not call this, call child.setParent (None) instead
        """
        if child.getParent() is not self:
            raise CompositionError, _("Child is not in parent")
        if self.delegate('will_remove_child', args=child):
            self.debug ('will_remove_child %s from %s' % (child, self))
            if hasattr (self, '_doRemoveChild'):
                self._doRemoveChild(child)
            super(CompositeResponder, self).removeChild(child)
            return True
        return False
예제 #6
0
    def show(self):
        """
        Make this widget, and any subwidgets thereof, visible.

        Returns the result of the delegation (i.e., True if delegates
        agreed to doing it). Raises a ViewError if anything bad
        happens.
        """
        if self.delegate('will_show'):
            self.debug('showing %s' % self)
            try:
                self._doShow()
                self._hidden = False
            except:
                raise ViewError, _("Unable to show")
            return True
        return False
예제 #7
0
    def hide(self):
        """
        Make this widget invisible.

        Returns the result of the delegation (i.e., True if delegates
        agreed to doing it). Raises a ViewError if anything bad
        happens.
        """
        if self.delegate('will_hide'):
            self.debug('hiding %s' % self)
            try:
                self._doHide()
                self._hidden = True
            except:
                raise ViewError, _("Unable to hide")
            return True
        return False
예제 #8
0
    def focus(self):
        """
        Make this widget the active one, out of all the ones in its
        window.

        This does *not* ensure the widget has keyboard focus.

        Returns the result of the delegation (i.e., True if delegates
        agreed to doing it). Raises a ViewError if anything bad
        happens.
        """
        if self.delegate('will_focus'):
            try:
                self._doFocus()
            except:
                raise ViewError, _("Unable to focus")
            return True
        return False
    def addChild(self, child):
        """
        Add a child to the container. Returns the result of the
        delegation.

        Do not call this, call child.setParent (self) instead
        """
        self.debug ('%s is adding %s' % (self, child))
        if child.getParent() is not None:
            raise CompositionError, _("Child is already parented")
        if self.delegate('will_add_child', args=child):
            super(CompositeResponder, self).addChild(child)
            if hasattr (self, '_doAddChild'):
                try:
                    self._doAddChild(child)
                except:
                    # failed, undo
                    super(CompositeResponder, self).removeChild(child)
                    raise
            return True
        return False
예제 #10
0
    def busy(self):
        """
        Make the widget look `busy'.

        This is different from `disabled': the user can still interact
        (unless the widget is also disabled). The idea is to give some
        feedback because, for example, stuff is still changeing.

        Some widgets might not support this.
        
        Returns the result of the delegation (i.e., True if delegates
        agreed to doing it). Raises a ViewError if anything bad
        happens.
        """
        if self.delegate('will_busy'):
            try:
                self._doBusy()
            except:
                raise ViewError, _("Unable to busy")
            return True
        return False
예제 #11
0
    def setSizeRequest(self, *sizes):
        """
        Request for a specific size (in pixels) of the widget.

        Argument is a 2-tuple of (int or None)s, or two (int or
        None)s. If int, set requested size; if None, unset.

        Returns the result of the delegation (i.e., True if delegates
        agreed to doing it). Raises a ViewError if anything bad
        happens.
        """
        try:
            x, y = sizes
        except ValueError:
            x, y = sizes[0]
        if self.delegate('will_resize', args=(x, y)):
            try:
                self._doSetSizeRequest(x, y)
            except:
                raise ViewError, _("Unable to set size request")
            return True
        return False