Пример #1
0
def newBlock():

    block = {}
    block["entry"] = tkinter.Frame( dropDownFields, bg=bgColor )
    block["entry"].pack( side = tkinter.TOP, anchor = "w" )
    block["PartStringVar"] = tkinter.StringVar()
    partName = sorted(asl_encoding.keys())[0]
    block["PartStringVar"].set( partName )
    block["ModifiersDropDown"] = []
    block["ModifiersLabel"] = []
    block["ModifiersStringVar"] = []

    top.buildingBlocks.append(block)
    binaryField.config( height = len(top.buildingBlocks) )
    setBlock(len(top.buildingBlocks)-1, partName)
Пример #2
0
def setBlock(index, partName):

    if (index >= len(top.buildingBlocks)):
        badWin = tkinter.Toplevel()
        badWin.title("Well, this is awkward...")

        msg = tkinter.Message(badWin, text="Something bad happend, please save or make note of your progress, and restart the application", width=350)
        msg.pack()

        button = tkinter.Button(badWin, text="OK", command=badWin.destroy)
        button.pack()

    block = top.buildingBlocks[index]

    block["PartStringVar"].set( partName )
    block["PartDropDown"] = tkinter.OptionMenu( block["entry"], block["PartStringVar"], *sorted(asl_encoding.keys()),
                                                command=lambda e: setBlock(index, e))
    block["PartDropDown"].config(bd=0, bg=buttonColor)
    block["PartDropDown"].grid( row = 0, column = 2 )

    for m in block["ModifiersDropDown"]:
        m.destroy()
    for l in block["ModifiersLabel"]:
        l.destroy()
    block["ModifiersDropDown"] = []
    block["ModifiersLabel"] = []
    block["ModifiersStringVar"] = []
    col_val = 3
    for m in asl_encoding[partName].modifiers:
        block["ModifiersLabel"].append( tkinter.Label( block["entry"], fg=fgColor, bg=bgColor, text=m.name ) )
        block["ModifiersLabel"][-1].grid( row = 0, column = col_val )
        block["ModifiersStringVar"].append( tkinter.StringVar() )
        block["ModifiersStringVar"][-1].set( m.values[0] )
        block["ModifiersDropDown"].append(tkinter.OptionMenu( block["entry"], block["ModifiersStringVar"][-1], *m.values, command=render ))
        block["ModifiersDropDown"][-1].config(bd=0, bg=buttonColor)

        block["ModifiersDropDown"][-1].grid( row = 0, column = col_val+1 )
        col_val += 2
    
    tkinter.Label( block["entry"], text=" ", fg=fgColor, bg=bgColor ).grid( row = 0, column = 1 )
    tkinter.Button( block["entry"], text="-", border=0, command=lambda : removeBlock(block) ).grid( row = 0, column = 0 )

        
    top.buildingBlocks[index] = block
    render(None)