@MAT_VEY

Что делать когда python tkinter не отвечает?

У меня проблема почему то python tkinter не отвечает.
Вот мой код:
from tkinter import*
from random import*
import time
import keyboard
class P1:
def __init__(self, canvas):
self.ball = ball
self.canvas = canvas
self.id = canvas.create_rectangle(0, 0, 95, 15, fill="black")
self.canvas.move(self.id, 40, 485)
self.y = 0
self.x = 0
self.canvas.bind_all('', self.space)
def draw(self):
self.canvas.move(self.id, self.x, self.y)
def space(self, evt):
self.ball.on_space_press(canvas)
class Ball:
def on_space_press(self, canvas):
self.canvas = canvas
self.id1 = canvas.create_oval(0, 0, 95, 15, fill="black")
self.canvas.move(self.id1, 40, 485)
self.y = 0
self.x = 0
t = 0
pos_oval = self.canvas.coords(self.id1)
pos = self.canvas.coords(self.id1)
while True:
self.y += 3
self.x += 3
if pos[1] > 510:
break
if pos[1] >= pos_oval[3]:
t += 1
break
self.canvas.move(self.id1, self.x, self.y)
class Oval:
def __init__(self, canvas):
self.canvas = canvas
tim = 0
y = 0
while tim <= 22:
tim += 1
y += 1
time.sleep(randint(2, 5))
starts = [300, 250, 200, 150, 100]
shuffle(starts)
self.y = 0
self.x = 0
d = ['red', 'green', 'blue', 'yellow', 'orange', 'purple', 'pink']
self.id2 = canvas.create_oval(0, 0, 100, 30, fill=d[0])
self.canvas.move(self.id2, 0, starts[0])
if y < 22:
y = 100
def move(self):
self.canvas.move(self.id2, self.x, self.y)
tk = Tk()
tk.title("")
tk.resizable(height=False, width=False)
tk.wm_attributes("-topmost", 1)
canvas = Canvas(tk, width=500, height=500, bd=0, highlightthickness=0)
canvas.pack()
tk.update()
y = 99
ball = Ball()
ovl = Oval(canvas)
p1 = P1(canvas)
while 1:
if y != 100:
keyboard.on_press('on_press')
keyboard.wait()
ovl.move()
p1.draw()
tk.update_idletasks()
tk.update()
time.sleep(0.1)
  • Вопрос задан
  • 122 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы