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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
from functools import partial
import tkinter as tk
from tkinter import Toplevel, Canvas
def dashboard_view(self):
"""
Permet d'afficher des toplevel contenant des graphique
de l'analyse demmander
"""
fram = Toplevel(self)
fram.title("Analyse graphique")
fram.config(background= "#005b96")
fram.geometry("1400x800+250+100")
fram.wm_state("zoomed")
titre1 = tk.Label(fram, text='Mod')
titre1.place(relx=0.5, rely=0.03, anchor='center')
frame2 = tk.Frame(fram)
frame2.config(background= '#FFA500')
frame2.pack(side="top", fill="both", expand = True)
frame2.grid_rowconfigure(0, weight=1)
frame2.grid_columnconfigure(0, weight=1)
class Principal(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
tk.Tk.wm_title(self, "Appli extract")
container = tk.Frame(self)
container.pack(side="top", fill="both", expand = True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.liste_page = {}
for page in (PageOne, PageTwo, PageThree):
frame = page(container, self) # création de page ancré sur le contenair de classe PageOne ..
self.liste_page[page] = frame # One done a la liste la page
frame.grid(row=0, column=0, sticky="nsew") # on place la page
self.show_frame(PageOne)# on appel la fonction page 1
def show_frame(self, cont):
frame = self.liste_page[cont]
frame.tkraise()
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
tk.Frame.config(self, background= '#87CEFA')
titre = tk.Label(self,text='Page un')
button_graph = tk.Button(self, text='go page 3', command= partial (controller.show_frame,PageThree))
titre.place(relx=0.5, rely=0.12, anchor='center')
button_graph.place(relx=0.5, rely=0.5, anchor='center')
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
class PageThree(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
tk.Frame.config(self, background= '#87CEFA')
widget_boutton = Canvas(
self, width=300, height=50, bg= "#005b96",
highlightbackground= "#005b96",
highlightcolor= "#005b96"
)
button_graph = tk.Button(widget_boutton, command=partial(dashboard_view, self))
button_graph.config(fg='#FFA500',bg= 'black', text='Graphique')
widget_boutton.place(relx=0.5, rely=0.55, anchor='center')#container
button_graph.place(relx=0.5, rely=0.55, anchor='center')
app= Principal()
app.geometry("400x300+750+300")
app.mainloop() |
Partager