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


Python Console.get_menu_choice方法代码示例

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


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

示例1: main

# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_menu_choice [as 别名]
def main():
    functions = dict(a=add_dvd, e=edit_dvd, l=list_dvds,
                     d=list_directors, r=remove_dvd, i=import_,
                     x=export, q=quit)
    filename = os.path.join(os.path.dirname(__file__), "dvds.sdb")
    db = None
    try:
        db = connect(filename)
        action = ""
        while True:
            count = dvd_count(db)
            print("\nDVDs ({0})".format(os.path.basename(filename)))
            if action != "l" and 1 <= count < DISPLAY_LIMIT:
                list_dvds(db)
            else:
                print("{0} dvd{1}".format(count, Util.s(count)))
            print()
            menu = ("(A)dd  (E)dit  (L)ist  (D)irectors  (R)emove  "
                    "(I)mport  e(X)port  (Q)uit"
                    if count else "(A)dd  (I)mport  (Q)uit")
            valid = frozenset("adelrixq" if count else "aiq")
            action = Console.get_menu_choice(menu, valid,
                                        "l" if count else "a", True)
            functions[action](db)
    finally:
        if db is not None:
            db.close()
开发者ID:178220709,项目名称:PyHello,代码行数:29,代码来源:dvds-sql.py

示例2: main

# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_menu_choice [as 别名]
def main():
    functions = dict(a=add_dvd, e=edit_dvd, l=list_dvds,
                     r=remove_dvd, i=import_, x=export, q=quit)
    filename = os.path.join(os.path.dirname(__file__), "dvds.dbm")
    db = None
    try:
        db = shelve.open(filename, protocol=pickle.HIGHEST_PROTOCOL)
        action = ""
        while True:
            print("\nDVDs ({0})".format(os.path.basename(filename)))
            if action != "l" and 1 <= len(db) < DISPLAY_LIMIT:
                list_dvds(db)
            else:
                print("{0} dvd{1}".format(len(db), Util.s(len(db))))
            print()
            menu = ("(A)dd  (E)dit  (L)ist  (R)emove  (I)mport  "
                    "e(X)port  (Q)uit"
                    if len(db) else "(A)dd  (I)mport  (Q)uit")
            valid = frozenset("aelrixq" if len(db) else "aiq")
            action = Console.get_menu_choice(menu, valid,
                                        "l" if len(db) else "a", True)
            functions[action](db)
    finally:
        if db is not None:
            db.close()
开发者ID:178220709,项目名称:PyHello,代码行数:27,代码来源:dvds-dbm.py

示例3: main

# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_menu_choice [as 别名]
def main():
    functions = dict(a=add_record, l=list_records,
                     m=list_machines, r=remove_record, i=import_,
                     d=initialize_discrete_table, q=quit)
    filename = os.path.join(os.path.dirname(__file__), "records.sdb")
    db = None
    try:
        db = connect(filename)
        action = ""
        while True:
            count = record_count(db)
            print("\nRecords ({0})".format(os.path.basename(filename)))
            if action != "l" and 1 <= count < DISPLAY_LIMIT:
                list_records(db)
            else:
                print("{0} record{1}".format(count, Util.s(count)))
            print()
            menu = ("(A)dd (L)ist  (M)achines  (R)emove  "
                    "(I)mport (D)iscretize (Q)uit"
                    if count else "(A)dd  (I)mport  (Q)uit")
            valid = frozenset("almridq" if count else "aiq")
            action = Console.get_menu_choice(menu, valid,
                                        "l" if count else "a", True)
            functions[action](db)
    finally:
        if db is not None:
            db.close()
开发者ID:crobertob,项目名称:RST,代码行数:29,代码来源:dreduct.py

示例4: main

# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_menu_choice [as 别名]
def main():
    functions = dict(a=all_employee, r=list_report, m=list_manager, q=quit_app)
    con = None

    try:
        # connect to hostName, userName, password, databaseName
        con = mdb.connect("localhost", "testuser", "test623", "testdb")
        cur = con.cursor()
        initDB(con, cur)

        print("\nManager and his/her reports:\n")
        all_employee(cur)

        action = ""
        while True:
            print()
            menu = " (A)llEmployee  List(R)eport  List(M)anager  (Q)uit"
            action = Console.get_menu_choice(menu, "armq", "q", True)
            functions[action](cur)
    except mdb.Error as e:
        print("Error %d: %s", e.args[0], e.args[1])
        sys.exit(1)
    finally:
        if con is not None:
            con.close()
开发者ID:hangang128,项目名称:PythonMysql,代码行数:27,代码来源:EmployeeManager.py

示例5: main

# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_menu_choice [as 别名]
def main():
    if len(sys.argv) > 1:
        Address[0] = sys.argv[1]
    call = dict(c=get_car_details, m=change_mileage, o=change_owner,
                n=new_registration, s=stop_server, q=quit)
    menu = ("(C)ar  Edit (M)ileage  Edit (O)wner  (N)ew car  "
            "(S)top server  (Q)uit")
    valid = frozenset("cmonsq")
    previous_license = None
    while True:
        action = Console.get_menu_choice(menu, valid, "c", True)
        previous_license = call[action](previous_license)
开发者ID:178220709,项目名称:PyHello,代码行数:14,代码来源:car_registration_ans.py

示例6: main

# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_menu_choice [as 别名]
def main():
    functions = dict(a=add_bookmark, e=edit_bookmark, l=list_bookmarks,
                     r=remove_bookmark, q=quit)
    filename = os.path.join(os.path.dirname(__file__), "bookmarks.dbm")
    db = None
    try:
        db = shelve.open(filename, protocol=pickle.HIGHEST_PROTOCOL)
        action = ""
        while True:
            print("\nBookmarks ({0})".format(os.path.basename(filename)))
            list_bookmarks(db)
            print()
            menu = "(A)dd  (E)dit  (L)ist  (R)emove  (Q)uit"
            action = Console.get_menu_choice(menu, "aelrq",
                                        "l" if len(db) else "a", True)
            functions[action](db)
    finally:
        if db is not None:
            db.close()
开发者ID:178220709,项目名称:PyHello,代码行数:21,代码来源:bookmarks.py

示例7: main

# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_menu_choice [as 别名]
def main():
    if len(sys.argv) > 1:
        address[0] = sys.argv[1]
    call = dict(s=get_club_state, gg=get_genres, ag=add_genre, dg=delete_genre,
                gd=get_dances, ad=add_dance, dd=delete_dance, gm=get_musics,
                am=add_music, dm=delete_music, gc=get_clients, ac=add_client,
                lc=load_clients, dc=delete_client, o=open_club, c=close_club, q=quit)
    menu = ("Get club (s)tate\n"
            "(gg)Get genres    (ag)Add genre   (dg)Delete genre\n"
            "(gd)Get dance     (ad)Add dance   (dc)Delete dance\n"
            "(gm)Get musics    (am)Add music   (dm)Delete music\n"
            "(gc)Get clients   (ac)Add client  (dc)Delete client\n"
            "(lc)Load clients\n"
            "(O)pen club       (C)lose club    (Q)uit")
    valid = set(call.keys())
    action = "cs"
    while True:
        action = Console.get_menu_choice(menu, valid, action, True)
        call[action]()
开发者ID:singatullinmt,项目名称:club,代码行数:21,代码来源:club-client.py


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