Hello ,
I am making tries to display images in different tkinter windows , in every window displaying a different image , for this i made this code :
# -*- coding: cp1252 -*-
from Tkinter import *
import Tkinter as tk
import ttk
from PIL import ImageTk, Image
import os
def interface2():
fenetre2=Toplevel()
fenetre2.geometry("500x400")
fenetre2.title(' ')
f1 = Frame(fenetre2, bg="blue", width=500, height=400)
f1.pack( fill=X, expand=0)
print modelidmodifvar2
print "image%s.jpg"%(modelidmodifvar2)
img2 = ImageTk.PhotoImage(Image.open("image%s.jpg"%modelidmodifvar2))
labimg.config( image=img2 )
print 'ok'
lab1 = Label(fenetre2, text="Gestion de ressources informatiques" , bg = "blue", fg = "white" )
lab1.place ( x=152 , y=25 )
buttonquit = Button(fenetre2, text = "Quitter", command = fenetre2.destroy)
buttonquit.place( x=224 , y=374 )
#Display
fenetre.withdraw()
fenetre=Tk()
fenetre.geometry("500x400")
fenetre.title(' ')
f1 = Frame(fenetre, bg="blue", width=500, height=400)
f1.pack( fill=X, expand=0)
global modelidmodifvar
global modelidmodifvar2
global labimg
modelidmodifvar = StringVar
modelidmodifvar2 = StringVar
modelidmodifvar = '12013'
modelidmodifvar2 = '22013'
labimg = Label(fenetre)
labimg.place(x=10,y=10)
img = ImageTk.PhotoImage(Image.open("image%s.jpg"%modelidmodifvar))
labimg.config( image=img )
lab1 = Label(fenetre, text="Gestion de ressources informatiques" , bg = "blue", fg = "white" )
lab1.place ( x=152 , y=25 )
butval = Button(fenetre, text = "valider", command = interface2)
butval.place( x=224 , y=54 )
buttonquit = Button(fenetre, text = "Quitter", command = fenetre.destroy)
buttonquit.place( x=224 , y=374 )
#Display
fenetre.mainloop()
In the first window , it dispays well the first image :"image12013.jpg" , but on the second window , that display nothing , and don't show any error message !
Can i know why plz ?