Exemplo n.º 1
0
    def _set_launcher(self):
        launcher = launchmod.Launcher(self.launched, launching=self)
        reac_enter = ConstantReaction(constants.THORPY_EVENT, launcher.launch,
                                      {
                                          "id": constants.EVENT_UNPRESS,
                                          "el": self
                                      })
        ##                             reac_name="reac_launch")
        reac_done = ConstantReaction(constants.THORPY_EVENT, self.unlaunch, {
            "id": constants.EVENT_DDL,
            "el": self.launched
        })
        ##                             reac_name="reac_done")
        if self.click_cancel:
            reac_cancel = Reaction(parameters.MOUSEBUTTONUP,
                                   launchmod.func_click_quit,
                                   params={
                                       "launcher": launcher,
                                       "what": CLICK_QUIT
                                   })
            ##                                    reac_name="reac_cancel")
            self.launched.add_reaction(reac_cancel)
        self.add_reaction(reac_enter)
        self.launched.add_reaction(reac_done)

        def func_before():
            self.launched.stick_to(self, "bottom", "top")
            self.launched.blit()
            self.launched.update()

        launcher.func_before = func_before
        self.launcher = launcher
Exemplo n.º 2
0
def set_launcher(launching, launched, click_quit=False):
    """Set <launching> as a launcher (on click) for element <launched>.
    Return launcher object."""
    launcher = Launcher(launched, launching=launching)
    reac_enter = ConstantReaction(constants.THORPY_EVENT, launcher.launch, {
        "id": constants.EVENT_UNPRESS,
        "el": launching
    })
    reac_done = ConstantReaction(constants.THORPY_EVENT, launcher.unlaunch, {
        "id": constants.EVENT_DONE,
        "el": launched
    }, {"what": DONE})
    reac_cancel = ConstantReaction(constants.THORPY_EVENT, launcher.unlaunch, {
        "id": constants.EVENT_CANCEL,
        "el": launched
    }, {"what": CANCEL})
    if click_quit:
        reac_clickquit = Reaction(parameters.MOUSEBUTTONUP,
                                  func_click_quit,
                                  params={
                                      "launcher": launcher,
                                      "what": CLICK_QUIT
                                  })
        launched.add_reaction(reac_clickquit)


##    launcher.launching = launching
    launching.add_reaction(reac_enter)
    launched.add_reaction(reac_done)
    launched.add_reaction(reac_cancel)
    return launcher
Exemplo n.º 3
0
def get_launcher(launched, click_quit=False, launching=None, autocenter=True):
    """Prepare and return a launcher object for launching <launched>."""
    launcher = Launcher(launched, launching=launching)
    launcher.autocenter = autocenter
    reac_done = ConstantReaction(constants.THORPY_EVENT,
                                 launcher.unlaunch, {
                                     "id": constants.EVENT_DONE,
                                     "el": launched
                                 }, {"what": DONE},
                                 reac_name="reac_done")
    reac_cancel = ConstantReaction(constants.THORPY_EVENT,
                                   launcher.unlaunch, {
                                       "id": constants.EVENT_CANCEL,
                                       "el": launched
                                   }, {"what": CANCEL},
                                   reac_name="reac_cancel")
    if click_quit:
        reac_clickquit = Reaction(parameters.MOUSEBUTTONUP,
                                  func_click_quit,
                                  {"button": parameters.LEFT_CLICK_BUTTON}, {
                                      "launcher": launcher,
                                      "what": CLICK_QUIT
                                  },
                                  reac_name="reac_clickquit")
        launched.add_reaction(reac_clickquit)
    launched.add_reaction(reac_done)
    launched.add_reaction(reac_cancel)
    return launcher
