Advertisement
cd62131

tkinter grid layout

Dec 1st, 2018
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import tkinter
  3. root = tkinter.Tk()
  4. a = [[1, 2, 3], [5, 6, 7]]
  5. for i in range(len(a)):
  6.     for j in range(len(a[i])):
  7.         tkinter.Label(
  8.             root, text=str(a[i][j]), fg='white', bg='red', padx=20,
  9.             pady=20).grid(
  10.                 column=i, row=j, padx=3, pady=3)
  11. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement