Similar presentations:
1_курс
1.
2.
from tkinter import *# Размеры окна
Breadth = 500
Highness = 330
# Функция события
def buttonClick() :
Graphic.create_rectangle(20, 20, Breadth-20, Highness-20)
Graphic.create_oval(20, 20, Breadth-20, Highness-20)
Graphic.create_line(Breadth/2, 20, Breadth/2, Highness-20)
Graphic.create_line(20, Highness/2, Breadth-20, Highness/2)
#Основная программа
Window = Tk()
Window.title("Графика")
Window.config(width=Breadth, height=Highness)
Graphic = Canvas(Window, width=Breadth, height=Highness)
Graphic.pack()
Button = Button(Window, text="Посмотреть!", command=buttonClick)
Button.place(x=Breadth/2-60, y=Highness/2-15, width=120, height=30)
Window.mainloop()
3.
РЕЗУЛЬТАТ4.
from tkinter import *import random
# Размеры окна
Breadth = 500
Highness = 330
# Функция события
def buttonClick() :
for Nr in range(0,84) :
Color = ["gray", "black", "red", "green", "blue", "cyan", "yellow", "magenta"]
Dye = Color[random.randint(0,7)]
Graphic.create_line(0, Nr*4, Breadth, Highness-Nr*4, fill=Dye)
Graphic.create_line(Nr*6, 0, Breadth-Nr*6, Highness, fill=Dye)
#Основная программа
Window = Tk()
Window.title("Графика")
Window.config(width=Breadth, height=Highness)
Graphic = Canvas(Window, width=Breadth, height=Highness)
Graphic.pack()
Button = Button(Window, text="Посмотреть!", command=buttonClick)
Button.place(x=Breadth/2-60, y=Highness/2-15, width=120, height=30)
Window.mainloop()
5.
6.
# Графика в Pythonfrom tkinter import *
import random
# Размеры окна
Breadth = 500
Highness = 330
# Константы цвета
Color = ["gray", "black", "red", "green","blue", "cyan", "yellow", "magenta"]
# Функция события
def buttonClick() :
for Nr in range(0,48) :
Dye = Color[random.randint(0,7)]
Graphic.create_rectangle(Nr*4, Nr*3, Breadth-Nr*4,Highness-Nr*3, fill=Dye)
# Основная программа
Window = Tk()
Window.title("Графика")
Window.config(width=Breadth, height=Highness)
Graphic = Canvas(Window, width=Breadth, height=Highness)
Graphic.pack()
Button = Button(Window, text="Посмотреть!", command=buttonClick)
Button.place(x=Breadth/2-60, y=Highness/2-15, width=120, height=30)
Window.mainloop()
7.
8.
# Графика в Pythonfrom tkinter import *
import random
# Размеры окна
Breadth = 500
Highness = 330
# Константы цвета
Color = ["gray", "black", "red", "green","blue", "cyan", "yellow", "magenta"]
# Функция события
def buttonClick() :
for Nr in range(0,48) :
Dye = Color[random.randint(0,7)]
Graphic.create_oval(Nr*4, Nr*3, Breadth-Nr*4, Highness-Nr*3, fill=Dye)
# Основная программа
Window = Tk()
Window.title("Графика")
Window.config(width=Breadth, height=Highness)
Graphic = Canvas(Window, width=Breadth, height=Highness)
Graphic.pack()
Button = Button(Window, text="Посмотреть!", command=buttonClick)
Button.place(x=Breadth/2-60, y=Highness/2-15, width=120, height=30)
Window.mainloop()
9.
10.
# Графика в Pythonfrom tkinter import *
import random
# Размеры окна
Breadth = 500
Highness = 330
# Константы цвета
Color = ["gray", "black", "red", "green","blue", "cyan", "yellow", "magenta"]
# Функция события
def buttonClick() :
Dye = Color[random.randint(0,7)]
Point = [(20,Highness-20), (Breadth/2,20),
(Breadth-20,Highness-20)]
Graphic.create_polygon(Point, fill=Dye)
# Основная программа
Window = Tk()
Window.title("Графика")
Window.config(width=Breadth, height=Highness)
Graphic = Canvas(Window, width=Breadth, height=Highness)
Graphic.pack()
Button = Button(Window, text="Посмотреть!", command=buttonClick)
Button.place(x=Breadth/2-60, y=Highness/2-15, width=120, height=30)
Window.mainloop()
11.
12.
# Графика в Pythonfrom tkinter import *
import random
# Константы цвета
Color = ["white", "gray", "red", "green","blue", "cyan", "yellow", "magenta"]
# Функция события
def buttonClick() :
for Nr in range(0,300) :
x = random.randint(0,Breadth)
y = random.randint(0,Highness)
z = random.randint(2,15)
Dye = Color[random.randint(0,7)]
Graphic.create_oval(x,y, x+z, y+z, fill=Dye)
# Основная программа
Window = Tk()
Window.title("Графика")
Breadth = 700
Highness = 530
Window.config(width=Breadth, height=Highness)
Graphic = Canvas(Window, width=Breadth, height=Highness,background="black")
Graphic.pack()
Button = Button(Window, text="Посмотреть!", command=buttonClick)
Button.place(x=Breadth/2-60, y=Highness-40, width=120, height=30)
Window.mainloop()