Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- root = tk.Tk()
- main_frame = tk.Frame(root)
- main_frame.pack()
- fs = [] # list to keep all frames (but I don't use it in this example)
- for r in range(10): # (r)ow
- # create frame to keep labels in row
- f = tk.Frame(main_frame)
- f.grid(row=r)
- # keep frame on list to use it later (to move or remove it)
- fs.append( f )
- # add some labels in frame in one row
- for c in range(10): #(c)olumn
- t = '| {}.{} |'.format(r, c)
- l = tk.Label(f, text=t)
- l.grid(row=0, column=c)
- # add button to remove frame
- b = tk.Button(f, text='Delete', command=lambda x=f:x.grid_forget())
- b.grid(row=0, column=10)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement