basic python entry tkinter widget how-to
I'm trying to use entry to get a response:
Code:
from Tkinter import * 1. What do I need to do? 2. When I do get the answer (printed, not as a variable), it comes with a new line, how do I eliminate the new line, or get it to signal enter? |
DISCLAIMER: I'm still putzing around with Python, so don't take my answers as gospel.
You could do something like this... Code:
from Tkinter import * In my modification, the setanswer function sets the variable to whatever is typed into the entry box. The printanswer function prints what is in the answer variable. You can type something new into the entry box, but until you click SET, the variable doesn't change. I also set master to a frame, and got rid of parent. You were creating three root windows with the three "= Tk()" lines. Python normal ends a print command with a newline, unless you append a comma at the end... Code:
print answer, Code:
print 'The answer is "%s".' % answer |
Well, I've been piddling around with this program for a while. I got the program down a while ago (Make a guess, check it, I even got it printing to tkinter), but I can't get it to enter with tkinter.
Thoughts? Code:
|
All times are GMT -5. The time now is 12:25 PM. |