I made a gui which collects data, the data is saved in sqlite3 and shown in a listbox.
Made a function which sends the user a mail with the data of a selected row, and give that row the color yellow.
The problem is that the program does not save these color changes. When i quit and run the program again, the color changes back to white again.
Made a simple example which shows the problem:
from tkinter import *
top = Tk()
top.geometry("800x400+0+0")
Lb1 = Listbox(top)
Lb1.insert(1, "Python")
Lb1.insert(2, "Perl")
Lb1.insert(3, "C")
Lb1.insert(4, "PHP")
Lb1.insert(5, "JSP")
Lb1.insert(6, "Ruby")
Lb1.pack()
def color_yellow():
Lb1.itemconfig(Lb1.curselection()[0], {'bg':'Yellow'})
b1=Button(top,text="color row Yellow",width=16,command=color_yellow)
b1.place(relx=0.5, rely=0.6, anchor=CENTER)
top.mainloop()
Tried with pickle but can't get it working:
from tkinter import *
import pickle
top = Tk()
top.geometry("800x400+0+0")
Lb1 = Listbox(top)
Lb1.insert(1, "Python")
Lb1.insert(2, "Perl")
Lb1.insert(3, "C")
Lb1.insert(4, "PHP")
Lb1.insert(5, "JSP")
Lb1.insert(6, "Ruby")
Lb1.pack()
def color_yellow():
Lb1.itemconfig(Lb1.curselection()[0], {'bg':'Yellow'})
return
pickle_out = open("dict.pickle","wb")
pickle.dump(color_yellow, pickle_out)
pickle_out.close()
pickle_in = open("dict.pickle","rb")
color_yellow = pickle.load(pickle_in)
b1=Button(top,text="color row Yellow",width=16,command=color_yellow)
b1.place(relx=0.5, rely=0.6, anchor=CENTER)
top.mainloop()