1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| #!/usr/bin/env python
# -*- coding: utf-8 -*-
from Tkinter import *
# valable à partir de Tcl/Tk v8.5
try:
import ttk
except ImportError:
print "Pas de bol..."
exit(1)
else:
print "Tcl version :", TclVersion
print "Tk version :", TkVersion
# end try
# fenêtre principale
fenetre = Tk()
# objet ttk.Notebook pour avoir des onglets
notebook = ttk.Notebook(fenetre, width=300, height=200)
notebook.pack(expand=1, fill=BOTH, padx=5, pady=5)
# onglet 1
tab1 = Frame(notebook, bg="yellow")
# ajoutez-y ce que vous voulez...
Label(tab1, text="label 1").pack(pady=10)
Button(tab1, text="bouton 1").pack()
# on ajoute l'onglet...
notebook.add(tab1, text="Onglet 1", sticky=NW+SE)
# onglet 2
tab2 = Frame(notebook, bg="cyan")
# ajoutez-y ce que vous voulez...
Label(tab2, text="label 2").pack(pady=10)
Button(tab2, text="bouton 2").pack()
Button(tab2, text="bouton 2").pack()
# on ajoute l'onglet...
notebook.add(tab2, text="Onglet 2", sticky=NW+SE)
# onglet 3
tab3 = Frame(notebook, bg="orange")
# ajoutez-y ce que vous voulez...
Label(tab3, text="label 3").pack(pady=10)
Button(tab3, text="bouton 3").pack()
Button(tab3, text="bouton 3").pack()
Button(tab3, text="bouton 3").pack()
# on ajoute l'onglet...
notebook.add(tab3, text="Onglet 3", sticky=NW+SE)
# boucle principale
fenetre.mainloop() |
Partager