Différences
Ci-dessous, les différences entre deux révisions de la page.
| 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] – villersd | teaching:progappchim:codes_presentation [2021/01/28 17:58] (Version actuelle) – villersd | ||
|---|---|---|---|
| Ligne 2: | Ligne 2: | ||
| ===== Turtle ===== | ===== Turtle ===== | ||
| + | //Cf.// la [[https:// | ||
| - | <sxh python; title : turtle-01.py> | + | <code python turtle-01.py> |
| # | # | ||
| - | # -*- coding: | + | # -*- coding: |
| # exemple de base turtle | # exemple de base turtle | ||
| Ligne 37: | Ligne 38: | ||
| time.sleep(10) | time.sleep(10) | ||
| - | </sxh> | + | </code> |
| ===== Tkinter ===== | ===== Tkinter ===== | ||
| - | (Python | + | |
| - | <sxh python; title : tkinter-simple-entry.py> | + | //Cf.// la [[https:// |
| + | |||
| + | <code python tkinter-simple-entry.py> | ||
| # | # | ||
| # -*- 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 | + | from tkinter |
| fen01 = Tk() | fen01 = Tk() | ||
| Ligne 68: | Ligne 71: | ||
| fen01.destroy() | fen01.destroy() | ||
| - | print ' | + | print(' |
| - | </sxh> | + | </code> |
| - | rebond | + | ==== Canvas Tkinter : rebond |
| - | <sxh python; title : anima_auto_rebond.py> | + | |
| + | <code python anima_auto_rebond.py> | ||
| #! / | #! / | ||
| # -*- 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 | + | from tkinter |
| # définition des gestionnaires | # définition des gestionnaires | ||
| Ligne 86: | Ligne 90: | ||
| def move(): | def move(): | ||
| " | " | ||
| - | a=0.99 | ||
| 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, | can1.coords(oval1, | ||
| if flag > | if flag > | ||
| Ligne 133: | Ligne 136: | ||
| fen1.mainloop() | fen1.mainloop() | ||
| fen1.destroy() | fen1.destroy() | ||
| + | </ | ||
| + | |||
| + | ==== DemoTkinter ==== | ||
| + | * télécharger ici : [[http:// | ||
| + | |||
| + | ===== Matplotlib - pylab ===== | ||
| + | |||
| + | <code python simple_fonction.py> | ||
| + | # | ||
| + | # -*- 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) | ||
| + | # | ||
| + | |||
| + | #show() | ||
| + | |||
| + | plot(tvals, my_func(tvals), | ||
| + | |||
| + | show() | ||
| + | </ | ||
| + | |||
| - | </ | ||