Exemplo n.º 4
0
 def _set_launcher(self):
     launcher = launchmod.Launcher(self.launched, launching=self)
     reac_enter = ConstantReaction(constants.THORPY_EVENT, launcher.launch,
                                   {
                                       "id": constants.EVENT_UNPRESS,
                                       "el": self
                                   })
     ##                             reac_name="reac_launch")
     reac_done = ConstantReaction(constants.THORPY_EVENT,
                                  self._unlaunch_done, {
                                      "id": constants.EVENT_DONE,
                                      "el": self.launched
                                  })
     ##                             reac_name="reac_done")
     reac_cancel = ConstantReaction(constants.THORPY_EVENT,
                                    self._unlaunch_cancel, {
                                        "id": constants.EVENT_CANCEL,
                                        "el": self.launched
                                    })
     ##                         reac_name="reac_cancel")
     if self.click_cancel:
         reac_click_cancel = Reaction(parameters.MOUSEBUTTONUP,
                                      self._unlaunch_click_cancel,
                                      params={"launcher": launcher})
         ##                                    reac_name="reac_click_cancel")
         self.launched.add_reaction(reac_click_cancel)
     self.add_reaction(reac_enter)
     self.launched.add_reaction(reac_done)
     self.launched.add_reaction(reac_cancel)
     self.launcher = launcher
Exemplo n.º 5
0
 def _add_buttons(self, size=None):
     size = style.SMALL_SIZE if size is None else size
     self._plus = Plus()
     self._minus = Minus()
     self._plus.finish()
     self._minus.finish()
     self._plus.drag = self._drag_element
     self._minus.drag = self._drag_element
     reac_plus_time = ConstantReaction(constants.THORPY_EVENT,
                                  self._plus._reaction_time,
                                  {"id":constants.EVENT_TIME},
                                  reac_name=constants.REAC_MOUSE_REPEAT)
     self.add_reaction(reac_plus_time)
     reac_minus_time = ConstantReaction(constants.THORPY_EVENT,
                                  self._minus._reaction_time,
                                  {"id":constants.EVENT_TIME},
                                  reac_name=constants.REAC_MOUSE_REPEAT+0.1)
     self.add_reaction(reac_minus_time)
     self.add_elements([self._plus, self._minus])
     # reactions to mouse press:
     reac_pluspress2 = ConstantReaction(constants.THORPY_EVENT,
                                    self._drag_element.shift,
                                    {"el": self._plus,
                                     "id": constants.EVENT_PRESS},
                                    {"sign":parameters.CLICK_LIFT_SHIFT},
                                    reac_name=constants.REAC_PRESSED2)
     self.add_reaction(reac_pluspress2)
     reac_minuspress2 = ConstantReaction(constants.THORPY_EVENT,
                                 self._drag_element.shift,
                                 {"el": self._minus,
                                  "id": constants.EVENT_PRESS},
                                 {"sign":-parameters.CLICK_LIFT_SHIFT},
                                 reac_name=constants.REAC_PRESSED2+0.1)
     self.add_reaction(reac_minuspress2)
Exemplo n.º 6
0
 def _set_launcher(self):
     launcher = launchmod.Launcher(self.launched, launching=self)
     reac_enter = ConstantReaction(constants.THORPY_EVENT, launcher.launch,
                                   {
                                       "id": constants.EVENT_UNPRESS,
                                       "el": self
                                   })
     ##                             reac_name="reac_launch")
     reac_done = ConstantReaction(constants.THORPY_EVENT, self.unlaunch, {
         "id": constants.EVENT_DONE,
         "el": self.launched
     }, {"what": DONE})
     ##                             reac_name="reac_done")
     reac_cancel = ConstantReaction(constants.THORPY_EVENT, self.unlaunch, {
         "id": constants.EVENT_CANCEL,
         "el": self.launched
     }, {"what": CANCEL})
     ##                         reac_name="reac_cancel")
     if self.click_cancel:
         reac_click_cancel = Reaction(parameters.MOUSEBUTTONUP,
                                      launchmod.func_click_quit,
                                      params={
                                          "launcher": self,
                                          "what": CLICK_QUIT
                                      },
                                      reac_name="reac_click_cancel")
         self.launched.add_reaction(reac_click_cancel)
     self.add_reaction(reac_enter)
     self.launched.add_reaction(reac_done)
     self.launched.add_reaction(reac_cancel)
     self.launcher = launcher
