当前位置: 首页>>代码示例>>Python>>正文


Python Cli.make_page方法代码示例

本文整理汇总了Python中cjh.cli.Cli.make_page方法的典型用法代码示例。如果您正苦于以下问题:Python Cli.make_page方法的具体用法?Python Cli.make_page怎么用?Python Cli.make_page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cjh.cli.Cli的用法示例。


在下文中一共展示了Cli.make_page方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: play_thru

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
 def play_thru(self, autoplay=False):
     goban = Goban(int(self.header_dict['SZ'])) #, skinfile=self.skin)
     color = 'black'
     for _, turn in enumerate(self.moves):
         goban.place_stone(turn[0], int(turn[1:]), color)
         if autoplay:
             func = lambda: time.sleep(.25)
         else: func = Cli.wait
         Cli.make_page(self.label, str(goban), func)
         if color == 'white':
             color = 'black'
         elif color == 'black':
             color = 'white'
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:15,代码来源:igo.py

示例2: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def main():
    """Launch an interface, i.e., main loop."""
    if SHELL.interface == 'Tk':
        SHELL.main_window.mainloop()
    else:
        while True:
            f = lambda: SHELL.list_menu(MENU_OPTS)
            action = Cli.make_page(func=f)
            if action == 1:
                scriptname = choose_file(SCRIPT_LIST)
                MENU_OPTS.items[0] = scriptname
            elif action == 2:
                shell_name = select_shell(SHELL_LIST)
                MENU_OPTS.items[1] = shell_name
            elif action == 3:
                pass
            elif action == 4:
                try:
                    run_script(scriptname, shell_name)
                except KeyboardInterrupt:
                    continue
            elif action == 5:
                open_in_editor(scriptname)
            elif action == 6:
                sys.exit(0)
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:27,代码来源:run2.py

示例3: work_with_p_files

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def work_with_p_files(cartesian):
    """
    Writes instance to pickle file or loads instance from pickle file.
    """
    #global file_list, pickle_list

    if ARGS and ARGS.infile:
        infile = ARGS.infile
    else:
        infile = 'save.p'

    current_dir = os.getcwd()
    file_list = os.listdir(current_dir)
    filemenu_list = ['..', 'save as pickle', 'open a pickle file']

    if infile in file_list:
        filemenu_list.append("reopen '" + infile + "'")
    menu1 = PlainList(filemenu_list)
    #pickle_list = []
    sel1 = Cli.make_page('pickle', cartesian, lambda: SHELL.list_menu(menu1))
    if sel1 == 2:
        cartesian.save_p_file(BASENAME)
    elif sel1 != 1:
        cartesian = Cli.open_p_file()
    return cartesian
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:27,代码来源:gocalc.py

示例4: access_gnugo_functs

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
    def access_gnugo_functs(self, basename):
        """
        Scoring/estimating tools from gnugo; this should take filename instead.
        """
        Cli.make_page(
            'WRITE FILE: {}.sgf'.format(basename), self, lambda: self.write_sgf(
            basename))

        menu1 = ListPrompt(['..', 'fast', 'medium', 'slow'])
        sel1 = Cli.make_page('MENU: GNUGO Scoring Tools', self, menu1.input)
        gnugo_dict = {'fast':'estimate', 'medium':'finish', 'slow':'aftermath'}
        print('') #pylint: disable=C0325
        if sel1 != 1:
            os.system('gnugo --score ' + gnugo_dict[menu1.items[sel1 - 1]] +\
                      ' --quiet -l {}.sgf'.format(basename))
            Cli.wait()
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:18,代码来源:igo.py

示例5: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def main():
    """
    Lets user browse and preview skins for the Goban class.
    """
    goban = Goban(sh_obj=SHELL, size=9)

    if __name__ == '__main__':
        while True:
            choice = Cli.make_page(func=lambda: SHELL.list_menu(LIST_OBJ))
            skinfile = LIST_OBJ[choice - 1]
            try:
                if SHELL.py_version == 2:
                    goban.skin_dict = json.load(open('skins/' + skinfile, 'rb'))
                elif SHELL.py_version == 3:
                    file_ptr = open('skins/{}'.format(skinfile), 'rb')
                    text_buffer = file_ptr.read().decode('utf-8')
                    goban.skin_dict = json.loads(text_buffer)
            except IOError:
                Cli.text_splash(Cli.box("File Error with '{}'".format(
                    skinfile)), duration=0)
                SHELL.wait()
                continue
            goban.cursor = [0, 0]
            Cli.text_splash("== Now give '{}' a try! ==".format(
                skinfile), duration=1, flashes=4)
            goban.view_edit()
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:28,代码来源:goban_preview.py

