示例#1
0
    def __setattr__(self, name, val):
        if name == "label":
            name = "text"
        Label.__setattr__(self, name, val)

        if name == "focused" and val == False:
            self.times_clicked = 0
示例#2
0
 def __init__(self):
     from ui.widgets import Label # unfortunately otherwise we run into a circular dependency
     self.label = Label(size=self.size,
                        font_desc=self.font_desc,
                        padding=self.padding,
                        background_color=self.background_color,
                        color=self.color)
示例#3
0
    def __init__(self, label = "", bevel = True, repeat_down_delay = 0, pressed_offset = 1,**kwargs):
        Label.__init__(self, **kwargs)
        self.interactive, self.can_focus = True, True

        #: current state
        self.state = "normal"

        #: label
        self.label = label

        #: if set, will repeat the on-mouse-down signal every specified miliseconds while the button is pressed
        #: when setting: 100 is a good initial value
        self.repeat_down_delay = repeat_down_delay

        #: draw border
        self.bevel = bevel

        #: by how many pixels should the label move towards bottom right when pressed
        #: defaults to 1
        self.pressed_offset = pressed_offset


        #: a rather curious figure telling how many times the button has been
        #: pressed since gaining focus. resets on losing the focus
        self.times_clicked = 0

        self.colors = {
            # fill, fill, stroke, outer stroke
            "normal": ("#fcfcfc", "#efefef", "#dedcda", "#918e8c"),
            "highlight": ("#fff", "#f4f3f2", "#dedcda", "#918e8c"),
            "pressed": ("#cfd1d3", "#b9bbc0", "#e0dedd", "#5b7aa1"),
            "focused": ("#fcfcfc", "#efefef", "#52749e", "#89adda")
        }

        self.connect("on-mouse-over", self.__on_mouse_over)
        self.connect("on-mouse-out", self.__on_mouse_out)
        self.connect("on-mouse-down", self.__on_mouse_down)
        self.connect("on-render", self.__on_render)

        self._pressed = False
        self._scene_mouse_up = None

        self._timeout = None