## Posted By

maturanti19 on 05/22/19

# Konfetti a zadaj pocet kruzkov s tlacidlom sa pridaju a zaverecne titulky

/ Published in: Python

Uzivatel zada pocet kruzkov ktore sa vytvoria kliknutim na gombik a ked klikne len tak tak mu urobi jeden farebny kruzok akoze konfetti a zaverecne titulky ktore sa hybu smerom hore

`import tkinterfrom random import * canvas = tkinter.Canvas(height=600, width=800, bg='gainsboro')canvas.pack() def kruzok(suradnice):    x=suradnice.x    y=suradnice.y    farba = choice(('thistle', 'skyblue', 'indigo', 'white', 'gray', 'violet', 'salmon'))    canvas.create_oval(x-10, y-10, x+10, y+10, fill=farba, width=3) def kruzky(n):    for i in range(n):        x=randrange(100,700)        y=randrange(100,500)        canvas.create_oval(x-20, y-20, x+20, y+20, outline='navy', width=2) def kruhy():    pocet=int(entry.get())    kruzky(pocet) def zmaz():     canvas.delete('all') def posun(parameter):    canvas.delete('all')##    global x1 ak chcem aby sa pamatala premenna    x1=200    global y1    y1=y1-5    canvas.create_text(x1,y1, text='Zaverecne titulky') #pocet= int(input('Zadaj pocet kruzkov: ')) entry=tkinter.Entry()entry.pack() button=tkinter.Button(text='Zadaj pocet', command=kruhy)button.pack() button2=tkinter.Button(text='Zmaz vsetko', command=zmaz)button2.pack() x1=200y1=500canvas.create_text(x1,y1, text='Zaverecne titulky') canvas.bind('<Button-1>', kruzok)canvas.bind_all('<Up>', posun) #kruzky(pocet)`