Exemplo n.º 1
0
def buildPopupMenu(items):
    "Serializes out popup menu items in binary format. items is a list of tuples, "
    "each tuple looking like that: (caption, hyperlink, inactive, bold, separator). "
    "caption, hyperlink - string; inactive, bold, separator - bolean."
    assert items is not None
    count = len(items)
    res = "menu:" + longtob(count)
    for caption, hyperlink, inactive, bold, separator in items:
        res += stringToBytes(caption)
        res += stringToBytes(hyperlink)
        flags = 0
        if inactive:
            flags += 1
        if bold:
            flags += 2
        if separator:
            flags += 4
        res += longtob(flags)
    return res
Exemplo n.º 2
0
def buildPopupMenu(items):
    'Serializes out popup menu items in binary format. items is a list of tuples, '
    'each tuple looking like that: (caption, hyperlink, inactive, bold, separator). '
    'caption, hyperlink - string; inactive, bold, separator - bolean.'
    assert items is not None
    count = len(items)
    res = "menu:" + longtob(count)
    for caption, hyperlink, inactive, bold, separator in items:
        res += stringToBytes(caption)
        res += stringToBytes(hyperlink)
        flags = 0
        if inactive:
            flags += 1
        if bold:
            flags += 2
        if separator:
            flags += 4
        res += longtob(flags)
    return res
Exemplo n.º 3
0
def stringToBytes(str):
    count = len(str)
    res = longtob(count)
    res += str
    res += "\0"
    return res
Exemplo n.º 4
0
def stringToBytes(str):
    count = len(str)
    res = longtob(count)
    res += str
    res += '\0'
    return res