def _setup(self, height=None, dragsize=None):
     height = style.SLIDER_THICK if height is None else height
     dragsize = style.SLIDERX_DRAG_SIZE if dragsize is None else dragsize
     self._height = height
     size = (self._length + dragsize[0] + style.SLIDER_MARGINS[0], height)
     painter = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         pressed=True,
         color=style.DEF_COLOR2,
         size=size)
     self.set_painter(painter)
     dp = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         pressed=False,
         size=dragsize)
     try:
         drag_x = self.val_to_pix(self.initial_value,
                                  self.get_fus_topleft()[0]) + 1
         self._drag_element.change_painter(dp, autopress=False)
         self._drag_element.set_center((drag_x, self.get_fus_center()[1]))
     except AttributeError:
         drag_x = self.val_to_pix(self.initial_value,
                                  self.get_ghost_topleft()[0]) + 1
         self._drag_element.set_painter(dp, autopress=False)
         self._drag_element.set_center((drag_x, self.get_ghost_center()[1]))
     self._drag_element.set_free(y=False)
     self.englobe_childrens()
Exemple #2
0
 def _setup(self, height=None, dragsize=None):
     height = style.SLIDER_THICK if height is None else height
     dragsize = style.SLIDERX_DRAG_SIZE if dragsize is None else dragsize
     self._height = height
     size = (self._length + dragsize[0] + style.SLIDER_MARGINS[0], height)
     painter = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         pressed=True,
         color=style.DEF_COLOR2,
         size=size)
     self.set_painter(painter)
     dp = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         pressed=False,
         size=dragsize)
     try:
         drag_x = self.val_to_pix(self.initial_value,
                                  self.get_fus_topleft()[0]) + 1
         self._drag_element.change_painter(dp, autopress=False)
         self._drag_element.set_center((drag_x, self.get_fus_center()[1]))
     except AttributeError:
         drag_x = self.val_to_pix(self.initial_value,
                                  self.get_ghost_topleft()[0]) + 1
         self._drag_element.set_painter(dp, autopress=False)
         self._drag_element.set_center((drag_x, self.get_ghost_center()[1]))
     self._drag_element.set_free(y=False)
     Ghost.fit_children(self)
 def _gen_painter(self):
     if self._type == "checkbox":
         return functions.obtain_valid_painter(
             painterstyle.CHECKBOX_PAINTER,
             color=style.DEF_COLOR2,
             size=style.CHECK_SIZE,
             pressed=True)
     elif self._type == "radio":
         return functions.obtain_valid_painter(
             painterstyle.RADIO_PAINTER,
             size=style.CHECK_SIZE, pressed=True)
Exemple #4
0
 def _gen_painter(self):
     if self._type == "checkbox":
         return functions.obtain_valid_painter(
             painterstyle.CHECKBOX_PAINTER,
             color=style.DEF_COLOR2,
             size=style.CHECK_SIZE,
             pressed=True)
     elif self._type == "radio":
         return functions.obtain_valid_painter(painterstyle.RADIO_PAINTER,
                                               size=style.CHECK_SIZE,
                                               pressed=True)
Exemple #5
0
 def __init__(self,
              path="./",
              ddl_size=None,
              normal_params=None,
              folders=True,
              files=True,
              file_types=None,
              text=""):
     """File and folder browser.
     <path>: the path of the folder in which browser browse files.
     <ddl_size>: if not None, force the size of the dropdown list of files.
     <folders>: if True, displays folders to user.
     <files>: if True, displays file to user.
     <file_types>: if not None, pass a list of files formats that you wand to
         be valid for user choice.
     <text>: title text of the browser.
     """
     ddl_size = style.BROWSERLIGHT_DDL_SIZE if ddl_size is None else ddl_size
     super(BrowserLight, self).__init__(normal_params=normal_params)
     self.path = path
     self._ddl_size = ddl_size
     if not hasattr(file_types, "__iter__") and file_types is not None:
         raise ValueError("Files types must be a sequence.")
     self.file_types = file_types
     # DropDownListFast
     actual_folders, actual_files = self._get_folders_and_files()
     actual_files = self._filter_files(actual_files)
     if not folders:
         actual_folders = None
     if not files:
         actual_files = []
     self._ddlf = DropDownListFast(size=self._ddl_size,
                                   titles=actual_files,
                                   folders=actual_folders)
     # selection button
     inserter_width = 3 * ddl_size[0] // 4
     ##        if inserter_width > style.MAX_INSERTER_WIDTH:
     ##            inserter_width = style.MAX_INSERTER_WIDTH
     self._selected = Inserter("Selected : ", size=(inserter_width, None))
     self._selected.finish()
     if isinstance(text, str):
         self.text_element = OneLineText(text)
         self.text_element.finish()
     else:
         self.text_element = text
     self.add_elements([self.text_element, self._ddlf, self._selected])
     reac_pressed = Reaction(parameters.BUTTON_UNPRESS_EVENT,
                             self._reaction_press,
                             reac_name=constants.REAC_PRESSED)
     self._ddlf.finish()
     self.add_reaction(reac_pressed)
     self._clicked = None
     self._something_selected = False
     painter = functions.obtain_valid_painter(
         painterstyle.BOX_PAINTER,
         pressed=True,
         ##                                                 color=style.DEF_COLOR2,
         radius=style.BOX_RADIUS)
     self.set_painter(painter)
     self._refresh_ddlf_lift()
Exemple #6
0
    def __init__(self,
                 size,
                 titles,
                 elements=None,
                 normal_params=None,
                 heavy=False,
                 folders=None,
                 margins=None,
                 has_lift=True):
        margins = style.DDL_MARGINS if margins is None else margins
        self._clicked = None
        Element.__init__(self, elements=elements, normal_params=normal_params)
        painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                                 pressed=True,
##                                                 color=style.DEF_COLOR2,
                                                 size=size,
                                                 radius=style.BOX_RADIUS)
        self.set_painter(painter)
        self._margins = margins
        self._heavy = heavy
        self._dv = self._get_dirviewer(titles, size, folders)
        reac_motion= Reaction(MOUSEMOTION,
                              self._reaction_motion,
                              reac_name=constants.REAC_MOTION)
        self.add_reaction(reac_motion)
        self._cursor_pos = (-1, -1)
        self._has_lift = has_lift
        self._menu = None
        self._set_selecter()
        self._force_lift = False
Exemple #7
0
 def _setup(self, width=style.LIFT_BUTTON_SIZE[0],
           dragsize=style.LIFT_DRAG_SIZE):
     self._drag_element = DraggerLiftY(self)
     self._height = width
     painter = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         pressed=True,
         color=style.DEF_COLOR2,
         size=(
             width,
             self._length +
             dragsize[1] +
             style.LIFT_MARGINS[1] +
             1))
     self.set_painter(painter)
     self._drag_element.set_painter(
         painterstyle.DEF_PAINTER(
             size=dragsize),
         autopress=False)
     try:
         self._drag_element.set_center((self.get_fus_center()[0], None))
     except AttributeError:  # state is ghost state, and has no fusionner
         self._drag_element.set_center((self.get_ghost_center()[0], None))
     self._drag_element.set_free(y=False)
     self.englobe_childrens()
 def _get_name_element(self, name):
     painter = functions.obtain_valid_painter(painterstyle.DEF_PAINTER,
                                              size=style.SIZE)
     el = Clickable(name)
     el.set_painter(painter)
     el.finish()
     return el
 def _get_name_element(self, name):
     painter = functions.obtain_valid_painter(painterstyle.DEF_PAINTER,
                                              size=style.SIZE)
     el = Clickable(name)
     el.set_painter(painter)
     el.finish()
     return el
Exemple #10
0
    def __init__(self,
                 size,
                 titles,
                 elements=None,
                 normal_params=None,
                 heavy=False,
                 folders=None,
                 margins=None,
                 has_lift=True):
        margins = style.DDL_MARGINS if margins is None else margins
        self._clicked = None
        Element.__init__(self, elements=elements, normal_params=normal_params)
        painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                                 pressed=True,
##                                                 color=style.DEF_COLOR2,
                                                 size=size,
                                                 radius=style.BOX_RADIUS)
        self.set_painter(painter)
        self._margins = margins
        self._heavy = heavy
        self._dv = self._get_dirviewer(titles, size, folders)
        reac_motion= Reaction(MOUSEMOTION,
                              self._reaction_motion,
                              name=constants.REAC_MOTION)
        self.add_reaction(reac_motion)
        self._cursor_pos = (-1, -1)
        self._has_lift = has_lift
        self._menu = None
        self._set_selecter()
        self._force_lift = False
Exemple #11
0
 def set_standard_style(self):
     from thorpy.painting.fusionner import _Fusionner
     for e in self.get_elements():
         painter = functions.obtain_valid_painter(painterstyle.BASIC_PAINTER,
                                 size=e.get_fus_rect().size)
         fusionner = _Fusionner(painter, e.get_title())
         e.set_image(fusionner.img)
Exemple #12
0
 def __init__(self,
              elements=None,
              normal_params=None,
              storer_params=None,
              size=None,
              put_lift=True,
              finish=True):
     """Box containing other elements.
     <bartext>: the text of the box bar. If no text, no bar is added.
     <size>: if not None, force the size of the box. Else the box
         automatically fit children."""
     Element.__init__(self, "", elements, normal_params, finish=False)
     self.storer_params = storer_params
     if self.storer_params is None:
         self.storer_params = dict()
     self._size = size
     self._has_lift = False
     self._put_lift = put_lift
     painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                              pressed=True,
                                              size=size,
                                              radius_ext=style.BOX_RADIUS)
     self.set_painter(painter)
     if finish:
         self.finish()
Exemple #13
0
 def set_standard_style(self):
     from thorpy.painting.fusionner import _Fusionner
     for e in self.get_elements():
         painter = functions.obtain_valid_painter(
             painterstyle.BASIC_PAINTER, size=e.get_fus_rect().size)
         fusionner = _Fusionner(painter, e.get_title())
         e.set_image(fusionner.img)
Exemple #14
0
 def _setup(self, width=None, dragsize=None):
     if width is None: width = style.LIFT_BUTTON_SIZE[0]
     if dragsize is None: dragsize = style.LIFT_DRAG_SIZE
     self._drag_element = DraggerLiftY(self)
     self._height = width
     painter = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         pressed=True,
         color=style.DEF_COLOR2,
         size=(
             width,
             self._length +
             dragsize[1] +
             style.LIFT_MARGINS[1] +
             1))
     self.set_painter(painter)
     self._drag_element.set_painter(
         painterstyle.DEF_PAINTER(
             size=dragsize),
         autopress=False)
     try:
         self._drag_element.set_center((self.get_fus_center()[0], None))
     except AttributeError:  # state is ghost state, and has no fusionner
         self._drag_element.set_center((self.get_ghost_center()[0], None))
     self._drag_element.set_free(y=False)
     Ghost.fit_children(self)
 def _get_file_element(self, name):
     painter = functions.obtain_valid_painter(painterstyle.NAME_PAINTER,
                                              size=style.SIZE)
     el = Element(name)
     el.set_painter(painter)
     el.set_style(style.STYLE_NAME)
     el.finish()
     return el
 def _get_file_element(self, name):
     painter = functions.obtain_valid_painter(painterstyle.NAME_PAINTER,
                                              size=style.SIZE)
     el = Element(name)
     el.set_painter(painter)
     el.set_style(style.STYLE_NAME)
     el.finish()
     return el
    def __init__(self,
                 path="./",
                 ddl_size=None,
                 normal_params=None,
                 folders=True,
                 files=True,
                 file_types=None,
                 text=""):
        """File and folder browser.
        <path>: the path of the folder in which browser browse files.
        <ddl_size>: if not None, force the size of the dropdown list of files.
        <folders>: if True, displays folders to user.
        <files>: if True, displays file to user.
        <file_types>: if not None, pass a list of files formats that you wand to
            be valid for user choice.
        <text>: title text of the browser.
        """
        ddl_size = style.BROWSERLIGHT_DDL_SIZE if ddl_size is None else ddl_size
        super(BrowserLight, self).__init__(normal_params=normal_params)
        self.path = path
        self._ddl_size = ddl_size
        if not hasattr(file_types, "__iter__") and file_types is not None:
            raise ValueError("Files types must be a sequence.")
        self.file_types = file_types
        # DropDownListFast
        actual_folders, actual_files = self._get_folders_and_files()
        actual_files = self._filter_files(actual_files)
        if not folders:
            actual_folders = None
        if not files:
            actual_files = []
        self._ddlf = DropDownListFast(size=self._ddl_size, titles=actual_files,
                                      folders=actual_folders)
        # selection button
        inserter_width = 3 * ddl_size[0] // 4
##        if inserter_width > style.MAX_INSERTER_WIDTH:
##            inserter_width = style.MAX_INSERTER_WIDTH
        self._selected = Inserter("Selected : ", size=(inserter_width, None))
        self._selected.finish()
        if isinstance(text, str):
            self.text_element = OneLineText(text)
            self.text_element.finish()
        else:
            self.text_element = text
        self.add_elements([self.text_element, self._ddlf, self._selected])
        reac_pressed = Reaction(parameters.BUTTON_UNPRESS_EVENT,
                                self._reaction_press,
                                reac_name=constants.REAC_PRESSED)
        self._ddlf.finish()
        self.add_reaction(reac_pressed)
        self._clicked = None
        self._something_selected = False
        painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                                 pressed=True,
##                                                 color=style.DEF_COLOR2,
                                                 radius=style.BOX_RADIUS)
        self.set_painter(painter)
        self._refresh_ddlf_lift()
 def get_launcher_element(self, name):
     size = (style.SIZE[0], style.Y_SMALL_SIZE)
     painter = functions.obtain_valid_painter(
         painterstyle.BROWSER_LAUNCHER_PAINTER, size=size)
     el = Clickable(name)
     el.set_painter(painter)
     el.set_style(style.STYLE_BROWSER_LAUNCHER)
     el.finish()
     return el
 def _get_value_element(self, valuestyle):
     painter = functions.obtain_valid_painter(
         painterstyle.CHECKER_VALUE_PAINTER, size=style.CHECK_SIZE)
     el = Element(str(self.get_value()))
     el.set_painter(painter)
     if valuestyle:
         el.set_style(valuestyle)
     el.finish()
     return el
