def Build(pMenuName, pFileName, pLabelList):
    '''
    Build menu from menu file
    The menu file may contain commands to set the current directory and to
    set specified environment variables.  This is done while the file is
    being read.  They are not dependent on the selected button.  The last 
    command encountered will be active.

    set environment variable name to value
        ;#set`name=value
    set current directory to path
        ;#cd`path
    '''
#
    lFile = open(pMenuName,'r')
    lFileText = lFile.readlines()
    lFile.close

    label = Tkinter.Label(frame, text=pFileName)
    label.pack(side=TOP, fill=X)
    lKeep = False
   
    for lText in lFileText:
        if len(lText) > 1:
            if lText[0] != "[":
                if lText[0] == "-":
                    pass
                    #label= Tkinter.Label(frame,text=lText[:-1])
                    #label.pack(side=TOP, fill=X)
                elif lText.startswith(";#"):        # <---- Special commands start with ;#
                    lPos = lText.find("`")          # <---- Fields are separated by `
                    if lPos > 0:
                        lCh = lText[2]
                        if lCh == 's':              # set environment variable
                            lEqPos = lText.find("=")
                            if lEqPos > lPos:
                                lKey = lText[lPos+1:lEqPos].strip()
                                lValue = lText[lEqPos+1:].strip()
                                os.environ[lKey] = lValue
                        elif lCh == 'c':            # set working directory
                            if lPos > 0 and lPos < len(lText):
                                os.chdir(lText[lPos+1:].strip())
                        else:                       # ignore
                            pass 
                elif lText[0] == ";":
                    pass
                elif lKeep == False:
                    pass
                else:
                    lPos = lText.find(",")
                    if lPos > 0:
                        lPrompt = lText[:lPos]
                        lCommand = lText[lPos+1:]

                        lCommand = Expand(lCommand, pFileName)
                        
                        mCmds[lPrompt] = lCommand
                        button = Tkinter.Button(frame,text=lPrompt)
                        button.pack(side=TOP,fill=X)
                        button.bind("<Button-1>", submitnow) ### (1)
                        button.bind("<Button-3>", showit)

            else:
                label = lText[1:-2].lower()
                if (label[0] < 'a') or (label[0] > 'z'):
                    label = label[1:]
                if pLabelList == [] or label in pLabelList:
                    lKeep = True
                    label = Tkinter.Label(frame,text=lText[1:-2], bg="yellow")
                    label.pack(side=TOP, fill=X)
                else:
                    lKeep = False

    Build menu from menu file
    The menu file may contain commands to set the current directory and to
    set specified environment variables.  This is done while the file is
    being read.  They are not dependent on the selected button.  The last 
    command encountered will be active.

    set environment variable name to value
        ;#set`name=value
    set current directory to path
        ;#cd`path
    
recipes/Python/577038_Simple_Buttonbar_Utility/recipe-577038.py