示例6: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def main():
    """
    Feed fortunes to the selected ASCII character.
    """
    parse_help_flag()
    Cli()
    cow = ''
    message1 = define_text()
    cow_num = Cli.make_page('UP NEXT: {}'.format(message1), '', MENU_FUNC)

    while True:
        message2 = message1
        message1 = define_text()
        cow = LIST_OBJ[cow_num - 1]
        ascii_cow = subprocess.check_output(
            'echo "{}"|cowsay -f {}'.format(message2, cow), shell=True)
        ascii_cow = "\n\n{}\n\n".format(ascii_cow)
        Cli.make_page('UP NEXT: {}'.format(message1), ascii_cow, Cli.wait)
        cow_num = Cli.make_page('UP NEXT: {}'.format(message1), '', MENU_FUNC)
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:21,代码来源:cowscript.py

示例7: select_shell

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def select_shell(shell_list_):
    """
    Select shell to use.
    """
    if SHELL.interface == 'bash':
        listobj = AbstractList(shell_list_)
        shell_menu = lambda: SHELL.list_menu(listobj)
        number = Cli.make_page(func=shell_menu)
        shell_name_ = shell_list_[number - 1]
    elif SHELL.interface == 'Tk':
        shell_name_ = shellvar.get().strip()
    return shell_name_
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:14,代码来源:run2.py

示例8: graph_operations

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def graph_operations(cartesian):
    """
    Functions relating to the board: edit it, trash it, view it with an
    external viewer.
    """
    plane_response = Cli.make_page(
        'MENU: Plane', cartesian, lambda: SHELL.list_menu(PLANE_OPTS))

    if plane_response == 2:
        cartesian.view_edit()
    elif plane_response == 3:
        try:
            color = cartesian.color_chooser()
            cartesian.fill(color)
        except KeyboardInterrupt:
            pass
    elif plane_response == 4:
        if ARGS and ARGS.external:
            Cli.make_page(
                'FILE: {}.sgf'.format(BASENAME), cartesian,
                lambda: cartesian.write_sgf(BASENAME))

            # View board (with external app).  If gnugo is specified, append the
            #appropriate flags.
            if ARGS and ARGS.external == 'gnugo':
                proc = subprocess.Popen(
                    'gnugo --mode ascii --quiet -l {}.sgf'.format(BASENAME),
                    shell=True)
            else:
                proc = subprocess.Popen(
                    '{} {}.sgf'.format(ARGS.external, BASENAME), shell=True)
            proc.wait()

        # Trash board and create a new one the same size
        else:
            cartesian = _make_graph()
    elif plane_response == 5:
        cartesian = _make_graph()
    return cartesian
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:41,代码来源:gocalc.py

示例9: choose_file

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def choose_file(script_list_):
    """
    Choose file to run.
    """
    if SHELL.interface == 'Tk':
        val = menu1.curselection()
        scriptname_ = script_list_[val[0]]

    elif SHELL.interface == 'bash':
        listobj = AbstractList(script_list_)
        script_menu = lambda: SHELL.list_menu(listobj)
        number = Cli.make_page(func=script_menu)
        scriptname_ = script_list_[number - 1]
    return scriptname_
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:16,代码来源:run2.py

示例10: file_actions

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def file_actions(cartesian):
    """
    work with files: open or save
    """
    sel1 = Cli.make_page(
        'MENU: File Actions', cartesian, lambda: SHELL.list_menu(FILE_OPTS))
    if sel1 == 2:
        cartesian.write_txt(BASENAME)
    elif sel1 == 3:
        cartesian.write_sgf(BASENAME)
    elif sel1 == 4:
        cartesian.save_p_file(BASENAME)
    elif sel1 == 5:
        cartesian = Cli.open_p_file()  # A = A.__class__.open_p_file()
    elif sel1 == 6:
        cartesian = work_with_p_files(cartesian)
    return cartesian
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:19,代码来源:gocalc.py

示例11: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def main():
    """
    Gets the user's choice and gives them a preview.
    """
    _first_pass = True
    art = ''
    if __name__ == '__main__':
        while True:
            if SHELL.interface in ['dialog'] and not _first_pass:
                Cli.wait()
            else:
                _first_pass = False
            #selection = Cli.make_page(obj='\n' + art, func=menu_func)
            selection = Cli.make_page(
                obj='\n' + art, func=lambda: SHELL.list_menu(LIST_OBJ))
            if selection == -1:
                break
            figlet_font = FONT_OPTIONS[selection - 1]
            art = subprocess.check_output('toilet --gay -f {} "{}"'.format(
                figlet_font, PHRASE), shell=True)
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:22,代码来源:toilet_preview.py