Exemplo n.º 7
0
 def __init__(self, elements, first_value, always_value=True):
     for e in elements:
         assert isinstance(e, Checker)
         reac = ConstantReaction(constants.THORPY_EVENT,
                                 self.refresh,
                                 event_args={
                                     "id": constants.EVENT_PRESS,
                                     "el": e
                                 },
                                 params={"selected": e})
         e.add_reaction(reac)
         reac2 = ConstantReaction(constants.THORPY_EVENT,
                                  self.refresh,
                                  event_args={
                                      "id": constants.EVENT_PRESS,
                                      "el": e._name_element
                                  },
                                  params={"selected": e})
         e.add_reaction(reac2)
     self.elements = elements
     self._selected = None
     self.always_value = always_value
     if self.always_value:
         if not first_value:
             raise Exception(
                 "If always_value is true, first_value must be set")
     self.function = None
     if first_value:
         self._selected = first_value
         self._selected.set_value(True)
Exemplo n.º 8
0
 def __init__(self,
              text="",
              elements=None,
              normal_params=None,
              storer_params=None,
              size=None,
              put_lift=True,
              color_size=(50, 50),
              value=(255, 0, 0),
              color_limvals=(0, 255)):
     Box.__init__(self, text, elements, normal_params, storer_params, size,
                  put_lift)
     self._color_size = color_size
     self._r_element = SliderXSetter(100,
                                     text="R: ",
                                     typ=int,
                                     limvals=color_limvals,
                                     initial_value=value[0])
     self._r_element.finish()
     self._g_element = SliderXSetter(100,
                                     text="G: ",
                                     typ=int,
                                     limvals=color_limvals,
                                     initial_value=value[1])
     self._g_element.finish()
     self._b_element = SliderXSetter(100,
                                     text="B: ",
                                     typ=int,
                                     limvals=color_limvals,
                                     initial_value=value[2])
     self._b_element.finish()
     reac_red = ConstantReaction(constants.THORPY_EVENT,
                                 self.refresh, {
                                     "name": constants.EVENT_SLIDE,
                                     "el": self._r_element
                                 },
                                 name="setcolorred")
     reac_green = ConstantReaction(constants.THORPY_EVENT,
                                   self.refresh, {
                                       "name": constants.EVENT_SLIDE,
                                       "el": self._g_element
                                   },
                                   name="setcolorgreen")
     reac_blue = ConstantReaction(constants.THORPY_EVENT,
                                  self.refresh, {
                                      "name": constants.EVENT_SLIDE,
                                      "el": self._b_element
                                  },
                                  name="setcolorblue")
     self.add_reactions([reac_red, reac_green, reac_blue])
     self._example_element = self._get_example_element()
     self.add_elements([
         self._r_element, self._g_element, self._b_element,
         self._example_element
     ])
Exemplo n.º 9
0
 def __init__(self,
              text="",
              elements=None,
              normal_params=None,
              storer_params=None,
              size=None,
              put_lift=True,
              color_size=(50, 50),
              value=(255, 0, 0),
              color_limvals=(0, 255)):
     """Box in which three sliders and a visualization square provide a way to
     define a color.
     <text>: title text for the color box.
     <size>: if not None, force the size of the box.
     <color_size>: the size of the color visualization rect.
     <value>: 3-tuple defining the initial color value.
     """
     Box.__init__(self, elements, normal_params, storer_params, size,
                  put_lift)
     self._color_size = color_size
     self._r_element = SliderXSetter(100, text="R: ", type_=int,
                            limvals=color_limvals, initial_value=value[0])
     self._r_element.finish()
     self._g_element = SliderXSetter(100, text="G: ", type_=int,
                            limvals=color_limvals, initial_value=value[1])
     self._g_element.finish()
     self._b_element = SliderXSetter(100, text="B: ", type_=int,
                            limvals=color_limvals, initial_value=value[2])
     self._b_element.finish()
     reac_red= ConstantReaction(constants.THORPY_EVENT,
                                self.refresh,
                                {"id":constants.EVENT_SLIDE,
                                 "el":self._r_element},
                                reac_name="setcolorred")
     reac_green= ConstantReaction(constants.THORPY_EVENT,
                                  self.refresh,
                                  {"id":constants.EVENT_SLIDE,
                                   "el":self._g_element},
                                  reac_name="setcolorgreen")
     reac_blue= ConstantReaction(constants.THORPY_EVENT,
                                 self.refresh,
                                 {"id":constants.EVENT_SLIDE,
                                  "el":self._b_element},
                                 reac_name="setcolorblue")
     self.add_reactions([reac_red, reac_green, reac_blue])
     self._example_element = get_example_element(value, color_size)
     self.add_elements([self._r_element, self._g_element, self._b_element,
                        self._example_element])
