예제 #1
0
class Picker(Gtk.Grid):

    def __init__(self, icon, label):
        Gtk.Grid.__init__(self)

        self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
                                 icon_name=icon)
        self.attach(self._button, 0, 0, 1, 1)
        self._button.hide()

        self._label = Gtk.Label(label.replace(' ', '\n'))
        self._label.props.justify = Gtk.Justification.CENTER
        self.attach(self._label, 0, 1, 1, 1)
        self._label.hide()

    def show_all(self):
        self._button.show()
        self._label.show()
        self.show()

    def hide_all(self):
        self._button.hide()
        self._label.hide()
        self.hide()

    def connect(self, callback, arg):
        self._button.connect('activate', callback, arg)

    def set_color(self, color):
        self._button.xo_color = color

    def set_icon(self, icon):
        self._button.set_icon_name(icon)
예제 #2
0
class Picker(Gtk.Grid):

    def __init__(self, icon, label):
        Gtk.Grid.__init__(self)

        self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
                                 icon_name=icon)
        self.attach(self._button, 0, 0, 1, 1)
        self._button.hide()

        self._label = Gtk.Label(label)
        self.attach(self._label, 0, 1, 1, 1)
        self._label.hide()

    def show_all(self):
        self._button.show()
        self._label.show()
        self.show()

    def hide_all(self):
        self._button.hide()
        self._label.hide()
        self.hide()

    def connect(self, callback, arg):
        self._button.connect('button-press-event', callback, arg)

    def set_color(self, color):
        self._button.xo_color = color

    def set_icon(self, icon):
        self._button.set_icon_name(icon)
예제 #3
0
class Picker(Gtk.Grid):
    def __init__(self, icon, label):
        Gtk.Grid.__init__(self)

        self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
                                 icon_name=icon)
        self.attach(self._button, 0, 0, 1, 1)
        self._button.hide()

        self._label = Gtk.Label(label)
        self.attach(self._label, 0, 1, 1, 1)
        self._label.hide()

    def show_all(self):
        self._button.show()
        self._label.show()
        self.show()

    def hide_all(self):
        self._button.hide()
        self._label.hide()
        self.hide()

    def connect(self, callback, arg):
        self._button.connect('button-press-event', callback, arg)

    def set_color(self, color):
        self._button.xo_color = color

    def set_icon(self, icon):
        self._button.set_icon_name(icon)
예제 #4
0
파일: view.py 프로젝트: Akirato/sugar
class AgePicker(Gtk.Grid):

    age_changed_signal = GObject.Signal('age-changed',
                                        arg_types=([int]))

    def __init__(self, color, gender, age):
        Gtk.Grid.__init__(self)
        self._color = color
        self._gender = gender
        self._age = age

        if self._gender is '':
            # Used for graphic only; does not set user's gender preference.
            self._gender = 'female'

        self._icon = EventIcon(icon_name='%s-%d' % (self._gender, self._age),
                               pixel_size=style.LARGE_ICON_SIZE)
        self._icon.connect('button-press-event', self.__pressed_cb)
        self.attach(self._icon, 0, 0, 1, 1)
        self._icon.show()

        label = Gtk.Label()
        label.set_text(AGE_LABELS[self._age])
        self.attach(label, 0, 1, 1, 1)
        label.show()

        self.set_age()

    def set_color(self, color, age):
        self._color = color
        self.set_age(age)

    def set_age(self, age=None):
        if age in AGES:
            age_index = AGES.index(age)
        else:
            age_index = None

        if age_index == self._age:
            self._icon.props.xo_color = self._color
        else:
            self._icon.props.xo_color = _NOCOLOR
        self._icon.show()

    age = GObject.property(type=object, setter=set_age)

    def set_gender(self, gender):
        self._icon.set_icon_name('%s-%d' % (gender, self._age))
        self._icon.show()

    gender = GObject.property(type=object, setter=set_gender)

    def __pressed_cb(self, button, event):
        self.age_changed_signal.emit(self._age)
예제 #5
0
파일: view.py 프로젝트: Anubhav-J/sugar
class AgePicker(Gtk.Grid):

    age_changed_signal = GObject.Signal('age-changed',
                                        arg_types=([int]))

    def __init__(self, color, gender, age):
        Gtk.Grid.__init__(self)
        self._color = color
        self._gender = gender
        self._age = age

        if self._gender is '':
            # Used for graphic only; does not set user's gender preference.
            self._gender = 'female'

        self._icon = EventIcon(icon_name='%s-%d' % (self._gender, self._age),
                               pixel_size=style.LARGE_ICON_SIZE)
        self._icon.connect('button-press-event', self.__pressed_cb)
        self.attach(self._icon, 0, 0, 1, 1)
        self._icon.show()

        label = Gtk.Label()
        label.set_text(AGE_LABELS[self._age])
        self.attach(label, 0, 1, 1, 1)
        label.show()

        self.set_age()

    def set_color(self, color, age):
        self._color = color
        self.set_age(age)

    def set_age(self, age=None):
        if age in AGES:
            age_index = AGES.index(age)
        else:
            age_index = None

        if age_index == self._age:
            self._icon.props.xo_color = self._color
        else:
            self._icon.props.xo_color = _NOCOLOR
        self._icon.show()

    age = GObject.property(type=object, setter=set_age)

    def set_gender(self, gender):
        self._icon.set_icon_name('%s-%d' % (gender, self._age))
        self._icon.show()

    gender = GObject.property(type=object, setter=set_gender)

    def __pressed_cb(self, button, event):
        self.age_changed_signal.emit(self._age)