Advertisement
here2share

# Tk_graphchart.py

Sep 6th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # Tk_graphchart.py
  2. from Tkinter import *
  3. import random
  4.  
  5. root = Tk()
  6.  
  7. cw = 650
  8. ch = 500
  9.  
  10. c = Canvas(width=cw, height=ch, background="white")
  11. c.pack()
  12.  
  13. c.create_line(10, ch, cw, ch)
  14. c.create_line(10, 0, 10, ch)
  15.  
  16. for a, b in zip(range(100, ch, 100), range(100, 0, -25)):
  17.     c.create_line(0, a, 20, a)
  18.     c.create_text(30, a, text=str(b))
  19.  
  20. x = 50
  21. y = 70
  22.  
  23. bars = [random.randint(1, 100) for i in range(12)]
  24. limit = x * len(bars)
  25.  
  26. while x <= limit:
  27.     for i in bars:
  28.         c.create_rectangle(x, ch-(i*4),
  29.                            y, ch,
  30.                            outline="black",
  31.                            fill="royalblue")
  32.         x += 50
  33.         y += 50
  34.  
  35. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement