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 [2016/02/17 11:59] – villersd | teaching:progappchim:codes_presentation [2021/01/28 17:58] (Version actuelle) – villersd | ||
---|---|---|---|
Ligne 4: | Ligne 4: | ||
//Cf.// la [[https:// | //Cf.// la [[https:// | ||
- | <sxh python; title : turtle-01.py> | + | <code python turtle-01.py> |
# | # | ||
# -*- coding: UTF-8 -*- | # -*- coding: UTF-8 -*- | ||
Ligne 38: | Ligne 38: | ||
time.sleep(10) | time.sleep(10) | ||
- | </sxh> | + | </code> |
===== Tkinter ===== | ===== Tkinter ===== | ||
- | En Python 2. Pour Python 3, utiliser "from tkinter import *" et print() ! | ||
//Cf.// la [[https:// | //Cf.// la [[https:// | ||
- | <sxh python; title : tkinter-simple-entry.py> | + | <code python tkinter-simple-entry.py> |
# | # | ||
# -*- coding: UTF-8 -*- | # -*- coding: UTF-8 -*- | ||
Ligne 51: | 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 72: | Ligne 71: | ||
fen01.destroy() | fen01.destroy() | ||
- | print ' | + | print(' |
- | </sxh> | + | </code> |
==== Canvas Tkinter : rebond d'une balle ==== | ==== Canvas Tkinter : rebond d'une balle ==== | ||
- | <sxh python; title : anima_auto_rebond.py> | + | <code python anima_auto_rebond.py> |
#! / | #! / | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
Ligne 84: | 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 137: | Ligne 136: | ||
fen1.mainloop() | fen1.mainloop() | ||
fen1.destroy() | fen1.destroy() | ||
- | </sxh> | + | </code> |
==== DemoTkinter ==== | ==== DemoTkinter ==== | ||
* télécharger ici : [[http:// | * 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() | ||
+ | </ | ||