Posted By

maturanti19 on 05/22/19


Tagged

python tree with create etc in and Blue Flower Sky krajinka


Versions (?)

Krajinka


 / Published in: Python
 

Vytvorte krajinku v pythone

  1. import tkinter
  2. from random import *
  3.  
  4. canvas = tkinter.Canvas(height=600, width=800, bg='skyblue')
  5. canvas.pack()
  6.  
  7. def strom(x,y):
  8. #kmen
  9. canvas.create_line(x,y,x,y-150, fill='chocolate', width=5)
  10.  
  11. #konare
  12. for i in range(10):
  13. b=y-randrange(0,150)
  14. canvas.create_line(x,b,x+randrange(-50,+50),b-30, fill='chocolate', width=2)
  15.  
  16. for i in range(20):
  17. strom(randrange(50,700), randrange(150,800))
  18.  
  19. def trs(x,y):
  20. #stonka
  21. canvas.create_line(x,y,x,y-50, fill='green', width=2)
  22. for i in range(20):
  23. #trava
  24. canvas.create_line(x,y,x+randrange(-40,40),y+randrange(-40,0), fill='green', width=2)
  25. #kvet
  26. for i in range(40):
  27. canvas.create_line(x, y-50, x+randrange(-40,40), y-50+randrange(-40,40), fill='yellow', width=1)
  28. for i in range(20):
  29. trs(randrange(50, 850), randrange(100, 800))

Report this snippet  

You need to login to post a comment.