SHARE
TWEET

Python - lines in grid

furas May 28th, 2018 (edited) 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##################################################################
  2. # using: padx=(1,0), pady=(1,0)
  3. ##################################################################
  4.  
  5. import tkinter as tk
  6.  
  7. root = tk.Tk()
  8. root['bg'] = 'black'
  9.  
  10. for c in range(10):
  11.     for r in range(10):
  12.         txt = "({},{})".format(r,c)
  13.         l = tk.Label(root, text=txt)
  14.         #l.grid(row=r, column=c, padx=(1,0), pady=(1,0))
  15.  
  16.         # skip external lines
  17.         px = (1,0) if c > 0 else (0,0)
  18.         py = (1,0) if r > 0 else (0,0)
  19.         l.grid(row=r, column=c, padx=px, pady=py)
  20.  
  21. root.mainloop()
  22.  
  23. ##################################################################
  24. # using: borderwidth=1, relief="solid"
  25. # (internal lines have size 2px, external lines have size 1px)
  26. ##################################################################
  27.  
  28. import tkinter as tk
  29.  
  30. root = tk.Tk()
  31. root['bg'] = 'black'
  32.  
  33. for c in range(10):
  34.     for r in range(10):
  35.         txt = "({},{})".format(r,c)
  36.         l = tk.Label(root, text=txt, borderwidth=1, relief="solid")
  37.         l.grid(row=r, column=c)
  38.  
  39. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top