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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
# Liaison PDFAjouts_DB_BackEnd.py
# ==================================================
# Variables - Tableaux
# ==================================================
global L_Conf_TV
L_Conf_TV = []
global Liste_TV
Liste_TV = []
global Liste_IDTV
Liste_IDTV = []
global Liste_DB
Liste_DB = []
global frames # Liste frames container
frames = []
def PDF_Contenu():
tpdf = tk.Toplevel()
tpdf.title("Création PDF")
tpdf.resizable(width=False, height=False) # Fenêtre verrouillée
tpdf.attributes("-toolwindow", 1) # Supprime les boutons Réduire/Agrandir
# ==================================================
# FRAMES
# ==================================================
# --- Frame [Master pour frame générées]
F_Master_TVx = tk.LabelFrame(tpdf, foreground="blue", relief=SOLID, borderwidth=1)
F_Master_TVx.place(x=5, y=211, width=1515, height=196)
# --- Frame [Treeview 1]
F_TV1 = tk.Frame(F_Master_TVx, relief=SOLID, borderwidth=1)
F_TV1.grid(row=0, column=0)
# --- Frame [Treeview 2]
F_TV2 = tk.Frame(F_Master_TVx, relief=SOLID, borderwidth=1)
F_TV2.grid(row=0, column=1)
# ==================================================
# FONCTIONS
# ==================================================
# --- Insertion Table Nom HV dans TreeView
def DisplayData_Ajouts(ID_DB, ID_Nom_Champ, ID_TV):
for i in PDFAjouts_DB_BackEnd.loadRecord(ID_DB, ID_Nom_Champ):
ID_TV.insert('', 'end', i[0], text=i[0], values=(i[0],)) # Pour transcrire une chaine avec des espaces, le moyen le plus simple, est de le passer en tant que tuple
# Création dynamique frame(s) contenant la sélection faite depuis TreeView dans un label
def selectItem(event):
print("a", event) # <ButtonRelease event state=Mod1|Button1 num=1 x=25 y=35>
global frames
var = IntVar()
frame = Frame(F_TV1) # frame généré dans la frame master
# === [Listing Table dans Widget Treeview] ===
curItem = Liste_IDTV[0].focus()
Liste = Liste_IDTV[0].item(curItem)["values"]
# === [Génére automatiquement le container frame contant les futurs widgets Labels] ===
frame.configure(relief=GROOVE)
frame.grid(row=len(frames) + 1, column=1, pady=1) # Nb de Colonne à générer - pady=intervale entre la prochaine
var.set(len(frames))
if len(frames) < 5:
L_Line = []
if Liste[0] != "":
# -- Génère Label - Affiche le Nb de Frame généré
l = Label(frame, textvariable=var)
l.grid(row=0, column=0)
# -- Génére Label - Nom
lb_nom = ""
Label(frame, text=Liste[0]).grid(row=0, column=1)
lb_nom = frame.winfo_children()[1] # Récupère le nom du label
L_Line.append(Liste[0])
l.var = var
frames.append(frame) # liste des frames générée
# ==================================================
# TreeViews Ajouts
# ==================================================
L_Conf_TV = [["TV1", "scb1", "Acides Gras", "AG", "AG_Nom", 0], ["TV2", "scb2", "Anti-Oxydants", "AO", "AO_Nom", 189], ["TV3", "scb3", "Argiles", "ARG", "ARG_Nom", 378], ["TV4", "scb4", "Divers", "Divers", "Divers_Nom", 567], ["TV5", "scb5", "Fragrances", "FRAG", "FRAG_Nom", 756],["TV6", "scb6", "Huiles Essentiels", "HE", "HE_Nom", 945],["TV7", "scb7", "Agents Epaississants", "AE", "AE_Nom", 1134], ["TV8", "scb8", "Teintes & Micas", "TT", "TT_Color", 1323]]
for u in range(0, 8):
L_TVNom = L_Conf_TV[u][0]
L_scbNom = L_Conf_TV[u][1]
L_NomCol = L_Conf_TV[u][2]
L_x = L_Conf_TV[u][5]
# --- Insertion Scrollbar
L_scbNom = Scrollbar(F_Treeviews, orient='vertical') # Ascenseur Vertical
L_scbNom.place(x=L_x + 174, y=24, height=153)
L_TVNom = ttk.Treeview(F_Treeviews, selectmode="browse", columns=(1), show="headings", yscrollcommand=L_scbNom.set)
L_TVNom.heading('#1', text=L_NomCol)
L_TVNom.column('#1', width=175, minwidth=40, stretch=OFF)
L_TVNom.place(x=L_x, y=2, width=175, height=175)
L_scbNom.config(command=L_TVNom.yview) # Ascenseur Vertical
# Liste des widgets dans Treeview
Liste_TV.append(F_Treeviews.winfo_children())
# Liste des ID Treeview uniquements --> (From, To, Step)
for u in range(1, len(Liste_TV[0]), 2):
Liste_IDTV.append((Liste_TV[0][u]))
# Insertion ID_TV dans L_Conf_TV
for u in range(0, len(Liste_IDTV)):
L_Conf_TV[u].append(Liste_IDTV[u])
# Display DATA to Treeview # ["TV1", "scb1", "Col1", "AG", "AG_Nom", 0, IDTV]
for u in range(0, len(L_Conf_TV)):
ID_DB = L_Conf_TV[u][3] # Identification Nom Base de Données cible
ID_Nom_Champ = L_Conf_TV[u][4] # Identification Nom du champ cible
ID_TV = L_Conf_TV[u][6] # Identification ID Treeview
DisplayData_Ajouts(ID_DB, ID_Nom_Champ, ID_TV)
# ==================================================
# BIND - TreeViews
# ==================================================
# Affiche Entry widget, via souris, la sélection des Datas [Colonnes Treeview]
Liste_IDTV[0].bind('<ButtonRelease-1>', selectItem) # Le bouton de la souris a été relâché |