Exemplo n.º 10
0
def launch_blocking_choices(text, choices, parent=None, title_fontsize=None,
                    title_fontcolor=None, main_color=None):
    """choices is a list of either tuple(text,func) or elements"""
    if title_fontsize is None: title_fontsize = style.FONT_SIZE
    if title_fontcolor is None: title_fontcolor = style.FONT_COLOR
##    elements = [make_button(t,f) for t,f in choices] #old form
    elements = []
    for choice in choices:
        if isinstance(choice, tuple):
            elements.append(make_button(choice[0],choice[1]))
        else:
            elements.append(choice)
    ghost = make_stored_ghost(elements)
    e_text = make_text(text, title_fontsize, title_fontcolor)
    box = Box.make([e_text, ghost])
    if main_color:
        box.set_main_color(main_color)
    box.center()
    from thorpy.miscgui.reaction import ConstantReaction
    for e in elements:
        reac = ConstantReaction(constants.THORPY_EVENT,
                                functions.quit_menu_func,
                                {"id":constants.EVENT_UNPRESS,
                                 "el":e})
        box.add_reaction(reac)
    from thorpy.menus.tickedmenu import TickedMenu
    m = TickedMenu(box)
    m.play()
    box.unblit()
    if parent:
        parent.partial_blit(None, box.get_fus_rect())
        box.update()
Exemplo n.º 11
0
def launch_choices(text, choices, title_fontsize=None, title_fontcolor=None,
                    click_quit=False):
    """choices are tuple (text,func)"""
    if title_fontsize is None: title_fontsize = style.FONT_SIZE
    if title_fontcolor is None: title_fontcolor = style.FONT_COLOR
##    elements = [make_button(t,f) for t,f in choices]
    elements = []
    for choice in choices:
        if isinstance(choice, tuple):
            elements.append(make_button(choice[0],choice[1]))
        else:
            elements.append(choice)
    ghost = make_stored_ghost(elements)
    e_text = make_text(text, title_fontsize, title_fontcolor)
    box = Box.make([e_text, ghost])
    box.center()
    from thorpy.miscgui.launchers.launcher import launch
    from thorpy.miscgui.reaction import ConstantReaction, Reaction
    from thorpy import functions
    launcher = launch(box)
    for e in elements:
        reac = ConstantReaction(constants.THORPY_EVENT,
                                launcher.unlaunch,
                                {"id":constants.EVENT_UNPRESS, "el":e},
                                {"what":None})
        box.add_reaction(reac)
    def click_outside(e):
        if not box.get_fus_rect().collidepoint(e.pos):
            functions.quit_menu_func()
    box.add_reaction(Reaction(pygame.MOUSEBUTTONDOWN, click_outside))
    return launcher
