Beispiel #1
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)
Beispiel #2
0
 def _add_buttons(self, size=None):
     _GraphicalSlider._add_buttons(self, size)
     rect = self.get_fus_rect()
     self._minus.set_center((-2 + rect.left - size[0] // 2, rect.centery))
     self._plus.set_center((2 + rect.right + size[0] // 2, rect.centery))
     Ghost.fit_children(self)
     self._add_buttons_reactions()
Beispiel #3
0
 def _add_buttons(self, size=None):
     _GraphicalSlider._add_buttons(self, size)
     rect = self.get_fus_rect()
     self._minus.set_center((-2 + rect.left - size[0] // 2, rect.centery))
     self._plus.set_center((2 + rect.right + size[0] // 2, rect.centery))
     Ghost.fit_children(self)
     self._add_buttons_reactions()
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
0
 def _add_buttons(self, size=None):
     _GraphicalSlider._add_buttons(self, size)
     rect = self.get_fus_rect()
     pos = (rect.centerx, rect.bottom + style.SLIDER_MARGINS[1] + size[1]/2)
     self._minus.set_center(pos)
     pos = (rect.centerx, rect.top - style.SLIDER_MARGINS[1] - size[1]/2)
     self._plus.set_center(pos)
     Ghost.fit_children(self)
     self._add_buttons_reactions()
Beispiel #8
0
 def _finish_add(self, size=None):
     size = style.LIFT_BUTTON_SIZE if size is None else size
     rect = self.get_fus_rect()
     pos = (rect.centerx, rect.bottom + style.BUTTON_MARGINS[1] + size[1]/2)
     self._minus.set_center(pos)
     pos = (rect.centerx, rect.top - style.BUTTON_MARGINS[1] - size[1]/2)
     self._plus.set_center(pos)
     Ghost.fit_children(self)
     self._add_buttons_reactions()
Beispiel #9
0
 def _add_buttons(self, size=None):
     _GraphicalSlider._add_buttons(self, size)
     rect = self.get_fus_rect()
     pos = (rect.centerx, rect.bottom + style.SLIDER_MARGINS[1] + size[1]/2)
     self._minus.set_center(pos)
     pos = (rect.centerx, rect.top - style.SLIDER_MARGINS[1] - size[1]/2)
     self._plus.set_center(pos)
     Ghost.fit_children(self)
     self._add_buttons_reactions()
Beispiel #10
0
 def _finish_add(self, size=None):
     size = style.LIFT_BUTTON_SIZE if size is None else size
     rect = self.get_fus_rect()
     pos = (rect.centerx, rect.bottom + style.BUTTON_MARGINS[1] + size[1]/2)
     self._minus.set_center(pos)
     pos = (rect.centerx, rect.top - style.BUTTON_MARGINS[1] - size[1]/2)
     self._plus.set_center(pos)
     Ghost.fit_children(self)
     self._add_buttons_reactions()
Beispiel #11
0
 def __init__(self,
              length,
              limvals=None,
              text="",
              elements=None,
              normal_params=None):
     self._height = None
     self._drag_element = DraggerY(self)
     super(SliderY, self).__init__(length, limvals, text, elements,
                                   normal_params)
     self._drag_element.finish()
     self.add_elements(list([self._drag_element]))
     Ghost.fit_children(self)
Beispiel #12
0
 def __init__(self,
              length,
              limvals=None,
              text="",
              elements=None,
              normal_params=None):
     self._height = None
     self._drag_element = DraggerY(self)
     super(SliderY, self).__init__(length, limvals, text, elements,
                                   normal_params)
     self._drag_element.finish()
     self.add_elements(list([self._drag_element]))
     Ghost.fit_children(self)
 def _get_launched_el(self, els, size, storer_params):
     _done_element = Clickable(style.OK_TXT)
     _done_element.finish()
     _cancel_element = Clickable(style.CANCEL_TXT)
     _cancel_element.finish()
     g = Ghost([_done_element, _cancel_element])
     g.finish()
     g.rank = float("inf")
     store(g, g.get_elements(), "h")
     g.fit_children()
     els += [g]
     box = Box(elements=els, size=size, storer_params=storer_params)
     box.finish() #box stores its elements
     return box, _done_element, _cancel_element
 def __init__(self,
              browser,
              name_txt="",
              file_txt="",
              launcher_txt="",
              normal_params=None,
              file_width=None,
              show_select=True,
              click_quit=False):
     """<browser> : the browser to be launched. Can either be a Browser
                    instance or a BrowserLight instance.
     <name_txt> : the text that stands before the (optionnal) file name and
                  the button to launch browser.
     <file_txt> : the default value shown to the user.
     <launcher_txt> : the text on the launcher button.
     """
     file_width = style.FILE_WIDTH if file_width is None else file_width
     self.show_select = show_select
     if not self.show_select:
         file_txt = ""
     _Launcher.__init__(self, "", normal_params, click_quit)
     self._spawn = "center"
     self.file_width = file_width
     self._done_element = Clickable(style.OK_TXT)
     self._done_element.finish()
     self._cancel_element = Clickable(style.CANCEL_TXT)
     self._cancel_element.finish()
     g = Ghost([self._done_element, self._cancel_element])
     g.finish()
     g.fit_children()
     g.rank = float("inf")
     store(g, g.get_elements(), "h")
     # to launch : must not be in self._elements!
     self.browser = browser
     box = Box(elements=[self.browser, g],
               storer_params=None)
     box.finish()
     self.launched_element = box
     self._deny_child(self.launched_element)
     # launcher
     self.launcher_el = self.get_launcher_element(launcher_txt)
     self.launcher_el.user_func = self.launch_box
     # name
     self._name_element = self._get_name_element(name_txt)
     self._name_element.user_func = self.launch_box
     self._file_element = self._get_file_element(file_txt)
     self.add_elements([self._name_element, self.launcher_el, self._file_element])
Beispiel #15
0
def make_stored_ghost(elements, mode="h"):
    ghost = Ghost(elements)
    ghost.finish()
    store(ghost, mode=mode)
    ghost.fit_children()
    return ghost
def make_stored_ghost(elements, mode="h"):
    ghost = Ghost(elements)
    ghost.finish()
    store(ghost, mode=mode)
    ghost.fit_children()
    return ghost