-1

I have a problem with Python programming with tkinter and my problem is AttributeError: 'NoneType' object has no attribute 'get'. Can you tell me how to get this error?

import ghasedak
from tkinter import *
root = Tk()
root.title('Dad')
root.geometry('700x600')
sms = ghasedak.Ghasedak('da3cd36817f7f4ce24cab83a9f11084bee9b74eb89f8f07a319564b7ab27e476')
def what():
    entryg = te.get()
    if entryg == 'w':
        sms.send({ 'message':'Dad wants water',  'receptor' : '09028435128',  'linenumber': '10008566' })
    elif entryg == 'n':
        sms.send({ 'message':'Dad wants nescafe',  'receptor' : '09028435128',  'linenumber': '10008566' })
    elif entryg == 's':
        sms.send({ 'message':'Dad wants Syrup',  'receptor' : '09028435128',  'linenumber': '10008566' })
    elif entryg == 't':
        sms.send({ 'message':'Dad wants tea',  'receptor' : '09028435128',  'linenumber': '10008566' })
    elif entryg == 'c':
        sms.send({ 'message':'Dad wants coffee',  'receptor' : '09028435128',  'linenumber': '10008566' })
    elif entryg == 'l':
        sms.send({ 'message':'Dad says please calm down',  'receptor' : '09028435128',  'linenumber': '10008566' })
tl = Label(root, text = 'What do you want?').grid(row = 0, column = 0)
te = Entry(root).grid(row = 0, column = 1)
tb = Button(root, text = 'submit', command = what).grid(row = 3, column = 1)
root.mainloop()
Mehrdad
  • 11
  • 2

1 Answers1

0

You need to use a stringvar instead of using .get() on a entry-box

data = StringVar() #We use StringVar so that we can store the input entered by the user in the entry box
te = Entry(root,textvariable = data)
te.grid(row = 0, column = 1) #You should always grid,pack,place the object in a new line

Now in the function :

def what():
    entryg = data.get()
    #[...]other code

You can read more about StringVar here

CopyrightC
  • 857
  • 2
  • 7
  • 15