Форум сайта python.su
Имеем лист тетрадный в клеточку, надо нарисовать по отдельности простого человечка (палочки, кружочки), то есть поэтапно, сначала круг, потом туловище и тд, как такое реализовать?
Прикреплённый файлы:
Безымянный.jpg (5,1 KБ)
Офлайн
Kasta_neda
Ты вообще о чём?
Офлайн
Нарисовать человечка по фрагментам, при условии, и плюс что бы поле было кликабельно(квадратики поля-тетради)
допустим выполнено условие, рисуем круг, выполнено другое, рисуем руку-линию
from Tkinter import * root = Tk() canvas = Canvas(root, width=600, height=600) canvas.pack(fill=BOTH) circle2 = canvas.create_oval(9,9,80,80, fill="white") telo = canvas.create_line(45,80,45,200,width=4) rukaP = canvas.create_line(45,80,100,100,width=4) rukaL = canvas.create_line(45,80,0,100,width=4) nogaL = canvas.create_line(45,200,0,300,width=4) nogaP = canvas.create_line(45,200,100,300,width=4) root.mainloop()
Отредактировано Kasta_neda (Авг. 17, 2014 20:35:00)
Офлайн
Игра
from Tkinter import * root = Tk() canvas = Canvas(root, width=600, height=600) canvas.pack(fill=BOTH) word = u'эффект' y = 0 while y < 600: x=0 while x < 600: canvas.create_rectangle(x,y,x+40,y+50, fill="white", outline="blue") x=x+40 y = y + 50 canvas.create_text(260,30, text=word[0], fill="purple", font=("Helvectica", "16")) canvas.create_text(300,30, text='_', fill="purple", font=("Helvectica", "18")) canvas.create_text(340,30, text='_', fill="purple", font=("Helvectica", "18")) canvas.create_text(380,30, text='_', fill="purple", font=("Helvectica", "18")) canvas.create_text(420,30, text='_', fill="purple", font=("Helvectica", "18")) canvas.create_text(460,30, text=word[5], fill="purple", font=("Helvectica", "16")) circle2 = canvas.create_oval(9,9,80,80, width=4, fill="white") telo = canvas.create_line(45,80,45,200,width=4) rukaP = canvas.create_line(45,80,100,100,width=4) rukaL = canvas.create_line(45,80,0,100,width=4) nogaL = canvas.create_line(45,200,0,300,width=4) nogaP = canvas.create_line(45,200,100,300,width=4) root.mainloop()
Отредактировано Kasta_neda (Авг. 17, 2014 21:24:28)
Прикреплённый файлы:
Ersv6a4U5ZQ.jpg (100,2 KБ)
Офлайн
Kasta_neda
Надо полный вопрос писать и не играть в телепатов.
Офлайн
Подскажите как счетчик ошибок прикрутить (переменная - er) и как сделать (если ответ правильный) кнопку зеленой?
#coding: utf-8 from Tkinter import * root = Tk() canvas = Canvas(root, width=600, height=600) canvas.pack(fill=BOTH) word = u'абвгде' y = 0 while y < 600: x=0 while x < 600: canvas.create_rectangle(x,y,x+33,y+27, fill="white", outline="blue") x=x+33 y = y + 27 a1 = canvas.create_text(315,40, text=word[0], fill="purple", font=("Helvectica", "16")) a2 = canvas.create_text(347,40, text='_', fill="purple", font=("Helvectica", "18")) a3 = canvas.create_text(380,40, text='_', fill="purple", font=("Helvectica", "18")) a4 = canvas.create_text(412,40, text='_', fill="purple", font=("Helvectica", "18")) a5 = canvas.create_text(444,40, text='_', fill="purple", font=("Helvectica", "18")) a6 = canvas.create_text(477,40, text=word[-1], fill="purple", font=("Helvectica", "16")) list1 = [1,2,3,4,5,6] alfabet = u'абвгдеёжзийклмнопрстуфхцчшщъыьэюя' er = 0 def a(v): print v if v in word: ind = word.index(v) b2 = list1[ind] if b2 == 1: pass if b2 == 6: pass if b2 == 2: a2 = canvas.create_text(347,40, text=word[1], fill="purple", font=("Helvectica", "18")) elif b2 == 3: a3 = canvas.create_text(380,40, text=word[2], fill="purple", font=("Helvectica", "18")) elif b2 == 4: a3 = canvas.create_text(412,40, text=word[3], fill="purple", font=("Helvectica", "18")) elif b2 == 5: a3 = canvas.create_text(444,40, text=word[4], fill="purple", font=("Helvectica", "18")) else: er =+ 1 print er if er == 1: golova() elif er == 2: telo() elif er == 3: rukaL() elif er == 4: rukaP() elif er == 5: nogaL() elif er == 6: nogaP() root.update() btn = Button(root , text = u'а', width=3, height=1, command = lambda: a(alfabet[0]))#.pack() btn2 = Button(root , text = u'б', width=3, height=1, command = lambda: a(alfabet[1]))#.pack() btn3 = Button(root , text = u'в', width=3, height=1, command = lambda: a(alfabet[2]))#.pack() btn4 = Button(root , text = u'г', width=3, height=1, command = lambda: a(alfabet[3]))#.pack() btn5 = Button(root , text = u'д', width=3, height=1, command = lambda: a(alfabet[4]))#.pack() btn6 = Button(root , text = u'е', width=3, height=1, command = lambda: a(alfabet[5]))#.pack() btn7 = Button(root , text = u'ё', width=3, height=1, command = lambda: a(alfabet[6]))#.pack() btn8 = Button(root , text = u'ж', width=3, height=1, command = lambda: a(alfabet[7]))#.pack() btn9 = Button(root , text = u'з', width=3, height=1, command = lambda: a(alfabet[8]))#.pack() btn10 = Button(root , text = u'и', width=3, height=1, command = lambda: a(alfabet[9]))#.pack() btn11 = Button(root , text = u'й', width=3, height=1, command = lambda: a(alfabet[10]))#.pack() btn12 = Button(root , text = u'к', width=3, height=1, command = lambda: a(alfabet[11]))#.pack() btn13 = Button(root , text = u'л', width=3, height=1, command = lambda: a(alfabet[12]))#.pack() btn14 = Button(root , text = u'м', width=3, height=1, command = lambda: a(alfabet[13]))#.pack() btn15 = Button(root , text = u'н', width=3, height=1, command = lambda: a(alfabet[14]))#.pack() btn16 = Button(root , text = u'о', width=3, height=1, command = lambda: a(alfabet[15]))#.pack() btn17 = Button(root , text = u'п', width=3, height=1, command = lambda: a(alfabet[16]))#.pack() btn18 = Button(root , text = u'р', width=3, height=1, command = lambda: a(alfabet[17]))#.pack() btn19 = Button(root , text = u'с', width=3, height=1, command = lambda: a(alfabet[18]))#.pack() btn20 = Button(root , text = u'т', width=3, height=1, command = lambda: a(alfabet[19]))#.pack() btn21 = Button(root , text = u'у', width=3, height=1, command = lambda: a(alfabet[20]))#.pack() btn22 = Button(root , text = u'ф', width=3, height=1, command = lambda: a(alfabet[21]))#.pack() btn23 = Button(root , text = u'х', width=3, height=1, command = lambda: a(alfabet[22]))#.pack() btn24 = Button(root , text = u'ц', width=3, height=1, command = lambda: a(alfabet[23]))#.pack() btn25 = Button(root , text = u'ч', width=3, height=1, command = lambda: a(alfabet[24]))#.pack() btn26 = Button(root , text = u'ш', width=3, height=1, command = lambda: a(alfabet[25]))#.pack() btn27 = Button(root , text = u'щ', width=3, height=1, command = lambda: a(alfabet[26]))#.pack() btn28 = Button(root , text = u'ъ', width=3, height=1, command = lambda: a(alfabet[27]))#.pack() btn29 = Button(root , text = u'ы', width=3, height=1, command = lambda: a(alfabet[28]))#.pack() btn30 = Button(root , text = u'ь', width=3, height=1, command = lambda: a(alfabet[29]))#.pack() btn31 = Button(root , text = u'э', width=3, height=1, command = lambda: a(alfabet[30]))#.pack() btn32 = Button(root , text = u'ю', width=3, height=1, command = lambda: a(alfabet[31]))#.pack() btn33 = Button(root , text = u'я', width=3, height=1, command = lambda: a(alfabet[32]))#.pack() btn.place(x='265',y='110') btn2.place(x='298',y='110') btn3.place(x='331',y='110') btn4.place(x='364',y='110') btn5.place(x='397',y='110') btn6.place(x='430',y='110') btn7.place(x='463',y='110') btn8.place(x='496',y='110') btn9.place(x='265',y='137') btn10.place(x='298',y='137') btn11.place(x='331',y='137') btn12.place(x='364',y='137') btn13.place(x='397',y='137') btn14.place(x='430',y='137') btn15.place(x='463',y='137') btn16.place(x='496',y='137') btn17.place(x='265',y='164') btn18.place(x='298',y='164') btn19.place(x='331',y='164') btn20.place(x='364',y='164') btn21.place(x='397',y='164') btn22.place(x='430',y='164') btn23.place(x='463',y='164') btn24.place(x='496',y='164') btn25.place(x='265',y='191') btn26.place(x='298',y='191') btn27.place(x='331',y='191') btn28.place(x='364',y='191') btn29.place(x='397',y='191') btn30.place(x='430',y='191') btn31.place(x='463',y='191') btn32.place(x='496',y='191') btn33.place(x='496',y='217') def golova(): global er canvas.create_oval(9,9,80,80, width=4, fill="white") er = 2 root.update() def telo(): global er canvas.create_line(45,80,45,200,width=4) er = 3 root.update() def rukaP(): global er canvas.create_line(45,80,100,100,width=4) er = 4 root.update() def rukaL(): global er canvas.create_line(45,80,0,100,width=4) er = 5 root.update() def nogaL(): global er canvas.create_line(45,200,0,300,width=4) er = 6 root.update() def nogaP(): global er canvas.create_line(45,200,100,300,width=4) er = 7 root.update() root.mainloop()
Отредактировано Kasta_neda (Авг. 18, 2014 19:57:17)
Офлайн
1. Все вопросы по GUI должны быть в разделе GUI.
2. Свойства объекта формально можно считать словарем, поэтому будет действовать такая конструкция:
button["bg"] = "green"
button.config(bg="green")
def golova(): global er canvas.create_oval(9,9,80,80, width=4, fill="white") er = 2 root.update() def telo(): global er canvas.create_line(45,80,45,200,width=4) er = 3 root.update() def rukaP(): global er canvas.create_line(45,80,100,100,width=4) er = 4 root.update() def rukaL(): global er canvas.create_line(45,80,0,100,width=4) er = 5 root.update() def nogaL(): global er canvas.create_line(45,200,0,300,width=4) er = 6 root.update() def nogaP(): global er canvas.create_line(45,200,100,300,width=4) er = 7 root.update()
Офлайн
Офлайн