Уведомления

Группа в Telegram: @pythonsu

#1 Окт. 26, 2019 18:52:12

CHABUREK
Зарегистрирован: 2019-10-26
Сообщения: 1
Репутация: +  0  -
Профиль   Отправить e-mail  

Не появляется картинка в окне ткинтер, когда нажимаю таб вылетает ошибка

from PIL import ImageTk, Image
from random import *
from tkinter import *
root = Tk()
root.geometry(“600x600”)
root.title(“НЕ СМОТРЕТЬ”)
canvas = Canvas(root, width = 600, height = 600, bg = “white”)
canvas.pack()
root.iconbitmap(r“c:\Users\пашКА\PycharmProjects\Sneyka\apple-128 (1).ico”)
def kvadro(x, y):
canvas.create_line(x, y, x + 100, y)
canvas.create_line(x + 100, y, x + 100, y + 100)
canvas.create_line(x, y, x, y + 100)
canvas.create_line(x, y + 100, x + 100, y + 100)
canvas.create_text(x + 50, y - 10, text= “a”, font=“Impact 20 bold”, fill=“black”)
canvas.create_text(x + 50, y + 110, text= “a”, font=“Impact 20 bold”, fill=“black”)
canvas.create_text(x - 10, y + 50, text = “b”, font=“Impact 20 bold”, fill=“black”)
canvas.create_text(x + 110, y + 50, text = “b”, font=“Impact 20 bold”, fill=“black”)
def formu(x, y):
canvas.create_text(x, y, text=“2(bc) = 2b * 2c”, font=“Impact 20 bold”, fill=“darkred”)
def gg(event):
x = randint(0, 600)
y = randint(0, 600)
z = randint(0, 2)
‘'’if z == 0:
canvas.create_text(x, y, text=“P = 2 * (a * b)”, font=“Impact 20 bold”, fill=“darkblue”)
elif z == 1:
kvadro(x, y)
else:
formu(x,y)
canvas.update()'''
open_img = open(“!win.png”)
img = PhotoImage(open_img)
ogo = canvas.create_image(x, y, image=img)
canvas.update()
canvas.delete(ogo)

root.bind(“<Tab>”, gg)
root.mainloop()



Exception in Tkinter callback
Traceback (most recent call last):
File “C:\Games\Новая папка\lib\tkinter\__init__.py”, line 1705, in __call__
return self.func(*args)
File “CUsers/пашКА/PycharmProjects/tchk/ввв.py”, line 38, in gg
ogo = canvas.create_image(x, y, image=img)
File “C:\Games\Новая папка\lib\tkinter\__init__.py”, line 2489, in create_image
return self._create('image', args, kw)
File “C:\Games\Новая папка\lib\tkinter\__init__.py”, line 2480, in _create
*(args + self._options(cnf, kw))))
TypeError: __str__ returned non-string (type _io.TextIOWrapper)

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version