Reputation: 1 Apprentice
- Active Posts:
- 21 (0.06 per day)
- 07-January 14
- Profile Views:
- Last Active:
- Mar 13 2014 06:02 AM
- Dream Kudos:
Posts I've Made
Posted 12 Mar 2014Sorry , i found the answer , could you delete the last post ? I don't see where is the button 'Edit message ' ?
Posted 12 Mar 2014Here is my code of the last exercise . I want to clarify that this is not a homework .The following exercise says :
Modify the previous program so that it takes into account two successive clicks pourdéterminer the coordinates of the diagonal of the rectangle.
I don't have any clue how to solve this ........
>>> def manager(event) : ... position(event) ... draw(event) ... >>> def position(click) : ... afficheur ['text'] = "%s, %s" % (click.x, click.y) ... >>> Listcolor = ('red', 'green','purple') >>> color = False >>> def draw(event): ... global color ... c = event.widget ... d = 21 ... x, y = event.x, event.y ... c.create_rectangle(x - d, y - d, x + d, y + d, fill=Listcolor[color], outline="") ... color = not color ... >>> from Tkinter import * >>> top = Tk() >>> C = Canvas(top, width=400, height=400, bg="light yellow") >>> C.pack() >>> C.bind("<Button-1>", manager) '3075006548Lmanager' >>> afficheur = Label(top) >>> afficheur.pack()
Posted 12 Mar 2014thanks !
When i set colors[current_counter] with the selected index , i get the right square .
Anyway, in your last code , it means that i have to forget the orginal function draw() ?
Sorry , but i don't understand your comment "# this color COULD be assigned to your button now."
Posted 12 Mar 2014I spend more that 2 weeks to think about this exercise , i don't think that this exercise is for my level in python . Why is so easy to get two colors and not 3 colors ?
Thanks for your explanation
Yes , the counter always grows , also , tkinter is not easy for the beginner , it's like a chess game ....
Posted 12 Mar 2014I put your code in my last code in the shell, but it always gives me a red square .
i put in my function draw() : fill = colors[i%len(colors)], but the function selects only the firt color (red) !
Do i have to place a global variable in my function draw() ?
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
- Click here to e-mail me
giny28 hasn't added any friends yet.