fork download
  1. # def each_key(layout):
  2. # from itertools import accumulate
  3. # from operator import itemgetter
  4. #
  5. # for row,xs in enumerate(layout):
  6. # column_indices = [0] + list(accumulate(map(itemgetter(1),xs)))
  7. # for column,(key,keylen) in zip(column_indices,xs):
  8. # yield row,column,key,keylen
  9.  
  10.  
  11. def each_key(layout):
  12. for row,xs in enumerate(layout):
  13. column = 0
  14. for key,keylen in xs:
  15. yield row,column,key,keylen
  16. column += keylen
  17.  
  18. def main():
  19. ...
  20.  
  21. for row,column,key,keylenin in each_key(layout):
  22. button = Button(root, text=key,command=press).grid(sticky="news", columnspan=keylen, row=row, column=column)
  23.  
Success #stdin #stdout 0.02s 5760KB
stdin
Standard input is empty
stdout
Standard output is empty