Hello

Je voudrai dupliquer a volonté un label ,mai en changer le texte:

par exemple (code brouillon non fonctionnel):
Avec un label la ligne des option devient vite très longue (bon on peux les couper m'en-fin c'est pas la question ici)
je cherche a faire,(en très gros)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
def copielabel(texte)
   while True
      lab=Label(self, text =texte, justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor ,foreground =self.labelForeground)
   return lab
 
 
copielabel("texte 1")
copielabel("texte 2")
copielabel("texte 3")

plutot que de faire:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
# Lfr[7] = liste contenan le text
    txt1 = Label(self, text =Lfr[7], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor ,foreground =self.labelForeground)
    txt2 = Label(self, text =Lfr[8], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
    txt3 = Label(self, text =Lfr[12], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
    txt4 = Label(self, text =Lfr[13], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
    txt5 = Label(self, text =Lfr[9], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
    txt6 = Label(self, text =Lfr[10], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
    txt7 = Label(self, text =Lfr[15], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
    txt8 = Label(self, text =Lfr[11], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
    txt9 = Label(self, text =Lfr[14], justify=LEFT , anchor=SW , width =self.longStringLabel, height =1, relief = self.label3d ,background = self.labelBagroundColor,foreground =self.labelForeground)
 
#etc etc
Merci d'avance