1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Tkinter import*
>>> from random import randrange
>>>
>>> def drawline():
... "Tracé d'une ligne dans le canevas can1"
... global x1,y1, x2,y2, cou1#FF3434
File "<stdin>", line 3
global x1,y1, x2,y2, cou1#FF3434
^
IndentationError: unexpected indent
>>> can1.create_line(x1,y1,x2,y2,width=2,fill=cou1)
File "<stdin>", line 1
can1.create_line(x1,y1,x2,y2,width=2,fill=cou1)
^
IndentationError: unexpected indent
>>> #modification des coordonnées pour la ligne suivante :
... y2,y1 = y2+10 , y1-10
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
NameError: name 'y2' is not defined
>>> def changecolor():
... "changement aléatoire de la couleur du tracé"
... global cou1
... pa1=['purple','cyan','maroon','green','red','blue','orange','yellow']
... c = randrange (8)
... cou1
...
... #---------------Pgm principal---------
... #les variables suivantes seront utilisées de manière globale :
... x1,y1, x2,y2,=10,190,190,10
File "<stdin>", line 10
x1,y1, x2,y2,=10,190,190,10
^
SyntaxError: invalid syntax
>>> cou1 = 'dark green'
>>>
>>> #création du widget principal ("maitre") :
... fen1 = Tk()
>>> # création du widget "esclave":
... can1 = Canvas (fen1,bg='dark green', height=200, width=200)
>>> can1.pack(side=LEFT)
>>> bou1= Button (fen1,text='Quitter',command=fen1.quit)
>>> bou1.pack(side=BOTTOM)
>>> bou2 = Button(fen1,text='Tracer une ligne',command-drawline)
File "<stdin>", line 1
SyntaxError: non-keyword arg after keyword arg
>>> bou2.pack()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'bou2' is not defined
>>> bou3 = Button (fen1,text ='Autre couleur' ,command=changecolor)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'changecolor' is not defined
>>> bou3.pack()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'bou3' is not defined
>>> fen1.mainloop()
>>> fen1.destroy()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1688, in destroy
self.tk.call('destroy', self._w)
_tkinter.TclError: can't invoke "destroy" command: application has been destroyed
>>>
... |
Partager