Объяснение:
import tkinter as tk
# Создаем холст
canvas_width = 300
canvas_height = 300
canvas = tk.Canvas(width=canvas_width, height=canvas_height)
canvas.pack()
# Нарисуем тело слона
body = canvas.create_oval(50, 100, 250, 250, fill='gray', outline='black')
# Нарисуем голову слона
head = canvas.create_oval(200, 30, 280, 120, fill='gray', outline='black')
trunk = canvas.create_polygon(200, 120, 200, 220, 100, 220, 100, 120, fill='gray', outline='black')
ear = canvas.create_polygon(200, 60, 220, 30, 240, 60, fill='gray', outline='black')
# Нарисуем глаза слона
eye_1 = canvas.create_oval(220, 60, 240, 80, fill='white', outline='black')
pupil_1 = canvas.create_oval(228, 68, 232, 72, fill='black')
eye_2 = canvas.create_oval(260, 60, 280, 80, fill='white', outline='black')
pupil_2 = canvas.create_oval(268, 68, 272, 72, fill='black')
# Нарисуем ноги слона
leg_1 = canvas.create_rectangle(60, 220, 100, 250, fill='gray', outline='black')
leg_2 = canvas.create_rectangle(200, 220, 240, 250, fill='gray', outline='black')
leg_3 = canvas.create_rectangle(70, 250, 90, 280, fill='gray', outline='black')
leg_4 = canvas.create_rectangle(210, 250, 230, 280, fill='gray', outline='black')
# Запускаем главный цикл tkinter
tk.mainloop()
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Объяснение:
import tkinter as tk
# Создаем холст
canvas_width = 300
canvas_height = 300
canvas = tk.Canvas(width=canvas_width, height=canvas_height)
canvas.pack()
# Нарисуем тело слона
body = canvas.create_oval(50, 100, 250, 250, fill='gray', outline='black')
# Нарисуем голову слона
head = canvas.create_oval(200, 30, 280, 120, fill='gray', outline='black')
trunk = canvas.create_polygon(200, 120, 200, 220, 100, 220, 100, 120, fill='gray', outline='black')
ear = canvas.create_polygon(200, 60, 220, 30, 240, 60, fill='gray', outline='black')
# Нарисуем глаза слона
eye_1 = canvas.create_oval(220, 60, 240, 80, fill='white', outline='black')
pupil_1 = canvas.create_oval(228, 68, 232, 72, fill='black')
eye_2 = canvas.create_oval(260, 60, 280, 80, fill='white', outline='black')
pupil_2 = canvas.create_oval(268, 68, 272, 72, fill='black')
# Нарисуем ноги слона
leg_1 = canvas.create_rectangle(60, 220, 100, 250, fill='gray', outline='black')
leg_2 = canvas.create_rectangle(200, 220, 240, 250, fill='gray', outline='black')
leg_3 = canvas.create_rectangle(70, 250, 90, 280, fill='gray', outline='black')
leg_4 = canvas.create_rectangle(210, 250, 230, 280, fill='gray', outline='black')
# Запускаем главный цикл tkinter
tk.mainloop()