def _reaction_press(self, event):
     hit_lift = False
     if self._ddlf._lift:
         if self._ddlf._lift.get_fus_rect().collidepoint(event.pos):
             hit_lift = True
     if not hit_lift:
         BrowserLight._reaction_press(self, event)
         selected = self.get_value()
         tick = pygame.time.get_ticks()
         if os.path.isdir(selected):
             if tick - self._last_click < parameters.DOUBLE_CLICK_DELAY:
                 self._go_to_dir(selected)
         self._last_click = tick
Ejemplo n.º 2
0
 def _reaction_press(self, event):
     hit_lift = False
     if self._ddlf._lift:
         if self._ddlf._lift.get_fus_rect().collidepoint(event.pos):
             hit_lift = True
     if not hit_lift:
         BrowserLight._reaction_press(self, event)
         selected = self.get_value()
         tick = pygame.time.get_ticks()
         if os.path.isdir(selected):
             if tick - self._last_click < parameters.DOUBLE_CLICK_DELAY:
                 self._go_to_dir(selected)
         self._last_click = tick
Ejemplo n.º 3
0
def get_handler_for(variable):
    typ = type(variable.value)
    value = variable.value
    text = variable.text
    limits = variable.limits
    handler_type = variable.handler_type
    handler = None
    if handler_type:
        if handler_type == "color_choice":
            handler = ColorSetter(text=text, value=value)
        elif handler_type == "file_choice":
            limits.setdefault("launcher", False)
            limits.setdefault("light", True)
            limits.setdefault("ddl_size", None)
            limits.setdefault("folders", True)
            limits.setdefault("file_types", None)
            limits.setdefault("files", True)
            if limits["light"]:
                handler = BrowserLight(text=text,
                                       path=value,
                                       ddl_size=limits["ddl_size"],
                                       folders=limits["folders"],
                                       files=limits["files"],
                                       file_types=limits["file_types"])
            else:
                handler = Browser(text=text,
                                  path=value,
                                  ddl_size=limits["ddl_size"],
                                  folders=limits["folders"],
                                  files=limits["files"],
                                  file_types=limits["file_types"])
        else:
            handler = obtain_valid_object(handler_type,
                                          value=value,
                                          typ=typ,
                                          text=text,
                                          limits=limits)
    elif typ is tuple:
        if len(value) == 3:
            handler = ColorSetter(text=text, value=value)
    elif (typ is str) or not (limits):
        handler = Inserter(text, value=str(value), value_type=typ)
    elif (typ is int) or (typ is float):
        handler = SliderXSetter(100,
                                limits,
                                text,
                                typ=typ,
                                initial_value=value)
    elif typ is bool:
        handler = Checker(variable.text,
                          value=variable.value,
                          checked=variable.value)
    if handler:
        handler.rank = variable.rank
        return handler
    else:
        raise Exception("Variable doesn't have default handler: " +
                        str(varname))
Ejemplo n.º 4
0
def get_handler_for(variable):
    type_ = type(variable.value)
    value = variable.value
    text = variable.text
    limits = variable.limits
    handler_type = variable.handler_type
    more = variable.more
    handler = None
    if handler_type:
        if handler_type == "color choice":
##            cs = ColorSetter(text=text, value=value)
            handler = ColorSetterLauncher(value, text)
        elif handler_type == "file choice":
            limits.setdefault("launcher", False)
            limits.setdefault("light", True)
            limits.setdefault("ddl_size", None)
            limits.setdefault("folders", True)
            limits.setdefault("file_types", None)
            limits.setdefault("files", True)
            if limits["light"]:
                handler = BrowserLight(text=text, path=value,
                                     ddl_size=limits["ddl_size"],
                                     folders=limits["folders"],
                                     files=limits["files"],
                                     file_types=limits["file_types"])
            else:
                handler = Browser(text=text, path=value,
                                 ddl_size=limits["ddl_size"],
                                 folders=limits["folders"],
                                 files=limits["files"],
                                 file_types=limits["file_types"])
        else:
            handler = obtain_valid_object(handler_type, value=value, type_=type_,
                                          text=text, limits=limits)
    elif type_ is tuple:
        if len(value) == 3:
##            handler = ColorSetter(text=text, value=value)
            handler = ColorSetterLauncher(value, text, finish=False)
    elif type_ is list:
        var_text = more.get("var_text", value[0])
        ddlf_size = more.get("ddlf_size", "auto")
        handler = DropDownListLauncher(const_text=text, var_text=var_text,
                                        titles=value, ddlf_size=ddlf_size,
                                        finish=False)
    elif ((type_ is str) or not(limits)) and not(type_ is bool):
        if not(limits) or isinstance(limits,str):
            ilimits = (None, None)
        else:
            ilimits = limits
        handler = Inserter(text, value=str(value), value_type=type_,
                            size=ilimits, finish=False)
        if limits == "float":
            handler.numeric_only = True
            handler.int_only = False
            handler._value_type = float
        elif limits == "int":
            handler.numeric_only = True
            handler.int_only = True
            handler._value_type = int
    elif (type_ is int) or (type_ is float):
        length = more.get("length", 100)
        handler = SliderXSetter(length,
                                limits,
                                text,
                                type_=type_,
                                initial_value=value,
                                finish=False)
    elif type_ is bool:
        handler = Checker(variable.text, value=variable.value, finish=False)
    if handler:
        handler.rank = variable.rank
        return handler
    else:
        raise Exception(
            "Variable doesn't have default handler: " +
            str(text))