Esempio n. 1
0
 def setLabel(self, label):
     """
     Sets the text within the Label widget.
     """
     if self.delegate('will_set_label', args=label):
         try:
             self._doSetLabel(unicode(label))
         except:
             raise LabelError, _("Unable to set label")
         return True
     return False
Esempio n. 2
0
 def setLineWrap(self, wrap):
     if self.delegate('will_set_line_wrap', args=wrap):
         try:
             self._doSetLineWrap(wrap)
         except:
             if wrap:
                 raise LabelError, _("Unable to wrap lines")
             else:
                 raise LabelError, _("Unable to stop wrapping lines")
         return True
     return False
Esempio n. 3
0
    def setFromFile(self, filename):
        """

        Creates a new Image displaying the file filename. If the file
        isn't found or can't be loaded, the resulting Image will
        display a "broken image" icon.

        If the file contains an animation, the image will contain an
        animation.
        """
        if self.delegate('will_set_from_file', args=filename):
            try:
                self._doSetFromFile(filename)
            except:
                raise ImageError, _("Unable to build image from file")
            return True
        return False
Esempio n. 4
0
    def setFromFile(self, filename):
        """

        Creates a new Image displaying the file filename. If the file
        isn't found or can't be loaded, the resulting Image will
        display a "broken image" icon.

        If the file contains an animation, the image will contain an
        animation.
        """
        if self.delegate('will_set_from_file', args=filename):
            try:
                self._doSetFromFile(filename)
            except:
                raise ImageError, _("Unable to build image from file")
            return True
        return False
Esempio n. 5
0
    def setUseMarkup(self, use):
        """
        Sets whether the text of the label contains markup in Pango's
        text markup language.

        Takes one argument, a bool.
        """
        if self.delegate('will_use_markup', args=use):
            try:
                self._doSetUseMarkup(use)
            except:
                if use:
                    raise LabelError, _("Unable to use markup")
                else:
                    raise LabelError, _("Unable to stop using markup")
            return True
        return False
Esempio n. 6
0
    def setSelectable(self, selectable):
        """
        Selectable labels allow the user to select text from the
        label, for copy-and-paste.

        Takes one argument, a bool.

        """
        if self.delegate('will_set_selectable', args=selectable):
            try:
                self._doSetSelectable(selectable)
            except:
                if selectable:
                    raise LabelError, _("Unable to make text selectable")
                else:
                    raise LabelError, _("Unable to make text unselectable")
            return True
        return False
Esempio n. 7
0
    def setJustify(self, justify):
        """
        justify is one of 'left', 'right', 'center', 'fill', or None.

        Sets the alignment of the lines in the text of the label
        relative to each other. Left is the default value when the
        widget is first created. If you instead want to set the
        alignment of the label as a whole, use setAlignment()
        instead. setJustify() has no effect on labels containing only
        a single line.

        """
        if self.delegate('will_justify', args=justify):
            try:
                self._doSetJustify(justify)
            except:
                raise LabelError, _("Unable to set justification")
            return True
        return False
Esempio n. 8
0
    def setUseUnderline(self, use):
        """
        Sets whether an underline in the text indicates the next
        character should be used for the mnemonic accelerator key.

        Takes one argument, a bool.
        """
        if self.delegate('will_use_underline', args=use):
            try:
                self._doSetUseUnderline(use)
            except:
                if use:
                    raise LabelError, \
                          _("Unable to use underlines for mnemonics")
                else:
                    raise LabelError, \
                          _("Unable to stop using underlines for mnemonics")
            return True
        return False
Esempio n. 9
0
    def setFromStock(self, *stck):
        """

        Creates a GtkImage displaying a stock icon. Sample stock icon
        names are 'open', 'exit'. Sample stock sizes are 'menu',
        'toolbar'. If the stock icon name isn't known, a "broken
        image" icon will be displayed instead.

        """
        try:
            stock, size = stck
        except ValueError:
            stock, size = stck[0]
        if self.delegate('will_set_from_stock', args=(stock, size)):
            try:
                self._doSetFromStock(stock, size)
            except:
                raise ImageError, _("Unable to build stock image")
            return True
        return False
Esempio n. 10
0
    def setFromStock(self, *stck):
        """

        Creates a GtkImage displaying a stock icon. Sample stock icon
        names are 'open', 'exit'. Sample stock sizes are 'menu',
        'toolbar'. If the stock icon name isn't known, a "broken
        image" icon will be displayed instead.

        """
        try:
            stock, size = stck
        except ValueError:
            stock, size = stck[0]
        if self.delegate('will_set_from_stock', args=(stock, size)):
            try:
                self._doSetFromStock(stock, size)
            except:
                raise ImageError, _("Unable to build stock image")
            return True
        return False
Esempio n. 11
0
    def setMnemonicWidget(self, widget):
        """

        If the label has been set so that it has an mnemonic key
        (using use_underline()) the label can be associated with a
        widget that is the target of the mnemonic. When the label is
        inside a widget (like a Button or a Notebook tab) it is
        automatically associated with the correct widget, but
        sometimes (i.e. when the target is a Entry next to the label)
        you need to set it explicitly using this function.

        The target widget will be accelerated by emitting
        "mnemonic_activate" on it. The default handler for this signal
        will activate the widget if there are no mnemonic collisions
        and toggle focus between the colliding widgets otherwise.
        
        """
        if self.delegate('will_set_mnemonic_widget', args=widget):
            try:
                self._doSetMnemonicWidget(widget)
            except:
                raise LabelError, _("Unable to set mnemonic widget")
            return True
        return False