def launch_alert(text, font_size=None, font_color=None, ok_text="Ok"): if font_size is None: font_size = style.FONT_SIZE if font_color is None: font_color = style.FONT_COLOR from thorpy.miscgui.launchers.launcher import launch box_alert = make_alert(text, font_size, font_color, ok_text) box_alert.center() launch(box_alert)
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_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