python:interface_graphique_tkinter:start

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

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] physixpython:interface_graphique_tkinter:start [2020/07/24 03:31] (Version actuelle) – modification externe 127.0.0.1
Ligne 5: Ligne 5:
 [[https://python.developpez.com/cours/TutoSwinnen/?page=Chapitre8|https://python.developpez.com/cours/TutoSwinnen/?page=Chapitre8]] [[https://python.developpez.com/cours/TutoSwinnen/?page=Chapitre8|https://python.developpez.com/cours/TutoSwinnen/?page=Chapitre8]]
  
-===== Hello world =====<code>+===== Exemples =====
  
 +==== Hello world ====
 +
 +<code python>
 from tkinter import * from tkinter import *
  
Ligne 23: Ligne 26:
 {{:python:interface_graphique_tkinter:609b587a51454113e998da2bb815bd1f.png}} {{:python:interface_graphique_tkinter:609b587a51454113e998da2bb815bd1f.png}}
  
-===== Calculatrice =====+==== Calculatrice ====
  
-<code>+<code python>
 from tkinter import * from tkinter import *
 from math import * from math import *
Ligne 50: Ligne 53:
  
 {{:python:interface_graphique_tkinter:1b5cc3a0407b8aa5171f808ed3d91bf1.png}} {{:python:interface_graphique_tkinter:1b5cc3a0407b8aa5171f808ed3d91bf1.png}}
 +
 +===== Les classes de tkinter =====
 +
 +|**//Widget// ** |
 +|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, text='Quitter', command = fenetre.destroy)
 +bouton1.pack()
 +
 +fenetre.mainloop()
 +
 +</code>
 +
 +{{:python:interface_graphique_tkinter:1851b60ce2895547f37ffc52390106d6.png}}
 +
 +==== Canvas ====
 +
 +<code python>
 +from tkinter import *
 +
 +fenetre = Tk()
 +
 +canvas = Canvas(fenetre, width=150, height=120, background='yellow')
 +ligne1 = canvas.create_line(75, 0, 75, 120)
 +ligne2 = canvas.create_line(0, 60, 150, 60)
 +txt = canvas.create_text(75, 60, text="Cible", font="Arial 16 italic", fill="blue")
 +canvas.pack()
 +
 +fenetre.mainloop()
 +
 +</code>
 +
 +{{:python:interface_graphique_tkinter:0a1138db124dd712b5f9c72c70892c3c.png}}
 +
 +Autres éléments :
 +
 +<code python>
 +create_arc()        :  arc de cercle
 +create_bitmap()     :  bitmap
 +create_image()      :  image
 +create_line()       :  ligne
 +create_oval()       :  ovale
 +create_polygon()    :  polygone
 +create_rectangle()  :  rectangle
 +create_text()       :  texte
 +create_window()     :  fenetre
 +
 +</code>
 +
 +Pour changer les coordonnées d'un élément :
 +
 +<code python>
 +canvas.coords(élément, x0, y0, x1, y1)
 +
 +</code>
 +
 +Pour supprimer un élément :
 +
 +<code python>
 +canvas.delete(élément)
 +
 +</code>
 +
 +==== Checkbutton ====
 +
 +<code python>
 +from tkinter import *
 +
 +fenetre = Tk()
 +
 +bouton = Checkbutton(fenetre, text="Nouveau?")
 +bouton.pack()
 +
 +fenetre.mainloop()
 +
 +</code>
 +
 +{{:python:interface_graphique_tkinter:c1aefef4966d648292f2f3f3c9d6de78.png}}
 +
 +\\
  
  
  • python/interface_graphique_tkinter/start.1570889127.txt.gz
  • Dernière modification : 2020/07/24 00:23
  • (modification externe)