Exemple #20
0
 def _get_name_element(self, name, namestyle):
     painter = functions.obtain_valid_painter(
         painterstyle.INSERTER_NAME_PAINTER, size=style.SIZE)
     el = Clickable(name, finish=False)
     el.set_painter(painter)
     if namestyle:
         el.set_style(namestyle)
     el.finish()
     return el
 def _get_name_element(self, name, namestyle):
     painter = functions.obtain_valid_painter(
         painterstyle.CHECKER_NAME_PAINTER, size=style.SIZE)
     el = Element(name)
     el.set_painter(painter)
     if namestyle:
         el.set_style(namestyle)
     el.finish()
     return el
 def _get_value_element(self, valuestyle):
     painter = functions.obtain_valid_painter(
         painterstyle.CHECKER_VALUE_PAINTER,
         size=style.CHECK_SIZE)
     el = Element(str(self.get_value()))
     el.set_painter(painter)
     if valuestyle:
         el.set_style(valuestyle)
     el.finish()
     return el
 def _get_name_element(self, name, namestyle):
     painter = functions.obtain_valid_painter(
         painterstyle.INSERTER_NAME_PAINTER,
         size=style.SIZE)
     el = Clickable(name)
     el.set_painter(painter)
     if namestyle:
         el.set_style(namestyle)
     el.finish()
     return el
 def get_launcher_element(self, name):
     size = (style.SIZE[0], style.Y_SMALL_SIZE)
     painter = functions.obtain_valid_painter(
         painterstyle.BROWSER_LAUNCHER_PAINTER,
         size=size)
     el = Clickable(name)
     el.set_painter(painter)
     el.set_style(style.STYLE_BROWSER_LAUNCHER)
     el.finish()
     return el
 def __init__(self,
              name="",
              elements=None,
              normal_params=None,
              press_params=None,
              value="",
              size=(None, None),
              namestyle=None,
              varlink_func=None,
              quit_on_click=False,
              value_type=str):
     """<to_set> : either None or a function which must take one argument"""
     namestyle=style.STYLE_INSERTER_NAME if namestyle is None else namestyle
     if size[0] is None:
         s0 = style.SIZE[0]
     else:
         s0 = size[0]
     if size[1] is None:
         s1 = style.Y_SMALL_SIZE
     else:
         s1 = size[1]
     size = (s0, s1)
     self.cursor = None
     super(Inserter, self).__init__("", elements, normal_params,
                                    press_params)
     self._name_element = self._get_name_element(name, namestyle)
     self.add_elements([self._name_element])
     self._iwriter = _InsertWriter(value)
     self._iwriter.finish()
     self.add_elements([self._iwriter])
     self.quit_on_click = quit_on_click
     self._value_type = value_type
     painter = functions.obtain_valid_painter(painterstyle.INSERTER_PAINTER,
                                              color=style.DEF_COLOR2,
                                              pressed=True,
                                              size=(s0,s1))
     self.set_painter(painter)
     self.normal_params.polite_set("states hover",
                                   [constants.STATE_NORMAL,
                                    constants.STATE_PRESSED])
     self.press_params.polite_set("states hover",
                                  [constants.STATE_NORMAL,
                                   constants.STATE_PRESSED])
     self._activated = False
     self._value = value
     self._inserted = self._value
     self._cursor_index = len(self._inserted)
     reac_keypress = Reaction(KEYDOWN, self._reaction_keydown,
                              reac_name=constants.REAC_KEYPRESS)
     self.add_reaction(reac_keypress)
     self._keyer = Keyer()
     self._hide_mouse = self.normal_params.params.get("hide mouse", False)
     self._varlink_func = varlink_func
     self.repeat_delay = parameters.KEY_DELAY
     self.repeat_interval = parameters.KEY_INTERVAL
Exemple #26
0
    def __init__(self,
                 path="./",
                 ddl_size=None,
                 normal_params=None,
                 folders=True,
                 files=True,
                 file_types=None,
                 text=""):
        ddl_size = style.BROWSERLIGHT_DDL_SIZE if ddl_size is None else ddl_size
        super(BrowserLight, self).__init__(normal_params=normal_params)
        self.path = path
        self._ddl_size = ddl_size
        self.file_types = file_types
        self.folders = folders
        self.files = files
        # DropDownListFast
        actual_folders, actual_files = self._get_folders_and_files()
        actual_files = self._filter_files(actual_files)
        if not folders:
            actual_folders = None
        if not files:
            actual_files = []
        self._ddlf = DropDownListFast(self._ddl_size, titles=actual_files,
                                      folders=actual_folders, has_lift=True)
##        self._ddlf.finish()
        # selection button
        inserter_width = 3*ddl_size[0]//4
##        if inserter_width > style.MAX_INSERTER_WIDTH:
##            inserter_width = style.MAX_INSERTER_WIDTH
        self._selected = Inserter("Selected : ", size=(inserter_width, None))
        self._selected.finish()
        if isinstance(text, str):
            self.text_element = OneLineText(text)
            self.text_element.finish()
        else:
            self.text_element = text
        self._path_element = PathElement(self, True)
        self._path_element.finish()
        self.add_elements([self.text_element, self._path_element, self._ddlf,
                           self._selected])
        reac_pressed = Reaction(parameters.BUTTON_UNPRESS_EVENT,
                                self._reaction_press,
                                name=constants.REAC_PRESSED)
##        self._ddlf._force_lift = True
        self._ddlf.finish()
        self.add_reaction(reac_pressed)
        self._clicked = None
        self._something_selected = False
        painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                                 pressed=True,
                                                 radius=style.BOX_RADIUS)
        self.set_painter(painter)
        self._last_click = -2 * parameters.DOUBLE_CLICK_DELAY
Exemple #27
0
 def __init__(self, elements=None, normal_params=None, height=None):
     Element.__init__(self, "", elements, normal_params)
     h = max([e.get_storer_rect().height for e in self.get_elements()]) + 2
     store(self, mode="h", x=1, y=h / 2, align="center")
     if self.father:
         w = self.father.get_storer_rect().width
     else:
         w = functions.get_screen_size()[0]
     size = (w, h)
     painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                              pressed=True,
                                              size=size,
                                              radius=style.BOX_RADIUS)
     self.set_painter(painter)
