Форум сайта python.su
from tkinter import * # Измененние заголовка окна формы def b1(event): if root.title() == 'Дадонов Юрий Петрович': root.title('ID=704456768') else: root.title('Дадонов Юрий Петрович') root = Tk() root.title('Дадонов Юрий Петрович') root.bind('<Button-1>', b1) # рисование системы координат с подписями canvas = Canvas(root,width=800,height=600,bg="#ffffff") canvas.pack() canvas.create_line(20,310,20,10,width=5,fill="red",arrow=LAST) canvas.create_line(10,300,500,300,width=5,fill="red",arrow=LAST) canvas.create_text(10, 320, anchor=W, font="Purisa", fill="red", text="0") canvas.create_text(10, 10, anchor=W, font="Purisa",fill="red", text="y") canvas.create_text(500, 310, anchor=W, font="Purisa",fill="red", text="x") # получение координат для рисования треугольника ID=704456768 x1=ID % 1000000//10000 +20 x2=ID % 1000000%10000//100 +20 x3=ID % 1000000%100 +20 ID3=ID//3 y1=300 - ID3 % 1000000//10000 y2=300 - ID3 % 1000000%10000//100 y3=300 - ID3 % 1000000%100 #рисование треугольника по заданным координатам colors='#87cefa' def change(): global colors clrs_list = ('#87cefa', 'green', '#8b00ff', '#800080', '#cc7722', '#db7093') colors = clrs_list[var.get()] canvas.itemconfig(tr, fill= colors) print(colors) #colors='#87cefa' tr=canvas.create_polygon([x1,y1],[x2,y2],[x3,y3],outline='#000000',fill=colors) #выбор цвета для треугольника с помощью радиокнопок var = IntVar() var.set(0) col1 = Radiobutton( text="Светло-голубой", variable=var, value=0 , command=change) col2 = Radiobutton( text="Зеленый", variable=var, value=1,command=change) col3 = Radiobutton(text="Фиолетовый", variable=var, value=2,command=change) col4 = Radiobutton(text="Пурпурный", variable=var, value=3,command=change) col5 = Radiobutton(text="Охра", variable=var, value=4,command=change) col6 = Radiobutton(text="Лиловый", variable=var, value=5,command=change) col1.place(x=500, y=50) col2.place(x=500, y=70) col3.place(x=500, y=90) col4.place(x=500, y=110) col5.place(x=500, y=130) col6.place(x=500, y=150) canvas.create_text(50, 390, anchor=W, font="Purisa", fill="red", text="x1:") canvas.create_text(150, 390, anchor=W, font="Purisa", fill="red", text="x2:") canvas.create_text(250, 390, anchor=W, font="Purisa", fill="red", text="x3:") canvas.create_text(50, 490, anchor=W, font="Purisa", fill="red", text="y1:") canvas.create_text(150, 490, anchor=W, font="Purisa", fill="red", text="y2:") canvas.create_text(250, 490, anchor=W, font="Purisa", fill="red", text="y3:") txt1 = Entry(canvas, width=10) txt2 = Entry(canvas, width=10) txt3 = Entry(canvas, width=10) txt4 = Entry(canvas, width=10) txt5 = Entry(canvas, width=10) txt6 = Entry(canvas, width=10) txt1.place(x=50, y=400) txt2.place(x=150, y=400) txt3.place(x=250, y=400) txt4.place(x=50, y=500) txt5.place(x=150, y=500) txt6.place(x=250, y=500) def koord(): global tr x1=int(txt1.get()) x2=int(txt2.get()) x3=int(txt3.get()) y1=int(txt4.get()) y2=int(txt5.get()) y3=int(txt6.get()) canvas.delete(tr) tr = canvas.create_polygon([x1,y1],[x2,y2],[x3,y3],outline='#000000',fill=colors) btn1 = Button(canvas, text="Построить треугольник", command= koord) btn1.place(x=350, y=500) root.mainloop()
[code python][/code]
Офлайн
PEHDOM ты супер ! уважаю профессионалов !как у тебя все получается-волшебник!побольше бы таких людей
а то многие зазнаются смотрят на нас таких начинающих и смеются
а что значит вставить кнопки в отдельном фрейме значит нужно вставлять отдельную область в canvs?
Офлайн
ydadonovнет, имееться ввиду отдельный виджет Frame (рамка).
а что значит вставить кнопки в отдельном фрейме значит нужно вставлять отдельную область в canvs?
[code python][/code]
Офлайн
Спасибо!сейчас попробую нахимичить вставить туда Radiobutton
Офлайн