Sep-02-2018, 08:28 PM
Hi
i have a problem with the Listbox on Tkinter.
When i select with mouse one word in the Listbox, the program give me the relative code.
If i select another word again in the Listbox the program put the new code under the first one.
I would like that at the second selection the code before disappear.
What can I have to change?
THANK U!
(sorry for my english
)
This is my code:
i have a problem with the Listbox on Tkinter.
When i select with mouse one word in the Listbox, the program give me the relative code.
If i select another word again in the Listbox the program put the new code under the first one.
I would like that at the second selection the code before disappear.
What can I have to change?
THANK U!
(sorry for my english
)This is my code:
from tkinter import *
from tkinter.font import Font
root = Tk()
text = Text(root)
myFont = Font(family="Times New Roman", size=12)
text.configure(font=myFont)
class articoli:
def __init__(self,codice,modello,pezzi_ora,cod_materiale,mis_materiale,
ultima_mod,materiale_casa):
self.codice = codice
self.modello = modello
self.pezzi_ora = pezzi_ora
self.cod_materiale = cod_materiale
self.mis_materiale = mis_materiale
self.ultima_mod = ultima_mod
self.materiale_casa = materiale_casa
self.label_8 = Label()
self.label_8.configure(text=self.codice,font=myFont)
self.label_8.pack(side=TOP)
self.label_9 = Label()
self.label_9.configure(text=self.modello,font=myFont)
self.label_9.pack(side=TOP)
self.label_10 = Label()
self.label_10.configure(text=self.pezzi_ora,font=myFont)
self.label_10.pack(side=TOP)
self.label_11 = Label()
self.label_11.configure(text=self.cod_materiale,font=myFont)
self.label_11.pack(side=TOP)
self.label_12 = Label()
self.label_12.configure(text=self.mis_materiale,font=myFont)
self.label_12.pack(side=TOP)
self.label_13 = Label()
self.label_13.configure(text=self.ultima_mod,font=myFont)
self.label_13.pack(side=TOP)
self.label_14 = Label()
self.label_14.configure(text=self.materiale_casa,font=myFont)
self.label_14.pack(side=TOP)
def callback(event):
value=str((Lb1.get(ACTIVE)))
print (value)
sys.stdout.flush()
if value== "Python":
Ps_48 = articoli("Ps 48","Patt_inf_est","1500","NG00002","135_5","20_04_2018",
"20")
elif value== "Perl":
Ps_40 = articoli("Ps_40","patt_sup_est","1000","NG00001",
"130_4","18_05_2018","2000")
elif value== "C":
Ps_42 = articoli("Ps_40","patt_sup_est","1000","NG00001",
"135_4","18_05_2018","3000")
elif value== "PHP":
Ps_45 = articoli("Ps_40","patt_sup_est","1000","NG00001",
"139_4","18_05_2018","4000")
elif value== "JSP":
Ps_47 = articoli("Ps_40","patt_sup_est","1000","NG00001",
"140_4","18_05_2018","5000")
#listbox definition
Lb1 = Listbox(selectmode=SINGLE)
Lb1.insert(1, "Python")
Lb1.insert(2, "Perl")
Lb1.insert(3, "C")
Lb1.insert(4, "PHP")
Lb1.insert(5, "JSP")
Lb1.pack(side=LEFT,fill=BOTH,expand=YES)
#scrollbar configuration
scrollbar = Scrollbar()
scrollbar.pack(side=LEFT, fill=Y)
#listbox configuration
Lb1.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=Lb1.yview)
#double click for listbox
Lb1.bind('<Double-Button-1>',callback)
root.mainloop()