Exemple #28
0
 def __init__(self, elements=None, normal_params=None, height=None):
     Element.__init__(self, "", elements, normal_params)
     h = max([e.get_storer_rect().height for e in self.get_elements()]) + 2
     store(self, mode="h", x=1, y=h/2, align="center")
     if self.father:
         w = self.father.get_storer_rect().width
     else:
         w = functions.get_screen_size()[0]
     size = (w, h)
     painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                              pressed=True,
                                              size=size,
                                              radius=style.BOX_RADIUS)
     self.set_painter(painter)
Exemple #29
0
 def __init__(self, bartext="", elements=None, normal_params=None,
              storer_params=None, size=None, put_lift=True):
     Element.__init__(self, "", elements, normal_params)
     self.storer_params = storer_params
     if self.storer_params is None:
         self.storer_params = dict()
     self._size = size
     self._has_lift = False
     self._put_lift = put_lift
     self._bartext = bartext
     painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                              pressed=True,
                                              size=size,
                                              radius=style.BOX_RADIUS)
     self.set_painter(painter)
Exemple #30
0
 def __init__(self, bartext="", elements=None, normal_params=None,
              storer_params=None, size=None, put_lift=True):
     Element.__init__(self, "", elements, normal_params)
     self.storer_params = storer_params
     if self.storer_params is None:
         self.storer_params = dict()
     self._size = size
     self._has_lift = False
     self._put_lift = put_lift
     self._bartext = bartext
     painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                              pressed=True,
                                              size=size,
                                              radius=style.BOX_RADIUS)
     self.set_painter(painter)
 def __init__(self,
              titles,
              size="auto",
              elements=None,
              normal_params=None,
              heavy=False,
              folders=None,
              margins=None,
              x=None,
              has_lift=True,
              finish=True):
     """Vertical list of multiple texts that can be selected.
     <titles>: a list of strings containing the different choices to display.
     <heavy>: if True, use more memory but is faster.
     <margins>: the margins of the dropdown list, not taking <x> into
         account.
     <x>: the value at which text starts. If x = 0, folders image will be
     croped!
     """
     margins = style.DDL_MARGINS if margins is None else margins
     size_painter = style.DDL_SIZE if size == "auto" else size
     self._clicked = None
     Element.__init__(self,
                      elements=elements,
                      normal_params=normal_params,
                      finish=False)
     painter = functions.obtain_valid_painter(
         painterstyle.BOX_PAINTER,
         pressed=True,
         ##                                                 color=style.DEF_COLOR2,
         size=size_painter,
         radius=style.BOX_RADIUS)
     self.set_painter(painter)
     self._margins = margins
     self._heavy = heavy
     self._dv = self._get_dirviewer(titles, size_painter, folders, x)
     reac_motion = Reaction(MOUSEMOTION,
                            self._reaction_motion,
                            reac_name=constants.REAC_MOTION)
     self.add_reaction(reac_motion)
     self._cursor_pos = (-1, -1)
     self._has_lift = has_lift
     self._menu = None
     self._set_selecter()
     self._force_lift = False
     self._size = size
     if finish:
         self.finish()
Exemple #32
0
def get_example_element(color, size):
    painter_frame = functions.obtain_valid_painter(painterstyle.DEF_PAINTER,
                                                   pressed=True,
                                                   size=size)
    if painter_frame.clip:
        color_size = painter_frame.clip.size
    else:
        color_size = size
    painter_example = BasicFrame(size=color_size, color=color)
    example = Element()
    example.set_painter(painter_example)
    example.finish()
    frame = Element(elements=[example])
    frame.set_painter(painter_frame)
    frame.finish()
    example.set_center(frame.get_fus_center())
    return frame
 def _get_example_element(self):
     color = self.get_color()
     painter_frame = functions.obtain_valid_painter(painterstyle.DEF_PAINTER,
                                                    pressed=True,
                                                    size=self._color_size)
     if painter_frame.clip:
         color_size = painter_frame.clip.size
     else:
         color_size = self._color_size
     painter_example = BasicFrame(size=color_size, color=color)
     example = Element()
     example.set_painter(painter_example)
     example.finish()
     frame = Element(elements=[example])
     frame.set_painter(painter_frame)
     frame.finish()
     example.set_center(frame.get_fus_center())
     return frame
Exemple #34
0
 def __init__(self, bartext="", elements=None, normal_params=None,
              storer_params=None, size=None, put_lift=True):
     """Box containing other elements.
     <bartext>: the text of the box bar. If no text, no bar is added.
     <size>: if not None, force the size of the box. Else the box
         automatically fit children."""
     Element.__init__(self, "", elements, normal_params)
     self.storer_params = storer_params
     if self.storer_params is None:
         self.storer_params = dict()
     self._size = size
     self._has_lift = False
     self._put_lift = put_lift
     self._bartext = bartext
     painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                              pressed=True,
                                              size=size,
                                              radius=style.BOX_RADIUS)
     self.set_painter(painter)
    def add_bar(self, text="", size=None, painter=None):
        writer = painterstyle.WRITER(font_name=style.BAR_FONTS,
                                     color=style.FONT_BAR_COLOR,
                                     size=style.FONT_BAR_SIZE,
                                     italic=style.BAR_ITALIC,
                                     bold=style.BAR_BOLD,
                                     underline=style.BAR_UNDERLINE,
                                     aa=style.FONT_BAR_AA,
                                     bckgr_color=style.FONT_BAR_BCKGR)

        params = {"writer": writer}
        bar = Element(text=text, normal_params=params)
        if not painter:
            painter = functions.obtain_valid_painter(painterstyle.BAR_PAINTER,
                                                     color=style.BAR_COLOR)
        bar.set_painter(painter)
        bar.finish()
        if size:
            bar.set_size(size)
        bar.set_bar_of(self)
