from make_small_images import UNSHIFTED, SHIFTED def print_key_locations(data, charlist, varname): locs = [] for row in range(5): for col in range(10): top = 30 + (row * 31) left = 1 + (col * 24) item = (row * 10) + col itemname = charlist[item] height = 31 # special handling for space bar if itemname == "space": width = 118 elif itemname == "discard": continue else: width = 22 locs += [itemname, left, top, left+width, top+height] repl = "{ %s }" % " ".join([str(x) for x in locs]) return data.replace(varname, repl) if __name__ == "__main__": fp = open("keyboard.hecl.template") data = fp.read() fp.close() data = print_key_locations(data, UNSHIFTED, "%%UNSHIFTEDLETTERS%%") data = print_key_locations(data, SHIFTED, "%%SHIFTEDLETTERS%%") fp = open("keyboard.hecl", "w") fp.write(data) fp.close()