from base import * import struct __all__ = ['rMenuBar', 'rMenu', 'rMenuItem'] def to_char_string(x): if not x: return '""' if x in (0x0a, 0x0d): return "\\n" if x == ord('"'): return "\"" if x >= 32 and x < 0x7e: return '"' + chr(x) + '"' return "\\x{:02x}".format(x) class rMenuBar(rObject): rName = "rMenuBar" rType = 0x8008 def __init__(self, *children, id=None, attr=None): super().__init__(id, attr) self.children = children[:] for x in children: if not isinstance(x, rMenu): raise TypeError("bad type: {}".format(type(x))) def __bytes__(self): bb = struct.pack("= 1: self.itemChar = bb[0] self.altItemChar = bb[0] # upper to lower? if len(bb) >= 2: self.altItemChar = bb[1] if len(bb) > 2: raise ValueError("keys too long: {}".format(keys)) def __bytes__(self): itemID = self.itemID if itemID == None: itemID = self.get_id() bb = struct.pack("