Exemplo n.º 1
0
    def __init__(self, text=None, menu=None):
        """
        Create a new hyperlink.

        @param text: The text of the hyperlink.
        @type text: str
        """
        gtk.EventBox.__init__(self)
        PropertyObject.__init__(self)
        self._gproperties = {}
        if text is not None:
            self.set_property('text', text)
        self._is_active = False
        self._is_hover = False
        self._menu = menu
        self._label = gtk.Label()
        self.add(self._label)
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                        gtk.gdk.BUTTON_RELEASE_MASK |
                        gtk.gdk.ENTER_NOTIFY_MASK |
                        gtk.gdk.LEAVE_NOTIFY_MASK)
        self.connect('button-press-event', self._on_button_press_event)
        self.connect('button-release-event', self._on_button_release_event)
        self.connect('enter-notify-event', self._on_hover_changed, True)
        self.connect('leave-notify-event', self._on_hover_changed, False)
        self.connect('map-event', self._on_map_event)
        self.connect('notify', self._on_notify)
        self.set_text(text)
Exemplo n.º 2
0
    def __init__(self, **kwargs):
        deprecationwarn(
            'ProxyComboBoxEntry is deprecated, use ProxyComboEntry instead',
            stacklevel=3)

        BaseComboBoxEntry.__init__(self)
        ValidatableProxyWidgetMixin.__init__(self, widget=self.entry)

        # We need to create the helper before PropertyObject, since we
        # need to access the helper in prop_set_list_editable, which
        # PropertyObject might call
        self._helper = _EasyComboBoxHelper(self)
        PropertyObject.__init__(self, **kwargs)

        self.set_text_column(ComboColumn.LABEL)

        # here we connect the expose-event signal directly to the entry
        self.child.connect('changed', self._on_child_entry__changed)

        # HACK! we force a queue_draw because when the window is first
        # displayed the icon is not drawn.
        gobject.idle_add(self.queue_draw)

        self.set_events(gtk.gdk.KEY_RELEASE_MASK)
        self.connect("key-release-event", self._on__key_release_event)
Exemplo n.º 3
0
    def __init__(self, text=None, menu=None):
        """
        Create a new hyperlink.

        @param text: The text of the hyperlink.
        @type text: str
        """
        gtk.EventBox.__init__(self)
        self.set_above_child(False)
        self.set_visible_window(False)
        PropertyObject.__init__(self)
        self._gproperties = {}
        if text is not None:
            self.set_property('text', text)
        self._is_active = False
        self._is_hover = False
        self._menu = menu
        self._label = gtk.Label()
        self.add(self._label)
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                        gtk.gdk.BUTTON_RELEASE_MASK |
                        gtk.gdk.ENTER_NOTIFY_MASK |
                        gtk.gdk.LEAVE_NOTIFY_MASK)
        self.connect('button-press-event', self._on_button_press_event)
        self.connect('button-release-event', self._on_button_release_event)
        self.connect('enter-notify-event', self._on_hover_changed, True)
        self.connect('leave-notify-event', self._on_hover_changed, False)
        self.connect('map-event', self._on_map_event)
        self.connect('notify', self._on_notify)
        self.set_text(text)
Exemplo n.º 4
0
 def __init__(self, data_type=int):
     # since the default data_type is str we need to set it to int
     # or float for spinbuttons
     gtk.SpinButton.__init__(self)
     PropertyObject.__init__(self, data_type=data_type)
     ValidatableProxyWidgetMixin.__init__(self)
     self._icon = IconEntry(self)
     self.set_property('xalign', 1.0)
Exemplo n.º 5
0
 def __init__(self):
     gtk.ComboBox.__init__(self)
     ProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self)
     self._helper = _EasyComboBoxHelper(self)
     self.connect('changed', self._on__changed)
     renderer = gtk.CellRendererText()
     self.pack_start(renderer)
     self.add_attribute(renderer, 'text', ComboColumn.LABEL)
Exemplo n.º 6
0
 def __init__(self, action=gtk.FILE_CHOOSER_ACTION_OPEN, backend=None):
     """
     Create a new ProxyFileChooserWidget object.
     @param action:
     @param backend:
     """
     ProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self, data_type=str)
     gtk.FileChooserWidget.__init__(self, action=action, backend=backend)
Exemplo n.º 7
0
    def __init__(self):
        self._is_unset = True
        gtk.TextView.__init__(self)
        PropertyObject.__init__(self, data_type=str)
        ValidatableProxyWidgetMixin.__init__(self)

        self._textbuffer = gtk.TextBuffer()
        self._textbuffer.connect('changed',
                                 self._on_textbuffer__changed)
        self.set_buffer(self._textbuffer)
Exemplo n.º 8
0
    def __init__(self, name=None, **kwargs):
        gtk.DrawingArea.__init__(self)
        PropertyObject.__init__(self, **kwargs)
        self.connect('notify::string1', lambda self, *a: self.queue_draw())

        if name:
            self.set_name(name)

        self._layout = self.create_pango_layout("")
        self._layout.set_font_description(
            pango.FontDescription("sans serif 12"))
        self._pixmap = None

        self.set_flags(self.flags() | gtk.CAN_FOCUS)
