Есть код
from tkinter import * import random import time class Game: def __init__(self): self.tk = Tk() self.tk.title("Создал игру Андрей") self.tk.resizable(0, 0) self.tk.wn_attributes("-topmost", 1) self.canvas = Canvas(self.tk, width=500, height=500, highlightthickness=0) self.canvas.pack() self.tk.update() self.canvas_height = 500 self.canvas_width = 500 self.bg = PhotoImage(file="background.gif") w = self.bg.width() h = self.bg.height() for x in range(0, 5): for y in range(0, 5): self.canvas.create_image(x * w, y * h, image=self.bg, anchor='nw') self.sprites = [] self.running = True g = Game() g.mainloop()
После запуска выдается:
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
RESTART: C:/Users/mocom/AppData/Local/Programs/Python/Python36-32/my_game_2.py
Traceback (most recent call last):
File "C:/Users/mocom/AppData/Local/Programs/Python/Python36-32/my_game_2.py", line 23, in <module>
g = Game()
File "C:/Users/mocom/AppData/Local/Programs/Python/Python36-32/my_game_2.py", line 9, in __init__
self.tk.wn_attributes("-topmost", 1)
File "C:\Users\mocom\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 2098, in __getattr__
return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'wn_attributes'
>>>
В чем ошибка?