neng屎所有人怯邪,就沒有人發(fā)現(xiàn)我潛入了
周末了蝉娜,放個假休息休息缔莲,就再來更新一篇哥纫!
之前介紹的腳本以"腳本的感覺"來實現(xiàn)的,今天我們來介紹一下"系統(tǒng)級別"的腳本痴奏!
一蛀骇、FBMenu
Menu菜單基本位于軟件的頂層顯示,通常以下拉菜單的形式呈現(xiàn)
我們來看一下UI效果
FBMenu.gif
這里展示了執(zhí)行腳本之后抛虫,在MoBu的菜單欄上方會出現(xiàn) New Menu的選項松靡,其中包含了兩個選項,以及一個下拉列表 建椰,我們來看一下官方代碼:
from pyfbsdk import *
# This function just prints the infos of the menu that has been clicked.
def eventMenu(control, event):
print control, event.Id, event.Name
gMenuMgr = FBMenuManager()
# --------------------------- "File/CustomFileIO" -----------------------------
# Inserts an item inside the File menu.
gMenuMgr.InsertFirst("File", "CustomFileIO")
# Inserts three 'sub-items' under the newly created menu item File/CustomFileIO.
lFileIO1 = gMenuMgr.InsertLast("File/CustomFileIO", "Operation 1")
lFileIO2 = gMenuMgr.InsertLast("File/CustomFileIO", "Operation 2")
lFileIO3 = gMenuMgr.InsertLast("File/CustomFileIO", "Operation 3")
# Removes the third sub-item.
lCustomFileIOMenu = gMenuMgr.GetMenu( "File/CustomFileIO" )
lCustomFileIOMenu.DeleteItem( lFileIO3 )
# ------------------------------- "New Menu" ----------------------------------
# Inserts a new menu in the topmost menu bar (Set pMenuPath=None to add menu at topmost level).
gMenuMgr.InsertFirst(None, "New Menu")
lNewMenu = gMenuMgr.GetMenu("New Menu")
lNewMenu.InsertLast("Fancy operation 1", 11)
lNewMenu.InsertLast("Fancy operation 2", 12)
# Registers event handler.
lNewMenu.OnMenuActivate.Add(eventMenu)
# Creates a new embedded menu.
lSubMenu = FBGenericMenu()
lSubMenu.InsertFirst("Three", 3)
lSubMenu.InsertFirst("Two", 2)
lSubMenu.InsertFirst("One", 1)
lSubMenu.OnMenuActivate.Add(eventMenu)
# Inserts the embdded menu in the New Menu
lNewMenu.InsertLast("An embedded Menu", 101, lSubMenu)
# --------------------------- "Add menu before/after" ---------------------------
gMenuMgr.InsertBefore(None, "Help", "Before Help")
gMenuMgr.InsertAfter(None, "Help", "After Help")
# ------------------------------- "Pop-up menu" ---------------------------------
lItem = lSubMenu.Execute(100, 200)
if lItem:
print "Pop-up menu: Selected item = %s.\n" % lItem.Caption
else:
print "Pop-up menu: No item selected.\n"
比較有用雕欺,大家可以好好看一看,decomposition and refactor!
二棉姐、結(jié)語
有什么問題可以留言屠列!
繼續(xù)!
共勉伞矩!