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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| from tkinter import *
from tkinter import ttk
L = 600
H = 500
nbreElement = 4
def createTab():
print("OUI!")
def createTab2():
print("NON!")
def Statistique1(t, monText):
pass
def Statistique(t, monText):
fonts = {
'normal': 'arial 9',
'bold': 'arial 9 bold',
}
monText.grid(row=0, column=0, sticky='nwse') # expansion du widget Text
for i in range(nbreElement):
monText.columnconfigure(i, weight=1)
#monText.rowconfigure(i, weight=1)
color = ['grey75', 'orange'][i % 2]
for j in range(3):
label = Label(monText, text=t, width=int(L/nbreElement),
bg=color, anchor='s',
font=fonts['normal'])
label.grid(row=j, column=i, padx=1)
#return monText
def create_frame(master, t):
frame = Frame(master, bd=2, relief=SUNKEN)
t = "mon lab"
frame.grid_columnconfigure(0, weight=1) # expansion de la colonne
frame.grid_rowconfigure(0, weight=1) # expansion de la colonne
monText = Text(frame)
monText.grid(row=0, column=0, sticky='nwse') # expansion du widget Text
#monText.insert(0.0, t)
#newBtn = Button(toolbar, text="Tableau", bg="maroon", fg="white", borderwidth=3, command=Statistique(t, monText))
newBtn = Button(toolbar, text="NON", bg="maroon", fg="white", borderwidth=3, command=createTab2())
newBtn.pack(side=LEFT, fill=X)
root.geometry('{}x{}'.format(L, H))
return frame
#createTab()
if __name__ == '__main__':
root = Tk()
myColor="lightblue"
# Defines and places the notebook widget
nb = ttk.Notebook(root)
toolbar = Frame(root, borderwidth=2, relief='raised', background=myColor)
frame1 = create_frame(nb,1)
nb.add(frame1, text='Text')
toolbar.pack(side=TOP, fill=X)
nb.pack(fill=BOTH, expand=1)
t=""
monText=frame1
newBtn = Button(toolbar, text="OUI", bg="red", fg="white", borderwidth=3, command=createTab())
newBtn.pack(side=LEFT, fill=X)
# Fin du menu deroulant #############################################
root.configure(background="green")
root.mainloop() |
Partager