Example #1
0
    def check_click(self):
        self.check_for_press()
        t = core.time()

        if self.frame.collidepoint(key.x_mouse, key.y_mouse):
            if key.mouse_buttons_down[0]:
                self.__color_main = core.Var.THEME_DOWN
            else:
                self.__color_main = core.Var.THEME_HOVER
            if self.mouse_pressed_on_this and key.mouse_buttons_released[0]:
                self.__change_value = True
                self.__c = core.Var.counter
        else:
            if key.mouse_buttons_pressed[0]:
                self.__change_value = False
            self.__color_main = core.Var.THEME_DEFAULT
        if self.__change_value:
            if t - self.__previous_blink > self.__blink_time:
                self.__previous_blink = t
                self.__blink = not self.__blink
            for i in core.Inputhandler.all_events:
                if i.type == core.p.KEYDOWN:
                    if i.key == core.p.K_BACKSPACE:
                        self.value = self.value[:-1]
                    elif i.key == core.p.K_RETURN:
                        self.command()
                    elif i.key <= 127 and core.Var.font_tiny.size(self.value)[0] <= self.width*.93:
                        if core.p.key.get_mods() & core.p.KMOD_SHIFT:
                            self.value += chr(i.key).upper()
                        else:
                            self.value += chr(i.key)
            self.change_value()
        else:
            self.__blink = False
        self.check_for_release()
Example #2
0
 def feed(this,
          start=time(),
          end=None,
          step=time(minutes=1),
          span=None,
          tell=True):
     within = span
     if not within:
         at, end = this.time
         within = end - at - step
     while start < within:
         try:
             yield this.load(start=start, time=step)
         except:
             if tell: print 'broken stream at {}!'.format(start)
             yield None
Example #3
0
 def __init__(self, x, y, width, command, text, maxlen):
     Widget.__init__(self, x, y, width, core.dpp(Widget.def_height), command, text)
     self.value = ""
     self.__img_value = core.Var.font_tiny.render(self.value, True, core.Var.BLACK)
     self.__frame_value = self.__img_value.get_rect()
     self.__frame_value.midleft = self.frame.midleft
     self.__color_main = core.Var.THEME_DEFAULT
     self.__blink_time = 0.8
     self.__previous_blink = core.time()
     self.__blink = False
     self.__change_value = False
     self.__c = 0
     self.maxlen = maxlen