Hi;
but my pictures are included inside Text widget and not into Label widget ; see the code after improving the comments :
but my pictures are included inside Text widget and not into Label widget ; see the code after improving the comments :
#!/usr/bin/python3 # -*- coding: utf-8 -*- from tkinter import * import pathlib #to create directory if not exits import sqlite3 import time import datetime root = Tk() case_correction_ddm=IntVar() ent_monitor_cev=StringVar() def CreerTable_cev(): #create directories and sub directories "bdd/Test" for test.db pathlib.Path('bdd/Test').mkdir(parents=True, exist_ok=True) conn1 = sqlite3.connect('bdd/Test/Test.db') curseur1 = conn1.cursor() curseur1.execute('''CREATE TABLE IF NOT EXISTS cev (id_cev INTEGER PRIMARY KEY,time_cev TEXT NOT NULL,lecture_monitor_cev TEXT NOT NULL,chemin_vers_image_message_cev TEXT NOT NULL)''') curseur1.close() # add values to the cev table by button "Run" def Add_To_Table_cev(): global chemin_image_message_cev_get if case_correction_ddm.get () : chemin_image_message_cev_get='images/correction_approuvee.gif' else: chemin_image_message_cev_get='images/correction_non_approuvee.gif' time_cev_get = str(time.strftime('%d/%m/%y à %H:%M:%S', time.localtime())) lecture_monitor_cev_get = str(ent_monitor_cev.get()) conn2 = sqlite3.connect('bdd/Test/Test.db') curseur2 = conn2.cursor() curseur2.execute('''INSERT INTO cev (time_cev,lecture_monitor_cev,chemin_vers_image_message_cev) VALUES (?,?,?)''',(time_cev_get,lecture_monitor_cev_get,chemin_image_message_cev_get)) conn2.commit() curseur2.close() # reading the content of the cev table def AfficherTable_cev(): T_cev.delete('1.0', END) T_cev.update() conn3 = sqlite3.connect('bdd/Test/Test.db') curseur3 = conn3.cursor() for resultats_cev in curseur3.execute('SELECT * FROM cev ORDER BY id_cev DESC'): indice1_modifie=str(resultats_cev[1]).center(70) chaine_etoile="*************************************************************************************\n" contenu_table_cev= str(indice1_modifie)+"\n\n"+"ddm lue par Monitor : "+ str(resultats_cev[2])+"\n\n" #picture path is given by : str(resultats_cev[3]) photo=PhotoImage(file=str(resultats_cev[3])) T_cev.insert(INSERT, chaine_etoile) T_cev.image_create(INSERT, image=photo) T_cev.insert(END,contenu_table_cev) curseur3.close() #call for the creation of the cev table CreerTable_cev() S_cev = Scrollbar(root) T_cev = Text(root, height=25, width=90) S_cev.pack(side=RIGHT, fill=Y) T_cev.pack(side=LEFT, fill=Y) S_cev.config(command=T_cev.yview) T_cev.config(yscrollcommand=S_cev.set) # display the content of the table cev AfficherTable_cev() entry_lecture_monitor=Entry(root,textvariable=ent_monitor_cev,font=('arial',12,'bold')) entry_lecture_monitor.pack(side=BOTTOM,pady=10 ) bouton_executer=Button(root,text='Run',command=lambda:[Add_To_Table_cev(),AfficherTable_cev()]) bouton_executer.pack(side=BOTTOM ) case_correction=Checkbutton(root,fg='black',variable=case_correction_ddm) case_correction.configure(text="confirmation") case_correction.pack(side=BOTTOM) root.mainloop()