Exemplo n.º 9
0
    def __init__(self, title=None, backend=None, dialog=None):
        """
        Create a new ProxyFileChooserButton object.
        @param title:
        @param backend:
        @param dialog:
        """
        ProxyWidgetMixin.__init__(self)
        PropertyObject.__init__(self, data_type=str)

        # Broken, Broken PyGTK
        if isinstance(title, str):
            gtk.FileChooserButton.__init__(self, title, backend)
        else:
            gtk.FileChooserButton.__init__(self, dialog or title)
Exemplo n.º 10
0
Arquivo: entry.py Projeto: Schevo/kiwi
    def __init__(self):
        self._completion = None

        gtk.Entry.__init__(self)
        PropertyObject.__init__(self)

        self.connect('insert-text', self._on_insert_text)
        self.connect('delete-text', self._on_delete_text)
        self.connect_after('grab-focus', self._after_grab_focus)

        self.connect('changed', self._on_changed)

        self.connect('focus', self._on_focus)
        self.connect('focus-out-event', self._on_focus_out_event)
        self.connect('move-cursor', self._on_move_cursor)

        # Ideally, this should be connected to notify::cursor-position, but
        # there seems to be a bug in gtk that the notification is not emited
        # when it should.
        # TODO: investigate that and report a bug.
        self.connect('notify::selection-bound',
                     self._on_notify_selection_bound)

        self._block_changed = False

        self._current_object = None
        self._mode = ENTRY_MODE_TEXT
        self._icon = IconEntry(self)

        # List of validators
        #  str -> static characters
        #  int -> dynamic, according to constants above
        self._mask_validators = []
        self._mask = None
        # Fields defined by mask
        # each item is a tuble, containing the begining and the end of the
        # field in the text
        self._mask_fields = []
        self._current_field = -1
        self._pos = 0
        self._selecting = False

        self._block_insert = False
        self._block_delete = False
Exemplo n.º 11
0
Arquivo: entry.py Projeto: Schevo/kiwi
    def __init__(self):
        DateEntry.__init__(self)
        ValidatableProxyWidgetMixin.__init__(self)
        PropertyObject.__init__(self)

        # Add some space to the entry, so it has rom for the icon, in case
        # of a validation error.
        #
        # Since we set the widget's width based on the number of characters,
        # get the width of a single char, so we can calculate how many
        # 'chars' the icon takes.
        layout = self.entry.get_layout()
        context = layout.get_context()
        metrics = context.get_metrics(context.get_font_description())
        char_width =  metrics.get_approximate_char_width() / pango.SCALE
        current_width = self.entry.get_width_chars()

        # We add 4 pixels to the width, because of the icon borders
        icon_width = VALIDATION_ICON_WIDTH + 4
        self.entry.set_width_chars(current_width
                                   + int(icon_width / char_width))
Exemplo n.º 12
0
Arquivo: label.py Projeto: Schevo/kiwi
    def __init__(self, label='', data_type=None):
        """
        Create a new ProxyLabel object.
        @param label: initial text
        @param data_type: data type of label
        """
        gtk.Label.__init__(self, label)
        PropertyObject.__init__(self, data_type=data_type)
        ProxyWidgetMixin.__init__(self)
        self.set_use_markup(True)
        self._attr_dic = { "style": None,
                           "weight": None,
                           "size": None,
                           "underline": None}
        self._size_list = ('xx-small', 'x-small',
                           'small', 'medium',
                           'large', 'x-large',
                           'xx-large')

        self.connect("notify::label", self._on_label_changed)
        self._block_notify_label = False
Exemplo n.º 13
0
 def __init__(self, **kwargs):
     gobject.GObject.__init__(self)
     PropertyObject.__init__(self, **kwargs)
Exemplo n.º 14
0
 def __init__(self):
     entry = ProxyEntry()
     ComboEntry.__init__(self, entry=entry)
     ValidatableProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self)
     entry.connect('content-changed', self._on_entry__content_changed)
Exemplo n.º 15
0
 def __init__(self, color=gtk.gdk.Color(0, 0, 0)):
     ProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self, data_type=str)
     gtk.ColorButton.__init__(self, color)
Exemplo n.º 16
0
 def __init__(self, fontname=None):
     ProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self, data_type=str)
     gtk.FontButton.__init__(self, fontname)
Exemplo n.º 17
0
 def __init__(self):
     ProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self, data_type=str)
     gtk.Button.__init__(self)
Exemplo n.º 18
0
 def __init__(self, label=None, use_underline=True):
     ProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self, data_type=bool)
     gtk.CheckButton.__init__(self, label=label,
                              use_underline=use_underline)
Exemplo n.º 19
0
Arquivo: scale.py Projeto: Schevo/kiwi
 def __init__(self):
     ProxyWidgetMixin.__init__(self)
     PropertyObject.__init__(self, data_type=float)
     gtk.VScale.__init__(self)