Exemple #36
0
    def __init__(self,
                 titles,
                 size="auto",
                 elements=None,
                 normal_params=None,
                 heavy=False,
                 folders=None,
                 margins=None,
                 x=None,
                 has_lift=True):
        """Vertical list of multiple texts that can be selected.
        <titles>: a list of strings containing the different choices to display.
        <heavy>: if True, use more memory but is faster.
        <margins>: the margins of the dropdown list, not taking <x> into
            account.
        <x>: the value at which text starts. If x = 0, folders image will be
        croped!
        """
        margins = style.DDL_MARGINS if margins is None else margins
        size_painter = style.DDL_SIZE if size == "auto" else size
        self._clicked = None
        Element.__init__(self, elements=elements, normal_params=normal_params)
        painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                                 pressed=True,
##                                                 color=style.DEF_COLOR2,
                                                 size=size_painter,
                                                 radius=style.BOX_RADIUS)
        self.set_painter(painter)
        self._margins = margins
        self._heavy = heavy
        self._dv = self._get_dirviewer(titles, size_painter, folders, x)
        reac_motion= Reaction(MOUSEMOTION,
                              self._reaction_motion,
                              reac_name=constants.REAC_MOTION)
        self.add_reaction(reac_motion)
        self._cursor_pos = (-1, -1)
        self._has_lift = has_lift
        self._menu = None
        self._set_selecter()
        self._force_lift = False
        self._size = size
Exemple #37
0
 def _setup(self, width=None, dragsize=None):
     width = style.LIFT_BUTTON_SIZE[0] if width is None else width
     dragsize = style.LIFT_DRAG_SIZE if dragsize is None else dragsize
     self._drag_element = DraggerDirViewerY(self)
     self._height = width
     painter = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         color=style.DEF_COLOR2,
         pressed=True,
         size=(width,
               self._length + dragsize[1] + style.LIFT_MARGINS[1] + 1))
     self.set_painter(painter)
     self._drag_element.set_painter(painterstyle.DEF_PAINTER(size=dragsize),
                                    autopress=False)
     self.current_state.ghost_rect.height = self._length
     try:
         self._drag_element.set_center((self.get_fus_center()[0], None))
     except AttributeError:  # state is ghost state, and has no fusionner
         self._drag_element.set_center((self.get_ghost_center()[0], None))
     self._drag_element.set_free(y=False)
     Ghost.fit_children(self)
Exemple #38
0
 def _setup(self, width=None, dragsize=None):
     width = style.LIFT_BUTTON_SIZE[0] if width is None else width
     dragsize = style.LIFT_DRAG_SIZE if dragsize is None else dragsize
     self._drag_element = DraggerDirViewerY(self)
     self._height = width
     painter = functions.obtain_valid_painter(
         painterstyle.DEF_PAINTER,
         color=style.DEF_COLOR2,
         pressed=True,
         size=(width,
               self._length + dragsize[1] + style.LIFT_MARGINS[1] + 1))
     self.set_painter(painter)
     self._drag_element.set_painter(painterstyle.DEF_PAINTER(size=dragsize),
                                    autopress=False)
     self.current_state.ghost_rect.height = self._length
     try:
         self._drag_element.set_center((self.get_fus_center()[0], None))
     except AttributeError:  # state is ghost state, and has no fusionner
         self._drag_element.set_center((self.get_ghost_center()[0], None))
     self._drag_element.set_free(y=False)
     self.englobe_childrens()
 def get_fusionner(self):
     if "fusionner" in self.params:
         return self.params["fusionner"]
     else:
         painter = self.get_painter()
         title = self.get_title()
         colorkey = self.params.get("colorkey")
         params = {"painter": painter, "title": title,
                   "colorkey": colorkey}
         typ = self.params.get("style")
         if typ == "text":
             params.pop("painter")
             fusionner = _get_generic_object(FusionnerText, params)
             return fusionner
         elif typ == "help":
             pain = functions.obtain_valid_painter(painterstyle.HELP_PAINTER,
                                                   size=style.HELP_SIZE,
                                                   color=style.DEF_HELP_COLOR)
             params["painter"] = self.get_painter(pain)
         elif typ == "normal":
             pass
         elif typ:
             functions.debug_msg("Unknown style : " + str(typ))
         return _get_generic_object(_Fusionner, params)
