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évisionLes deux révisions suivantes | ||
teaching:progappchim:codes_presentation [2015/02/17 11:46] – villersd | teaching:progappchim:codes_presentation [2015/02/17 17:47] – villersd | ||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
===== Turtle ===== | ===== Turtle ===== | ||
+ | //Cf.// la [[https:// | ||
<sxh python; title : turtle-01.py> | <sxh python; title : turtle-01.py> | ||
# | # | ||
- | # -*- coding: | + | # -*- coding: |
# 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:// | ||
<sxh python; title : tkinter-simple-entry.py> | <sxh python; title : tkinter-simple-entry.py> | ||
# | # | ||
Ligne 72: | Ligne 76: | ||
</ | </ | ||
- | rebond | + | ==== Canvas Tkinter : rebond |
+ | |||
<sxh python; title : anima_auto_rebond.py> | <sxh python; title : anima_auto_rebond.py> | ||
#! / | #! / | ||
Ligne 86: | Ligne 91: | ||
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 137: | ||
fen1.mainloop() | fen1.mainloop() | ||
fen1.destroy() | fen1.destroy() | ||
- | |||
</ | </ | ||
+ | |||
+ |