Создать оконное приложение на языке python. Нужно создать сложное приложение!! Пожалуйста помогите, очень срочно. Даю 50 баллов!
Ответы
Ответ:
Смотри
Объяснение:
from tkinter import * # importejam tkinter
def mouth_open(): # atveram muti
c.itemconfig(mouth, fill="black")
def mouth_close(): # aizveram muti
c.itemconfig(mouth, fill="red")
def blink(): # mirkšķināt acis
c.itemconfig(eye, fill="green")
c.itemconfig(eyeball, state=HIDDEN)
def unblink():
c.itemconfig(eye, fill="white")
c.itemconfig(eyeball, state=NORMAL)
def steal_hat():
c.itemconfig(hat, state=HIDDEN)
c.itemconfig(words, text="Give my hat back!")
def burp(event):
mouth_open()
c.itemconfig(words, text="Burp!")
c.bind_all("<Button-1>", burp)
def blink2(event):
c.itemconfig(eye, fill="green")
c.itemconfig(eyeball, state=HIDDEN)
def unblink2(event):
c.itemconfig(eye, fill="white")
c.itemconfig(eyeball, state=NORMAL)
def eye_control(event): # kontolēšana
key = event.keysym
if key == "Up":
c.move(eyeball, 0, -1)
elif key == "Down":
c.move(eyeball, 0, 1)
elif key == "Left":
c.move(eyeball, -1, 0)
elif key == "Right":
c.move(eyeball, 1, 0)
window = Tk() # logs
window.title("Alien")
c = Canvas(window, height=300, width=400)
c.pack()
body = c.create_oval(100, 150, 300, 250, fill="green")
eye = c.create_oval(170, 70, 230, 130, fill="white")
eyeball = c.create_oval(190, 90, 210, 110, fill="black")
mouth = c.create_oval(150, 220, 250, 240, fill="red")
neck = c.create_line(200, 150, 200, 130)
hat = c.create_polygon(180, 75, 220, 75, 200, 20, fill="blue")
c.move(eyeball, -10, 0)
c.move(eyeball, 10, 0)
words = c.create_text(200, 280, text="I am an alien!")
window.attributes("-topmost", 1)
c.bind_all("<KeyPress-a>", blink2)
c.bind_all("<KeyPress-z>", unblink2)
c.bind_all("<Key>", eye_control)