Exemple #40
0
 def get_fusionner(self):
     if "fusionner" in self.params:
         return self.params["fusionner"]
     else:
         painter = self.get_painter()
         title = self.get_title()
         colorkey = self.params.get("colorkey")
         params = {"painter": painter, "title": title, "colorkey": colorkey}
         type_ = self.params.get("style")
         if type_ == "text":
             params.pop("painter")
             fusionner = _get_generic_object(FusionnerText, params)
             return fusionner
         elif type_ == "help":
             pain = functions.obtain_valid_painter(
                 painterstyle.HELP_PAINTER,
                 size=style.HELP_SIZE,
                 color=style.DEF_HELP_COLOR)
             params["painter"] = self.get_painter(pain)
         elif type_ == "normal":
             pass
         elif type_:
             functions.debug_msg("Unknown style : " + str(type_))
         return _get_generic_object(_Fusionner, params)
 def __init__(self,
              path="./",
              ddl_size=None,
              normal_params=None,
              folders=True,
              files=True,
              file_types=None,
              text="",
              finish=True):
     """File and folder browser for a.
     <path>: the path of the folder in which browser browse files.
     <ddl_size>: if not None, force the size of the dropdown list of files.
     <folders>: if True, displays folders to user.
     <files>: if True, displays file to user.
     <file_types>: if not None, pass a list of files formats that you wand to
         be valid for user choice.
     <text>: title text of the browser.
     """
     ddl_size = style.BROWSERLIGHT_DDL_SIZE if ddl_size is None else ddl_size
     super(BrowserLight, self).__init__(normal_params=normal_params,
                                        finish=False)
     self.path = self.set_path(path)
     self.last_done_path = str(self.path)
     self._ddl_size = ddl_size
     self.file_types = file_types
     self.folders = folders
     self.files = files
     # DropDownListFast
     actual_folders, actual_files = self._get_folders_and_files()
     actual_files = self._filter_files(actual_files)
     if not folders:
         actual_folders = None
     if not files:
         actual_files = []
     self._ddlf = DropDownListFast(size=self._ddl_size,
                                   titles=actual_files,
                                   folders=actual_folders,
                                   has_lift=True,
                                   finish=False)
     ##        self._ddlf.finish()
     # selection button
     inserter_width = 3 * ddl_size[0] // 4
     ##        if inserter_width > style.MAX_INSERTER_WIDTH:
     ##            inserter_width = style.MAX_INSERTER_WIDTH
     self._selected = Inserter("Selected : ", size=(inserter_width, None))
     if isinstance(text, str):
         self.text_element = OneLineText(text)
     else:
         self.text_element = text
     self._path_element = PathElement(father=self, abspath=True)
     self.add_elements([
         self.text_element, self._path_element, self._ddlf, self._selected
     ])
     reac_pressed = Reaction(parameters.BUTTON_UNPRESS_EVENT,
                             self._reaction_press, {"button": 1},
                             reac_name=constants.REAC_PRESSED)
     ##        self._ddlf._force_lift = True
     self._ddlf.finish()
     self.add_reaction(reac_pressed)
     self._clicked = None
     self._something_selected = False
     painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                              pressed=True,
                                              radius=style.BOX_RADIUS)
     self.set_painter(painter)
     self._last_click = -2 * parameters.DOUBLE_CLICK_DELAY
     if finish:
         self.finish()
Exemple #42
0
def get_img_redraw(hoverable, state, params):
    paint_params = params["params"]
    paint_params["size"] = hoverable.get_ghost_size()
    painter = functions.obtain_valid_painter(params["painter"], **paint_params)
    return painter.get_fusion(hoverable.get_title(), True)
Exemple #43
0
 def __init__(self,
              name="",
              elements=None,
              normal_params=None,
              press_params=None,
              value="",
              size=(None, None),
              namestyle=None,
              varlink_func=None,
              quit_on_click=False,
              value_type=str,
              finish=True):
     """Element fo text insertion.
     <name>: text of the title before the inserter.
     <value>: initial text inside the inserter.
     <size>: if not (None,None), a 2-tuple specifying the size of the text
         insertion zone.
     <quit_on_click>: if True, make the inserter lose focus when mouse click
         outside its area.
     """
     namestyle = style.STYLE_INSERTER_NAME if namestyle is None else namestyle
     if size[0] is None:
         s0 = style.SIZE[0]
     else:
         s0 = size[0]
     if size[1] is None:
         s1 = style.Y_SMALL_SIZE
     else:
         s1 = size[1]
     size = (s0, s1)
     self.cursor = None
     super(Inserter, self).__init__("",
                                    elements,
                                    normal_params,
                                    press_params,
                                    finish=False)
     self._name_element = self._get_name_element(name, namestyle)
     self.add_elements([self._name_element])
     self._iwriter = _InsertWriter(value)
     self.add_elements([self._iwriter])
     self.quit_on_click = quit_on_click
     self._value_type = value_type
     painter = functions.obtain_valid_painter(painterstyle.INSERTER_PAINTER,
                                              color=style.DEF_COLOR2,
                                              pressed=True,
                                              size=(s0, s1))
     self.set_painter(painter)
     self.normal_params.polite_set(
         "states hover", [constants.STATE_NORMAL, constants.STATE_PRESSED])
     self.press_params.polite_set(
         "states hover", [constants.STATE_NORMAL, constants.STATE_PRESSED])
     self._activated = False
     self._value = value
     self._inserted = self._value
     self._cursor_index = len(self._inserted)
     reac_keypress = Reaction(KEYDOWN,
                              self._reaction_keydown,
                              reac_name=constants.REAC_KEYPRESS)
     self.add_reaction(reac_keypress)
     self._keyer = Keyer()
     self._hide_mouse = self.normal_params.params.get("hide mouse", False)
     self._varlink_func = varlink_func
     self.repeat_delay = parameters.KEY_DELAY
     self.repeat_interval = parameters.KEY_INTERVAL
     self.deactivate_on_focus = []
     self.auto_resize = True
     self.numeric_only = False
     self.int_only = False
     if finish:
         self.finish()
