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 | ||
python:interface_graphique_tkinter:start [2019/10/12 16:13] – physix | python:interface_graphique_tkinter:start [2020/07/24 03:31] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 7: | Ligne 7: | ||
===== Exemples ===== | ===== Exemples ===== | ||
- | ==== Hello world ====< | + | ==== Hello world ==== |
+ | <code python> | ||
from tkinter import * | from tkinter import * | ||
Ligne 27: | Ligne 28: | ||
==== Calculatrice ==== | ==== Calculatrice ==== | ||
- | < | + | < |
from tkinter import * | from tkinter import * | ||
from math import * | from math import * | ||
Ligne 72: | Ligne 73: | ||
|Toplevel| | |Toplevel| | ||
- | ==== Button ====< | + | ==== Button ==== |
+ | |||
+ | < | ||
from tkinter import * | from tkinter import * | ||
Ligne 86: | Ligne 89: | ||
{{: | {{: | ||
+ | |||
+ | ==== Canvas ==== | ||
+ | |||
+ | <code python> | ||
+ | from tkinter import * | ||
+ | |||
+ | fenetre = Tk() | ||
+ | |||
+ | canvas = Canvas(fenetre, | ||
+ | ligne1 = canvas.create_line(75, | ||
+ | ligne2 = canvas.create_line(0, | ||
+ | txt = canvas.create_text(75, | ||
+ | canvas.pack() | ||
+ | |||
+ | fenetre.mainloop() | ||
+ | |||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Autres éléments : | ||
+ | |||
+ | <code python> | ||
+ | create_arc() | ||
+ | create_bitmap() | ||
+ | create_image() | ||
+ | create_line() | ||
+ | create_oval() | ||
+ | create_polygon() | ||
+ | create_rectangle() | ||
+ | create_text() | ||
+ | create_window() | ||
+ | |||
+ | </ | ||
+ | |||
+ | Pour changer les coordonnées d'un élément : | ||
+ | |||
+ | <code python> | ||
+ | canvas.coords(élément, | ||
+ | |||
+ | </ | ||
+ | |||
+ | Pour supprimer un élément : | ||
+ | |||
+ | <code python> | ||
+ | canvas.delete(élément) | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Checkbutton ==== | ||
+ | |||
+ | <code python> | ||
+ | from tkinter import * | ||
+ | |||
+ | fenetre = Tk() | ||
+ | |||
+ | bouton = Checkbutton(fenetre, | ||
+ | bouton.pack() | ||
+ | |||
+ | fenetre.mainloop() | ||
+ | |||
+ | </ | ||
+ | |||
+ | {{: | ||
\\ | \\ | ||