Update default value Entry Widget
<p>I have a toplevel window containing a simple entry widget and two buttons. (Class opc)</p>

<p>The entry widget has assigned a default value "test". What IÂ´m trying to do is update this default value when the user input a new value, and show this as default in new instances of the window.</p>

<p>When I change the value and save changes, new instances of the windows always show "test" and not the new input.</p>

<p>What is the best way to do this? Should I use "Stringvar"?</p>

<pre><code>import tkinter as tk
from tkinter import ttk


class TEP(tk.Frame):
    def __init__(self, parent):
        tk.Frame.__init__(self, parent)
        self.parent = parent

        label=tk.LabelFrame(self, text="REFERENCIAS", height=180, labelanchor="n",borderwidth="2",relief="groove")
        label.pack(fill="x",padx=10,pady=10)


class opc(tk.Frame):     
    def __init__(self, parent,*args, **kwargs):
        tk.Frame.__init__(self, parent,*args, **kwargs)
        self.parent = parent
        self.grid()


        datlab = tk.LabelFrame(self.parent, text="InformaciÃ³n", labelanchor="nw",borderwidth="2",relief="groove")  
        datlab.grid(column=0,row=0,padx=5,pady=3,ipadx=5,ipady=5)

        labelproy=tk.Label(datlab,text="Proyecto:",padx=5,pady=5)
        labelproy.grid(column=0, row=0, sticky=tk.W)
        self.entrproy=tk.Entry(datlab,width=27)
        self.entrproy.insert(0,"Test")
        self.entrproy.grid(row=0,column=1,sticky=tk.W,padx=5) 

        self.ok = ttk.Button(self.parent, text="OK", command=self.getdata)
        self.ok.grid(column=0,row=4,sticky=tk.W,padx=50,pady=7)
        self.cancel = ttk.Button(self.parent, text="Cancelar", command=self.parent.destroy)
        self.cancel.grid(column=0,row=4,sticky=tk.E,padx=50,pady=7)

        self.parent.bind('&lt;Return&gt;',self.getdata)

    def getdata(self,*args):

        self.Proyecto=self.entrproy.get() 
        print(self.Proyecto)
        self.parent.destroy()



def main(): 
    root = tk.Tk()
    app = TEP(root)
    app.pack(side="top", fill="both", expand = True)
    menubar=MenuBar(root)
    menubar.add
    root.config(menu=menubar)
    root.title("App")
    root.focus_force()
#    root.wm_state('zoomed')
    root.minsize(width=1000, height=420)
    root.columnconfigure(0,weight=1)
    root.rowconfigure(0,weight=1)
    root.mainloop()

if __name__ == '__main__':
    main()
</code></pre>

<p>One option is to create a list owned by the class, i.e.:</p>

<pre><code>class classname(object):
    defaultvalue=[100] #Default is 100

    def dostuff(self):
         self.defaultvalue[0]=self.entryname.get()
</code></pre>

<p>The basic idea is that each class has the same value for defaultvalue: a link to a spot in memory where '100' is stored.  If you change the value at that location, it will update it for future instances of the class.</p>

python tkinter