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 59
| from tkinter import *
import tkinter.tix as tix
from tkinter import ttk
def Statistique():
fonts = {
'normal': 'arial 9',
'bold': 'arial 9 bold',
}
for i in range(3):
color = ['grey75', 'white'][i % 2]
for j in range(3):
label = tix.Label(frame1, text='label %d x %d' % (j, i),
bg=color, width=2, anchor='w',
font=fonts['normal'])
label.grid(row=j, column=i, padx=1)
return frame1
def create_frame(master, t):
frame = Frame(master, bd=2, relief=SUNKEN)
t = ""
text = Text(frame, font=48)
text.grid(row=0, column=0, sticky='nwse') # expansion du widget Text
frame.grid_columnconfigure(0, weight=3) # expansion de la colonne
frame.grid_rowconfigure(0, weight=3) # expansion de la colonne
text.insert(0.0, t)
newBtn = Button(toolbar, text="Tableau", borderwidth=3, command=Statistique)
newBtn.pack(side=LEFT, fill=X)
return frame
if __name__ == '__main__':
root = tix.Tk()
myColor="lightblue"
# Defines and places the notebook widget
nb = ttk.Notebook(root)
toolbar = Frame(root, borderwidth=2, relief='raised', background=myColor)
root.update()
frame1 = create_frame(nb,1)
nb.add(frame1, text='Text')
toolbar.pack(side=TOP, fill=X)
nb.pack(fill=BOTH, expand=1)
root.update()
# Fin du menu deroulant #############################################
root.configure(background="green")
root.mainloop() |
Partager