def get_img_redraw(hoverable, state, params):
    paint_params = params["params"]
    paint_params["size"] = hoverable.get_ghost_size()
    painter = functions.obtain_valid_painter(params["painter"],
                                             **paint_params)
    return painter.get_fusion(hoverable.get_title(), True)
    def __init__(self,
                 path="./",
                 ddl_size=None,
                 normal_params=None,
                 folders=True,
                 files=True,
                 file_types=None,
                 text=""):
        """File and folder browser for a.
        <path>: the path of the folder in which browser browse files.
        <ddl_size>: if not None, force the size of the dropdown list of files.
        <folders>: if True, displays folders to user.
        <files>: if True, displays file to user.
        <file_types>: if not None, pass a list of files formats that you wand to
            be valid for user choice.
        <text>: title text of the browser.
        """
        ddl_size = style.BROWSERLIGHT_DDL_SIZE if ddl_size is None else ddl_size
        super(BrowserLight, self).__init__(normal_params=normal_params)
        self.path = self.set_path(path)
        self.last_done_path = str(self.path)
        self._ddl_size = ddl_size
        self.file_types = file_types
        self.folders = folders
        self.files = files
        # DropDownListFast
        actual_folders, actual_files = self._get_folders_and_files()
        actual_files = self._filter_files(actual_files)
        if not folders:
            actual_folders = None
        if not files:
            actual_files = []
        self._ddlf = DropDownListFast(size=self._ddl_size, titles=actual_files,
                                      folders=actual_folders, has_lift=True)
##        self._ddlf.finish()
        # selection button
        inserter_width = 3*ddl_size[0]//4
##        if inserter_width > style.MAX_INSERTER_WIDTH:
##            inserter_width = style.MAX_INSERTER_WIDTH
        self._selected = Inserter("Selected : ", size=(inserter_width, None))
        self._selected.finish()
        if isinstance(text, str):
            self.text_element = OneLineText(text)
            self.text_element.finish()
        else:
            self.text_element = text
        self._path_element = PathElement(self, True)
        self._path_element.finish()
        self.add_elements([self.text_element, self._path_element, self._ddlf,
                           self._selected])
        reac_pressed = Reaction(parameters.BUTTON_UNPRESS_EVENT,
                                self._reaction_press,
                                {"button":1},
                                reac_name=constants.REAC_PRESSED)
##        self._ddlf._force_lift = True
        self._ddlf.finish()
        self.add_reaction(reac_pressed)
        self._clicked = None
        self._something_selected = False
        painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
                                                 pressed=True,
                                                 radius=style.BOX_RADIUS)
        self.set_painter(painter)
        self._last_click = -2 * parameters.DOUBLE_CLICK_DELAY
 def __init__(self,
              name="",
              elements=None,
              normal_params=None,
              press_params=None,
              value="",
              size=(None, None),
              namestyle=None,
              varlink_func=None,
              quit_on_click=False,
              value_type=str):
     """Element fo text insertion.
     <name>: text of the title before the inserter.
     <value>: initial text inside the inserter.
     <size>: if not (None,None), a 2-tuple specifying the size of the text
         insertion zone.
     <quit_on_click>: if True, make the inserter lose focus when mouse click
         outside its area.
     """
     namestyle=style.STYLE_INSERTER_NAME if namestyle is None else namestyle
     if size[0] is None:
         s0 = style.SIZE[0]
     else:
         s0 = size[0]
     if size[1] is None:
         s1 = style.Y_SMALL_SIZE
     else:
         s1 = size[1]
     size = (s0, s1)
     self.cursor = None
     super(Inserter, self).__init__("", elements, normal_params,
                                    press_params)
     self._name_element = self._get_name_element(name, namestyle)
     self.add_elements([self._name_element])
     self._iwriter = _InsertWriter(value)
     self._iwriter.finish()
     self.add_elements([self._iwriter])
     self.quit_on_click = quit_on_click
     self._value_type = value_type
     painter = functions.obtain_valid_painter(painterstyle.INSERTER_PAINTER,
                                              color=style.DEF_COLOR2,
                                              pressed=True,
                                              size=(s0,s1))
     self.set_painter(painter)
     self.normal_params.polite_set("states hover",
                                   [constants.STATE_NORMAL,
                                    constants.STATE_PRESSED])
     self.press_params.polite_set("states hover",
                                  [constants.STATE_NORMAL,
                                   constants.STATE_PRESSED])
     self._activated = False
     self._value = value
     self._inserted = self._value
     self._cursor_index = len(self._inserted)
     reac_keypress = Reaction(KEYDOWN, self._reaction_keydown,
                              reac_name=constants.REAC_KEYPRESS)
     self.add_reaction(reac_keypress)
     self._keyer = Keyer()
     self._hide_mouse = self.normal_params.params.get("hide mouse", False)
     self._varlink_func = varlink_func
     self.repeat_delay = parameters.KEY_DELAY
     self.repeat_interval = parameters.KEY_INTERVAL