Saturday, December 21, 2019

tkinter nested for loop in python

# !/usr/bin/python3
from  tkinter import *
root = Tk(  )
b = 0
for r in range(6):
   for c in range(6):
      b = b + 1
      Button(root, text = str(b), borderwidth = 1 ).grid(row = r,column = c)

root.mainloop()

output:

No comments:

Post a Comment

python class topic video