1
votes

I have a simple TKinter GUI that has a text entry box and a button. I want to enter text, click the button, and have my program print the text. The GUI works fine, except when I click on the text entry box and type I don't see the cursor or the text until I resize the window or click the button. When I click the button the text shows up in the entry box and is returned. The GUI is not updating as I enter text. I'm running Python 3.4 on OS X 10.10. Any ideas would be welcome.

Here is the code:

#!/usr/bin/env python
from tkinter import *

def getstring():
    filter_string= sfilter.get()
    print('User Entered:', filter_string)
    root.destroy()
    return

root = Tk()
root.geometry('400x400+500+300')
root.title("Extract")

sfilter= StringVar()

label1= Label(root, text= "Design Corner Filter:").grid(row=1, column=1)
dfilter_box= Entry(root, textvariable=sfilter).grid(row=1,column=2)
button1= Button(root, text= 'Plot', command= getstring).grid(row=2, column=2)

root.mainloop()
1
Seems to work fine for me: python 3.4.0, Ubuntu 14.04 x86_64 - Marcin
Thanks for checking out my code Marcin. I think it is a Mac OS X issue. I can add that I installed Python 3.4.1 using Anaconda. When I check the version I get- Python 3.4.1 :: Anaconda 2.1.0 (x86_64). The version of tkinter is tk-8.5.15-0. - jkueng

1 Answers

0
votes

Not working: Windows 7, python3.4.1

If you don't require string vars you can call the get method on the widget

dfilter_box.get()