Beispiel #1
0
def IsMenuExist(menuName='iKnot'):
    main_menu = kcs_gui.menu_get(None, 0)
    index=0
    while True:
        try:
            menu=kcs_gui.menu_item_get(main_menu, index)
            if menu[0]==menuName:
                return True
            index+=1
        except:
            return False
Beispiel #2
0
def GetMenus():
    main_menu = kcs_gui.menu_get(None, 0)
    index=0
    menus=[]
    while True:
        try:
            m=kcs_gui.menu_item_get(main_menu, index)
            menus.append((m[0],m[1],kcs_gui.menu_get(main_menu,index)))
            index+=1
        except 'kcs_IndexError':
            print 'error----------'
        except:
            return menus
Beispiel #3
0
def AddMenu(menuName, menuList):
    """initiate the menu.
    menuName:menu name
    menuList:[("sub menu name",
                ("caption", "script",'message'),
                ("caption", "script",'message'),
            ),
            ]
    """
    try:
        main_menu = kcs_gui.menu_get(None, 0)
        index = 0
        while 1:
            if kcs_gui.menu_item_get(main_menu, index)[0] == "&Help":
                break;
            elif kcs_gui.menu_item_get(main_menu, index)[0] == menuName:
                return
            else:
                index = index + 1;
                
        ktMenu = kcs_gui.menu_add(main_menu, index + 1, menuName)
        menuIndex = 0
        for menu in menuList:
            if len(menu) == 2 and isinstance(menu[1], str): 
                kcs_gui.menu_item_usr_add(ktMenu, menuIndex, menu[0], menu[1])
                menuIndex += 1
            elif len(menu) == 2 and menu[1] == -1:  # ·Ö¸ôÏß
                kcs_gui.menu_item_std_add(ktMenu, menuIndex, menu[0], menu[1])
                menuIndex += 1
            else:
                m = kcs_gui.menu_add(ktMenu, menuIndex, menu[0])
                subIndex = 0
                for submenu in menu[1:]:
                    kcs_gui.menu_item_usr_add(m, subIndex, submenu[0], submenu[1])
                    subIndex += 1
                menuIndex += 1
    except Exception, e:
        print e
Beispiel #4
0
def GetMenu(menuName):
    """
    return menu object by given name.
    if the name is not exist, create a new one and return.
    """
    main_menu = kcs_gui.menu_get(None, 0)
    index=0
    while True:
        menu=kcs_gui.menu_item_get(main_menu, index)
        if menu[0]==menuName:
            return kcs_gui.menu_get(main_menu,index)
        elif menu[0]=='&Help':
            return kcs_gui.menu_add(main_menu,index+1,menuName)
        elif index>100:
            return None
        else:
            index+=1