Exemplo n.º 12
0
def launch_blocking_choices(text,
                            choices,
                            parent=None,
                            title_fontsize=None,
                            title_fontcolor=None,
                            func=None):
    """choices are tuple (text,func)"""
    if title_fontsize is None: title_fontsize = thorpy.style.FONT_SIZE
    if title_fontcolor is None: title_fontcolor = thorpy.style.FONT_COLOR
    elements = [thorpy.make_button(t, f) for t, f in choices]
    ghost = thorpy.make_group(elements)
    e_text = thorpy.make_text(text, title_fontsize, title_fontcolor)
    box = thorpy.Box.make([e_text, ghost])
    box.center()
    from thorpy.miscgui.reaction import ConstantReaction
    for e in elements:
        reac = ConstantReaction(thorpy.constants.THORPY_EVENT,
                                thorpy.functions.quit_menu_func, {
                                    "id": thorpy.constants.EVENT_UNPRESS,
                                    "el": e
                                })
        box.add_reaction(reac)
    from thorpy.menus.tickedmenu import TickedMenu
    m = TickedMenu(box)
    m.play()
    box.unblit()
    if parent:
        parent.partial_blit(None, box.get_fus_rect())
        box.update()
    if func:
        func()
Exemplo n.º 13
0
def launch_choices(text, choices, title_fontsize=None, title_fontcolor=None):
    """choices are tuple (text,func)"""
    if title_fontsize is None: title_fontsize = style.FONT_SIZE
    if title_fontcolor is None: title_fontcolor = style.FONT_COLOR
    ##    elements = [make_button(t,f) for t,f in choices]
    elements = []
    for choice in choices:
        if isinstance(choice, tuple):
            elements.append(make_button(choice[0], choice[1]))
        else:
            elements.append(choice)
    ghost = make_stored_ghost(elements)
    e_text = make_text(text, title_fontsize, title_fontcolor)
    box = Box.make([e_text, ghost])
    box.center()
    from thorpy.miscgui.launchers.launcher import launch
    from thorpy.miscgui.reaction import ConstantReaction
    launcher = launch(box)
    for e in elements:
        reac = ConstantReaction(constants.THORPY_EVENT, launcher.unlaunch, {
            "id": constants.EVENT_UNPRESS,
            "el": e
        }, {"what": None})
        box.add_reaction(reac)
    return launcher
Exemplo n.º 14
0
 def __init__(self, elements, first_value=None, always_value=False):
     for e in elements:
         assert isinstance(e, Togglable)
         reac = ConstantReaction(constants.THORPY_EVENT,
                                 self.refresh,
                                 event_args={
                                     "id": constants.EVENT_TOGGLE,
                                     "el": e
                                 },
                                 params={"selected": e})
         e.add_reaction(reac)
     self.elements = elements
     self._selected = None
     self.always_value = always_value
     if self.always_value:
         if not first_value:
             raise Exception(
                 "If always_value is true, first_value must be set")
     if first_value:
         self._selected = first_value
         ##            first_value._press()
         #
         first_value.change_state(constants.STATE_PRESSED)
         first_value._hovered = True
         sn = first_value.current_state_key
         if sn in first_value._states_hover:
             first_value.current_state.fusionner.img = first_value._hover_imgs[
                 sn]
             first_value._updates[sn].center = first_value.get_fus_center(
                 sn)
         first_value._count += 1
         first_value.toggled = True
     self.function = None
Exemplo n.º 15
0
def launch_blocking(element,
                    after=None,
                    func=None,
                    set_auto_ok=True,
                    add_ok_enter=None):
    if set_auto_ok:
        auto_ok(element)
    from thorpy.elements.inserter import Inserter
    inserters = []
    if add_ok_enter is None:  #auto detect
        add_ok_enter = True
        for e in [element] + list(element.get_descendants()):
            if isinstance(e, Inserter):
                inserters.append(e)
    if add_ok_enter:
        reac = ConstantReaction(pygame.KEYDOWN, emulate_ok_press,
                                {"key": pygame.K_RETURN}, {
                                    "element": element,
                                    "inserters": inserters
                                })
        element.add_reaction(reac)
    m = TickedMenu(element)
    m.play()
    if add_ok_enter:
        element.remove_reaction(reac)
    if after:
        after.unblit_and_reblit()
    if func:
        func()
