Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in code
#1

# made by kikoko_2

from tkinter import *
GARUMS = 500
PLATUMS = 800
logs = Tk()
logs.title('Burbuļu spridzinātājs')
a = Canvas(logs, width=PLATUMS, height=GARUMS, bg='darkblue')
a.pack()

kuģa_id = a.create_polygon(5, 5, 5, 25, 30, 15, fill='red')
kuģa_id2 = a.create_oval(0, 0, 30, 30, outline='red')
KUĢA_R = 15
VID_X = PLATUMS / 2
VID_Y = GARUMS / 2
a.move(kuģa_id, VID_X, VID_Y)
a.move(kuģa_id2, VID_X, VID_Y)

KUĢA_ĀTR = 10
def pārvietot_kuģi(notikums):
    if notikums.keysym == 'Up':
        a.move(kuģa_id, 0, -KUĢA_ĀTR)
        a.move(kuģa_id2, 0, -KUĢA_ĀTR)
    elif notikums.keysym == 'Down':
        a.move(kuģa_id, 0, KUĢA_ĀTR)
        a.move(kuģa_id2, 0, KUĢA_ĀTR)
    elif notikums.keysym == 'Left':
        a.move(kuģa_id, -KUĢA_ĀTR, 0)
        a.move(kuģa_id2, -KUĢA_ĀTR, 0)
    elif notikums.keysym == 'Right':
        a.move(kuģa_id, KUĢA_ĀTR, 0)
        a.move(kuģa_id2, KUĢA_ĀTR, 0)
a.blind_all('q', pārvietot_kuģi)
Error:
Traceback (most recent call last): File "C:\Users\test\Desktop\python game\myfirstgame.py", line 33, in <module> a.blind_all('q', pārvietot_kuģi) AttributeError: 'Canvas' object has no attribute 'blind_all'
I don't understand what's wrong with it.
I am newbie and please don't blame me if this is a dumb mistake.
Thanks!
Reply
#2
It a spelling mistake. a.blind_all should be
a.bind_all
99 percent of computer problems exists between chair and keyboard.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020