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:05] – physix | python:interface_graphique_tkinter:start [2020/07/24 03:31] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 5: | Ligne 5: | ||
| [[https:// | [[https:// | ||
| - | ===== Hello world =====< | + | ===== Exemples |
| + | ==== Hello world ==== | ||
| + | |||
| + | <code python> | ||
| from tkinter import * | from tkinter import * | ||
| Ligne 23: | Ligne 26: | ||
| {{: | {{: | ||
| - | ===== Calculatrice | + | ==== Calculatrice ==== |
| - | < | + | < |
| from tkinter import * | from tkinter import * | ||
| from math import * | from math import * | ||
| Ligne 50: | Ligne 53: | ||
| {{: | {{: | ||
| + | |||
| + | ===== Les classes de tkinter ===== | ||
| + | |||
| + | |**// | ||
| + | |Button| | ||
| + | |Canvas| | ||
| + | |Checkbutton| | ||
| + | |Entry| | ||
| + | |Frame| | ||
| + | |Label| | ||
| + | |Listbox| | ||
| + | |Menu| | ||
| + | |Menubutton| | ||
| + | |Message| | ||
| + | |Radiobutton| | ||
| + | |Scale| | ||
| + | |Scrollbar| | ||
| + | |Text| | ||
| + | |Toplevel| | ||
| + | |||
| + | ==== Button ==== | ||
| + | |||
| + | <code python> | ||
| + | |||
| + | from tkinter import * | ||
| + | |||
| + | fenetre = Tk() | ||
| + | |||
| + | bouton1 = Button(fenetre, | ||
| + | bouton1.pack() | ||
| + | |||
| + | fenetre.mainloop() | ||
| + | |||
| + | </ | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ==== 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() | ||
| + | |||
| + | </ | ||
| + | |||
| + | {{: | ||
| + | |||
| + | \\ | ||