示例12: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def main():
    """
    user can create a collection of Thing objects
    """
    things = []
    label_pile = [str(thing) for thing in things]
    enum = Enumeration(label_pile, 'Inventory')

    # Start Screen
    SHELL.welcome(
        'Things',
        'This is a test/demonstration of my cjh.shell module and Thing class.')
    print('')  # pylint: disable=C0325
    selection = SHELL.list_menu(MAIN_MENU)

    while True:
        if selection == 1:
            name = form(
                enum, selection, lambda: SHELL.input('\nName of thing: '))
            something = Thing()
            something.label = name
            things.append(something)
        elif selection == 2:
            form(enum, selection, Cli.wait)
        elif selection == 3:
            discard_menu = ListPrompt(label_pile)
            if len(things) > 0:
                print('Choose a <Thing> to Discard.')  # pylint: disable=C0325
                discard = form(
                    enum, selection, lambda: discard_menu.input(hidden=True))
                things.remove(things[discard - 1])
        elif selection == 4:
            print('\n')  # pylint: disable=C0325
            sys.exit('Good bye.')

        label_pile = [str(thing) for thing in things]
        enum = Enumeration(label_pile, 'Inventory')
        selection = Cli.make_page(
            header='Main Menu', obj=str(enum) + Cli.hrule(
            width=.333, string=True),
            func=lambda: SHELL.list_menu(MAIN_MENU))
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:43,代码来源:thing_test.py

示例13: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def main():
    """
    the main function
    """
    #fx_list = []

    if ARGS is not None and ARGS.quiet is False:
        SHELL.welcome(
            script_name='== simple graph calc ==',
            description='A simple text-based graphing calculator.')

    graph = _make_graph()

    # if there is an --infile, open graph in editor
    if ARGS is not None and ARGS.infile is True:
        graph.view_edit()

    # Main Loop
    while True:
        if SHELL.interface in ['bash']:
            Cli.clear()

        # Will this work on SL4A?
        main_response = Cli.make_page(
            'MENU: Main', graph, lambda: SHELL.list_menu(MAIN_OPTS))
        print(main_response)

        #use try keyboard interrupt
        if main_response == 1:
            graph = graph_operations(graph)
        elif main_response == 2:
            graph = functions_menu(graph)
        elif main_response == 3:
            graph.access_gnugo_functs(BASENAME)
        elif main_response == 4:
            graph = file_actions(graph)
        else:
            break
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:40,代码来源:gocalc.py

示例14: form

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def form(enum, selection, function):
    """
    print appropriate header and page content, then run function f
    """
    return Cli.make_page(
        header=MENU_OPTIONS[selection - 1], obj=str(enum), func=function)
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:8,代码来源:thing_test.py

示例15: functions_menu

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import make_page [as 别名]
def functions_menu(cartesian):
    """
    Add/View Functions
    """
    while True:
        funct_response = Cli.make_page(
            'MENU: Functions', cartesian, lambda: SHELL.list_menu(FUNCT_OPTS))
        if funct_response == 1:
            break
        elif funct_response == 2:
            # List attached functions--currently Polynoms only
            Cli.make_page('view functions', cartesian, cartesian.list_functs)
        elif funct_response == 3:
            # Auto-Shapes
            menu2 = PlainList(['..', 'ellipse', 'sine wave'])
            while True:
                sel2 = Cli.make_page(
                     'auto-shapes', cartesian, lambda: SHELL.list_menu(menu2))
                if sel2 == 1:
                    break
                if sel2 == 2:

                    # Ellipses/Circles
                    menu3 = PlainList(['..', 'circle', 'ellipse'])

                    # Perhaps the interface should not be like this and it
                    # should return all the way up to the 'Functions' menu?
                    # But maybe it's good as it is.
                    while True:
                        sel3 = Cli.make_page(
                             'plot an ellipse', cartesian,
                             lambda: SHELL.list_menu(menu3))
                        if sel3 == 1:
                            break
                        if sel3 == 2:
                            try:
                                color = cartesian.color_chooser()
                                Cli.make_page(
                                    'circles', cartesian,
                                    lambda: cartesian.prompt_circle(color))
                            except KeyboardInterrupt:
                                pass
                        elif sel3 == 3:
                            try:
                                color = cartesian.color_chooser()
                                Cli.make_page(
                                    'ellipse', cartesian,
                                    lambda: cartesian.prompt_ellipse(color))
                            except KeyboardInterrupt:
                                pass
                elif sel2 == 3:

                    # Sine Waves
                    try:
                        color = cartesian.color_chooser()
                        main_text = refresh_main_table(cartesian)
                        Cli.make_page(
                            'plot a sine wave', main_text,
                            lambda: cartesian.prompt_wave(color))
                    except KeyboardInterrupt:
                        pass

        elif funct_response == 4:
            cartesian.add_polynomial()
        elif funct_response == 5:
            try:
                color = cartesian.color_chooser()
                main_text = refresh_main_table(cartesian)
                Cli.make_page(
                    'plot a point', main_text, lambda: cartesian.prompt_point(
                    color))
            except KeyboardInterrupt:
                pass
    return cartesian
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:76,代码来源:gocalc.py


注:本文中的cjh.cli.Cli.make_page方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。