Exemplo n.º 16
0
def launch_blocking(element, after=None, func=None, set_auto_ok=True,
                    add_ok_enter=None, set_auto_cancel=True, click_quit=False):
    if set_auto_ok:
        auto_ok(element)
    if set_auto_cancel:
        auto_cancel(element)
    if click_quit:
##        auto_click_quit(element)
        def click(e):
            if element.get_fus_rect().collidepoint(e.pos):
                if hasattr(element,"e_ok"):
                    emulate_ok_press(element.e_ok)
                elif hasattr(element, "e_cancel"):
                    post_cancel(element)
                    functions.quit_menu_func()
        element.add_reaction(Reaction(pygame.MOUSEBUTTONDOWN, click))
    from thorpy.elements.inserter import Inserter
    inserters = []
    if add_ok_enter is None: #auto detect
        add_ok_enter = True
        for e in [element]+list(element.get_descendants()):
            if isinstance(e, Inserter):
                inserters.append(e)
    if add_ok_enter:
        reac = ConstantReaction(pygame.KEYDOWN, emulate_ok_press,
                        {"key":pygame.K_RETURN}, {"element":element,
                                                    "inserters":inserters})
        element.add_reaction(reac)
    m = TickedMenu(element)
    m.play()
    if add_ok_enter:
        element.remove_reaction(reac)
    if after:
        after.unblit_and_reblit()
    if func:
        func()
    done = None
    cancel = None
    if hasattr(element, "e_ok"):
        done = element.e_ok.message
    if hasattr(element, "e_cancel"):
        cancel = element.e_cancel.message
    if done and not(cancel):
        return _FakeLauncher("done")
    elif cancel and not(done):
        return _FakeLauncher("cancel")
    elif done and cancel:
        raise Exception()
    else:
        return _FakeLauncher(None)
Exemplo n.º 17
0
def launch_blocking_choices_str(text,
                                choices,
                                parent=None,
                                title_fontsize=None,
                                title_fontcolor=None,
                                func=None,
                                store="v"):
    """choices are tuple (text,func)"""
    if title_fontsize is None: title_fontsize = thorpy.style.FONT_SIZE
    if title_fontcolor is None: title_fontcolor = thorpy.style.FONT_COLOR

    class Choice:
        value = None

    def choice_func(value):
        Choice.value = value

    elements = []
    for name in choices:
        e = thorpy.make_button(name, choice_func, {"value": name})
        elements.append(e)
    ghost = thorpy.make_group(elements, mode=store)
    e_text = thorpy.make_text(text, title_fontsize, title_fontcolor)
    box = thorpy.Box.make([e_text, thorpy.Line(100, "h"), ghost])
    box.center()
    from thorpy.miscgui.reaction import ConstantReaction
    for e in elements:
        reac = ConstantReaction(thorpy.constants.THORPY_EVENT,
                                thorpy.functions.quit_menu_func, {
                                    "id": thorpy.constants.EVENT_UNPRESS,
                                    "el": e
                                })
        box.add_reaction(reac)

    def click_outside(e):
        if not box.get_fus_rect().collidepoint(e.pos):
            thorpy.functions.quit_menu_func()

    reac = thorpy.Reaction(pygame.MOUSEBUTTONDOWN, click_outside)
    box.add_reaction(reac)
    from thorpy.menus.tickedmenu import TickedMenu
    m = TickedMenu(box)
    m.play()
    box.unblit()
    if parent:
        parent.partial_blit(None, box.get_fus_rect())
        box.update()
    if func:
        func()
    return Choice.value
