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
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()
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
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] 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
def launch_blocking_choices(text, choices, parent=None, 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] 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.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()