![]() |
[Tkinter] Bounce Game - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] Bounce Game (/thread-8906.html) |
Bounce Game - SheeppOSU - Mar-12-2018 I was making this game from the Python book and I made it exactly as it had it in the book but when I asked python to check it before I ran it, it said,"inconsistent use of tabs and spaces in indentation" for line 7. Please tell me if you notice something wrong. import time import random from tkinter import * class Ball: def __init__(self, canvas, color): self.canvas = canvas self.id = cavas.create_oval(10, 10, 25, 25, fill=color) self.canvas.move(self.id, 245, 100) def draw(self): self.canvas.move(self.id, 0, -1) tk = Tk() canvas = Canvas(tk, width=400, height=400) canvas.pack() tk.title("Game") tk.wm_attributes("-topmost", 1) tk.title("Game") canvas = Canvas(tk, width=400, height=400, bd=0, highlightthickness=0) canvas.pack() tk.update() ball = Ball(canvas, 'red') while 1: ball.draw() tk.update_idletasks() tk.update() time.sleep(0.01) RE: Bounce Game - j.crater - Mar-12-2018 I believe the problem is with indentation here. Lines within the __init__ function should be indented: def __init__(self, canvas, color): self.canvas = canvas self.id = cavas.create_oval(10, 10, 25, 25, fill=color) self.canvas.move(self.id, 245, 100) |