Форум сайта python.su
from tkinter import *
root = Tk()
def oval_func(event):
c.delete(oval)
c.create_text(80, 50, text='Овал')
def rect_func(event):
c.delete(tril)
c.create_text(230, 50, text='Прямогульник')
def triangle(event):
c.delete(trian)
c.create_text(380, 50, text='Треугольник')
c = Canvas(width=460, height=100, bg='grey')
c.pack()
oval = c.create_oval(30,10,130,80, fill='orange')
tril = c.create_rectangle(180,10,280,80,fill='lightgreen')
trian = c.create_polygon(330,80,380,10,430,80,fill='white',outline='black')
c.tag_bind(oval,'<Button-1>', oval_func)
c.tag_bind(tril, ‘<Button-1>’, rect_func)
c.tag_bind(trian, ‘<Button-1>’, triangle)
root.mainloop()
Здесь, при нажатии на фигуру, высвечивается текст
А мне хочется, чтобы после высвечивания текста, при нажатии на него, высвечивалась та же самая фигура
Офлайн
отредактируй свое сообщение
[code python]между этими тегами вставь свой код[/code]
Офлайн
xam1816Простите, а для чего?
отредактируй свое сообщение
Офлайн
from tkinter import * root = Tk() def oval_func(event): c.delete(oval) c.create_text(80, 50, text='Овал') def rect_func(event): c.delete(tril) c.create_text(230, 50, text='Прямогульник') def triangle(event): c.delete(trian) c.create_text(380, 50, text='Треугольник') c = Canvas(width=460, height=100, bg='grey') c.pack() oval = c.create_oval(30,10,130,80, fill='orange') tril = c.create_rectangle(180,10,280,80,fill='lightgreen') trian = c.create_polygon(330,80,380,10,430,80,fill='white',outline='black') c.tag_bind(oval,'<Button-1>', oval_func) c.tag_bind(tril, ‘<Button-1>’, rect_func) c.tag_bind(trian, ‘<Button-1>’, triangle) root.mainloop()
Офлайн