teaching:progappchim:codes_presentation

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
teaching:progappchim:codes_presentation [2015/02/17 11:46] villersdteaching:progappchim:codes_presentation [2016/02/17 11:59] villersd
Ligne 2: Ligne 2:
  
 ===== Turtle ===== ===== Turtle =====
 +//Cf.// la [[https://docs.python.org/2/library/turtle.html|documentation officielle]].
  
 <sxh python; title : turtle-01.py> <sxh python; title : turtle-01.py>
 #!/usr/bin/python #!/usr/bin/python
-# -*- coding: iso-8859-15 -*-+# -*- coding: UTF--*-
  
 # exemple de base turtle # exemple de base turtle
Ligne 40: Ligne 41:
  
 ===== Tkinter ===== ===== Tkinter =====
-(Python 2)+En Python 2. Pour Python 3, utiliser "from tkinter import *" et print(
 + 
 +//Cf.// la [[https://docs.python.org/2/library/tk.html|documentation officielle]]. 
 <sxh python; title : tkinter-simple-entry.py> <sxh python; title : tkinter-simple-entry.py>
 #!/usr/bin/python #!/usr/bin/python
Ligne 72: Ligne 76:
 </sxh> </sxh>
  
-rebond (erreur à corriger)+==== Canvas Tkinter : rebond d'une balle ==== 
 + 
 <sxh python; title : anima_auto_rebond.py> <sxh python; title : anima_auto_rebond.py>
 #! /usr/bin/env python #! /usr/bin/env python
Ligne 86: Ligne 91:
 def move(): def move():
     "déplacement de la balle"     "déplacement de la balle"
-    a=0.99  #ralentissement 
     global x1, y1, vx, vy, dt, flag     global x1, y1, vx, vy, dt, flag
     x1, y1 = x1 +vx*dt, y1 + vy*dt     x1, y1 = x1 +vx*dt, y1 + vy*dt
     if x1 < 0 or x1 > 220:     if x1 < 0 or x1 > 220:
-        vx=-vx*a+        vx=-vx
     if y1 < 0 or y1 > 220:     if y1 < 0 or y1 > 220:
-        vy = -vy*a+        vy = -vy
     can1.coords(oval1,x1,y1,x1+30,y1+30)     can1.coords(oval1,x1,y1,x1+30,y1+30)
     if flag >0:      if flag >0: 
Ligne 133: Ligne 137:
 fen1.mainloop() fen1.mainloop()
 fen1.destroy() fen1.destroy()
- 
 </sxh> </sxh>
 +
 +==== DemoTkinter ====
 +  * télécharger ici : [[http://pythonfacile.free.fr/python/demotkinter.html]]
 +
 +
  • teaching/progappchim/codes_presentation.txt
  • Dernière modification : 2021/01/28 17:58
  • de villersd