DJ80
DJ80

Reputation: 43

Problems with get() for Tkinter widgets

I'm having an issue getting a value out of my entry boxes with Tkinter. What I'm trying to work with right now is

S1 = Entry(attr,
           width = 3).grid(row = 0,
                           column = 1)
L = Label(attr,
          width = 5,
          relief = RIDGE,
          anchor = E,
          text = "STR: ").grid(row = 0,
                               column = 0)

with a button at the end to attempt to get multiple values out (several .get()s instead of just the one here)

def Process():
   SEN = S1.get()

Button(attr,
       text = 'Continue',
       command=Process).grid(row = 8, column = 0)

I have the labels and Entrys set up as their own functions. it functions until I attempt to get() the data out. Where am I going wrong?

Upvotes: 0

Views: 151

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386285

When you do S1=Entry(...).grid(...), what is stored in S1 is the result of the grid function, which is always None. If you want to store a reference to the widget then you need to call grid separately.

Try this to see:

S1 = Entry(attr, width=3)
S1.grid(row=0, column=1)

Upvotes: 2

Related Questions