ошибка:
>>> Exception in Tkinter callback
Traceback (most recent call last):
File "C:\puthon\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "C:\Users\Admin\Desktop\python project\алаыол\sdfgh.py", line 32, in move_fish
x = x + 5
код:
#импорт библиотек
from tkinter import*
from time import*
from random import randint
x = 50
y = 50
x1 = 0
y1 = 0
count = 0
#создание рабочей поверхности
tk = Tk()
canvas = Canvas(tk, width = 500, height = 500)
canvas.pack()
#функции
def move_fish(event):
if event.keysym == 'Up':
canvas.move(id_img1,0,-5)
y = y - 5
elif event.keysym == 'Down':
canvas.move(id_img1,0,5)
y = y + 5
elif event.keysym == 'Left':
canvas.move(id_img1,-5,0)
x = x - 5
elif event.keysym == 'Right':
canvas.move(id_img1,5,0)
x = x + 5
#работа с интерфеисом
fish_obj = PhotoImage(file='Background.png')
id_img1 = canvas.create_image(50,50,anchor=NW,image=fish_obj)
#правление
canvas.bind_all("<KeyPress-Up>",move_fish)
canvas.bind_all("<KeyPress-Down>",move_fish)
canvas.bind_all("<KeyPress-Left>",move_fish)
canvas.bind_all("<KeyPress-Right>",move_fish)
>>> Exception in Tkinter callback
Traceback (most recent call last):
File "C:\puthon\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "C:\Users\Admin\Desktop\python project\алаыол\sdfgh.py", line 32, in move_fish
x = x + 5
код:
#импорт библиотек
from tkinter import*
from time import*
from random import randint
x = 50
y = 50
x1 = 0
y1 = 0
count = 0
#создание рабочей поверхности
tk = Tk()
canvas = Canvas(tk, width = 500, height = 500)
canvas.pack()
#функции
def move_fish(event):
if event.keysym == 'Up':
canvas.move(id_img1,0,-5)
y = y - 5
elif event.keysym == 'Down':
canvas.move(id_img1,0,5)
y = y + 5
elif event.keysym == 'Left':
canvas.move(id_img1,-5,0)
x = x - 5
elif event.keysym == 'Right':
canvas.move(id_img1,5,0)
x = x + 5
#работа с интерфеисом
fish_obj = PhotoImage(file='Background.png')
id_img1 = canvas.create_image(50,50,anchor=NW,image=fish_obj)
#правление
canvas.bind_all("<KeyPress-Up>",move_fish)
canvas.bind_all("<KeyPress-Down>",move_fish)
canvas.bind_all("<KeyPress-Left>",move_fish)
canvas.bind_all("<KeyPress-Right>",move_fish)