Exemplo n.º 18
0
 def __init__(self,
              target,
              elements=None,
              normal_params=None,
              capture_states=None):
     StaticShadow.__init__(self, target, elements, normal_params)
     if capture_states is None:
         capture_states = [CAPTURE_STATE_STATIC]
     self._capture_states = capture_states
     self._shadows = {}
     self.offsets = {s: (0., 0.) for s in self._capture_states}
     reaction = ConstantReaction(constants.THORPY_EVENT,
                                 self._reaction_change_state, {
                                     "name": constants.EVENT_CHANGE_STATE,
                                     "el": self.target
                                 },
                                 name=constants.REAC_CHANGE_STATE)
     self.add_reaction(reaction)
Exemplo n.º 19
0
def launch_nonblocking_choices(text,
                               choices,
                               parent=None,
                               title_fontsize=None,
                               title_fontcolor=None,
                               func=None):
    """choices are tuple (text,func)"""
    from thorpy.miscgui.launchers.launcher import post_done
    if title_fontsize is None: title_fontsize = thorpy.style.FONT_SIZE
    if title_fontcolor is None: title_fontcolor = thorpy.style.FONT_COLOR
    elements = [thorpy.make_button(t, f) for t, f in choices]
    ghost = thorpy.make_group(elements)
    e_text = thorpy.make_text(text, title_fontsize, title_fontcolor)
    box = thorpy.Box.make([e_text, ghost])
    box.center()
    from thorpy.miscgui.reaction import ConstantReaction
    for e in elements:
        reac = ConstantReaction(thorpy.constants.THORPY_EVENT, post_done, {
            "id": thorpy.constants.EVENT_UNPRESS,
            "el": e
        }, {"el": box})
        box.add_reaction(reac)
    thorpy.launch_nonblocking(box)
Exemplo n.º 20
0
 def _add_buttons(self, size=None):
     size = style.SMALL_SIZE if size is None else size
     # _plus
     self._plus = Plus(text="+")
     self._plus.set_painter(painterstyle.DEF_PAINTER(size=size))
     self._plus.finish()
     self._plus.drag = self._drag_element
     reac_plus = ConstantReaction(constants.THORPY_EVENT,
                                  self._plus._reaction_time,
                                  {"name": constants.EVENT_TIME},
                                  name=constants.REAC_MOUSE_REPEAT)
     self.add_reaction(reac_plus)
     # _minus
     self._minus = Minus(text="-")
     self._minus.set_painter(painterstyle.DEF_PAINTER(size=size))
     self._minus.finish()
     self._minus.drag = self._drag_element
     reac_minus = ConstantReaction(constants.THORPY_EVENT,
                                   self._plus._reaction_time,
                                   {"name": constants.EVENT_TIME},
                                   name=constants.REAC_MOUSE_REPEAT + 0.1)
     self.add_reaction(reac_minus)
     self.add_elements([self._plus, self._minus])
     # reactions to mouse _press (!= reactions to key _press):
     self._plus.reactions[constants.REAC_PRESSED + 0.1] = ConstantReaction(
         constants.THORPY_EVENT, self._drag_element.shift, {
             "name": constants.EVENT_PRESS,
             "el": self.plus
         })
     self._minus.reactions[constants.REAC_PRESSED + 0.1] = ConstantReaction(
         constants.THORPY_EVENT, self._drag_element.shift, {
             "name": constants.EVENT_PRESS,
             "el": self.minus
         }, {"sign": -1})
     self._reactions[constants.REAC_PRESSED + 0.1] = ConstantReaction(
         constants.THORPY_EVENT, self._drag_element.shift, {
             "name": constants.EVENT_PRESS,
             "el": self.plus
         })
     self._reactions[constants.REAC_PRESSED + 0.1] = ConstantReaction(
         constants.THORPY_EVENT, self._drag_element.shift, {
             "name": constants.EVENT_PRESS,
             "el": self.minus
         }, {"sign": -1})
Exemplo n.º 21
0
 def add_press_event(self, event_type, event_args):
     reaction = ConstantReaction(event_type, self._press, event_args)
     self.add_reaction(reaction)
Exemplo n.º 22
0
 def add_unpress_event(self, event_type, event_args):
     reaction = ConstantReaction(event_type, self._reaction_unpress_key)
     self.add_reaction(reaction)