tkinter won't update entry box with function
<p>Lately I've bean learning how to use the tkinter module in Python 3 to create a GUI. Unfortunately I've become stuck on an issue where my Entry widgets won't update. To understand the problem I wrote a short test case that populates an Entry widget with the string 'hello'.</p>

<pre><code>class SettingsWindow():

    def __init__(self):
        self.root = tk.Tk()

        main_frame = ttk.Frame(self.root, padding=(15, 15, 15, 15))
        main_frame.grid()

        start_time = tk.StringVar()
        start_time_ent = ttk.Entry(main_frame, textvariable=start_time, width=5)
        start_time.set('hello')
        start_time_ent.grid()

        main_frame.mainloop()

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

<p>The issue arises when I attempt to organize my work in terms of methods:</p>

<pre><code>class SettingsWindow():

    def __init__(self):
        self.root = tk.Tk()

        main_frame = ttk.Frame(self.root, padding=(15, 15, 15, 15))
        main_frame.grid()

        self.general_settings(main_frame, parent_column=1, parent_row=2)

        main_frame.mainloop()

    def general_settings(self, parent_frame, parent_column=0, parent_row=0):
        start_time = tk.StringVar()
        start_time_ent = ttk.Entry(parent_frame, textvariable=start_time, width=5)
        start_time.set('hello')
        start_time_ent.grid()

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

<p>When I run the second version of the code, the window loads with an empty Entry widget. My only guess on why this happens is  <code>start_time.set('hello')</code> is stuck in some queue and I'm missing a command when compiling the window. Any suggestions?</p>

<p>The ttk widgets are particularly sensitive to the garbage collector. Make <code>start_time</code> an instance variable rather than a local variable.</p>

python python-3.x user-interface tkinter