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
teaching:progappchim:codes_presentation [2015/02/17 11:46] villersdteaching:progappchim:codes_presentation [2021/01/28 17:58] (Version actuelle) 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>+<code python turtle-01.py>
 #!/usr/bin/python #!/usr/bin/python
-# -*- coding: iso-8859-15 -*-+# -*- coding: UTF--*-
  
 # exemple de base turtle # exemple de base turtle
Ligne 37: Ligne 38:
  
 time.sleep(10) time.sleep(10)
-</sxh>+</code>
  
 ===== Tkinter ===== ===== Tkinter =====
-(Python 2) + 
-<sxh python; title : tkinter-simple-entry.py>+//Cf.// la [[https://docs.python.org/2/library/tk.html|documentation officielle]]. 
 + 
 +<code python tkinter-simple-entry.py>
 #!/usr/bin/python #!/usr/bin/python
 # -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
Ligne 47: Ligne 50:
 # lecture de 2 masses par une fenêtre tk # lecture de 2 masses par une fenêtre tk
  
-from Tkinter import *+from tkinter import *
  
 fen01 = Tk() fen01 = Tk()
Ligne 68: Ligne 71:
 fen01.destroy() fen01.destroy()
  
-print 'Masses lues : ', m1,' et ',m2+print('Masses lues : ', m1,' et ',m2)
  
-</sxh>+</code>
  
-rebond (erreur à corriger) +==== Canvas Tkinter : rebond d'une balle ==== 
-<sxh python; title : anima_auto_rebond.py>+  
 +<code python anima_auto_rebond.py>
 #! /usr/bin/env python #! /usr/bin/env python
 # -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
Ligne 79: Ligne 83:
 # Petit exercice utilisant la librairie graphique Tkinter # Petit exercice utilisant la librairie graphique Tkinter
  
-from Tkinter import *+from tkinter import *
  
 # définition des gestionnaires # définition des gestionnaires
Ligne 86: Ligne 90:
 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 136:
 fen1.mainloop() fen1.mainloop()
 fen1.destroy() fen1.destroy()
 +</code>
 +
 +==== DemoTkinter ====
 +  * télécharger ici : [[http://pythonfacile.free.fr/python/demotkinter.html]]
 +
 +===== Matplotlib - pylab =====
 +
 +<code python simple_fonction.py>
 +#!/usr/bin/python
 +# -*- coding: utf-8 -*-
 +# cosinusoïde amortie
 +
 +from pylab import *
 +
 +def my_func(t):        
 +    s1 = cos(2*pi*t)        
 +    e1 = exp(-t)        
 +    return s1*e1
 +
 +tvals = arange(0., 5., 0.05)
 +#plot(tvals, my_func(tvals))
 +
 +#show()
 +
 +plot(tvals, my_func(tvals), 'bo', tvals, my_func(tvals), 'k')
 +
 +show()
 +</code>
 +
  
-</sxh> 
  • teaching/progappchim/codes_presentation.1424169993.txt.gz
  • Dernière modification : 2015/02/17 11:46
  • de villersd