Howto read value of entry in tkinter [duplicate]












-1
















This question already has an answer here:




  • Tkinter: AttributeError: NoneType object has no attribute get

    2 answers




Can anyone please tell me, why I get the error 'NoneType' object has no attribute 'get'?



import tkinter as tk
from tkinter import messagebox

class App(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.lab1 = tk.Label(text="Abfahrtsort").grid(row=0, column=0, sticky="w")
self.start = tk.Entry(self).grid(row=0, column=1)
self.lab2 = tk.Label(text="Zielort").grid(row=1, column=0, sticky="w")
self.end = tk.Entry(self).grid(row=1, column=1)
self.button = tk.Button(self, text="Anzeigen", command=self.on_button).grid(row=2, column=1)

def on_button(self):
messagebox.showinfo(self.entry.get())

app = App()
app.mainloop()









share|improve this question















marked as duplicate by Bryan Oakley python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 15:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Change self.entry.get() to self.end.get(). You are trying to use get() on a non-existent self.entry. Seeing that you have defined your entry field as self.end you need to change your messagebox statement to reflect the same. On top of that you need to use grid() on a new line separate from where you define your entry field.

    – Mike - SMT
    Dec 31 '18 at 15:06













  • If you had searched this site with that exact error message you would have found an answer.

    – Bryan Oakley
    Dec 31 '18 at 15:33
















-1
















This question already has an answer here:




  • Tkinter: AttributeError: NoneType object has no attribute get

    2 answers




Can anyone please tell me, why I get the error 'NoneType' object has no attribute 'get'?



import tkinter as tk
from tkinter import messagebox

class App(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.lab1 = tk.Label(text="Abfahrtsort").grid(row=0, column=0, sticky="w")
self.start = tk.Entry(self).grid(row=0, column=1)
self.lab2 = tk.Label(text="Zielort").grid(row=1, column=0, sticky="w")
self.end = tk.Entry(self).grid(row=1, column=1)
self.button = tk.Button(self, text="Anzeigen", command=self.on_button).grid(row=2, column=1)

def on_button(self):
messagebox.showinfo(self.entry.get())

app = App()
app.mainloop()









share|improve this question















marked as duplicate by Bryan Oakley python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 15:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Change self.entry.get() to self.end.get(). You are trying to use get() on a non-existent self.entry. Seeing that you have defined your entry field as self.end you need to change your messagebox statement to reflect the same. On top of that you need to use grid() on a new line separate from where you define your entry field.

    – Mike - SMT
    Dec 31 '18 at 15:06













  • If you had searched this site with that exact error message you would have found an answer.

    – Bryan Oakley
    Dec 31 '18 at 15:33














-1












-1








-1









This question already has an answer here:




  • Tkinter: AttributeError: NoneType object has no attribute get

    2 answers




Can anyone please tell me, why I get the error 'NoneType' object has no attribute 'get'?



import tkinter as tk
from tkinter import messagebox

class App(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.lab1 = tk.Label(text="Abfahrtsort").grid(row=0, column=0, sticky="w")
self.start = tk.Entry(self).grid(row=0, column=1)
self.lab2 = tk.Label(text="Zielort").grid(row=1, column=0, sticky="w")
self.end = tk.Entry(self).grid(row=1, column=1)
self.button = tk.Button(self, text="Anzeigen", command=self.on_button).grid(row=2, column=1)

def on_button(self):
messagebox.showinfo(self.entry.get())

app = App()
app.mainloop()









share|improve this question

















This question already has an answer here:




  • Tkinter: AttributeError: NoneType object has no attribute get

    2 answers




Can anyone please tell me, why I get the error 'NoneType' object has no attribute 'get'?



import tkinter as tk
from tkinter import messagebox

class App(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.lab1 = tk.Label(text="Abfahrtsort").grid(row=0, column=0, sticky="w")
self.start = tk.Entry(self).grid(row=0, column=1)
self.lab2 = tk.Label(text="Zielort").grid(row=1, column=0, sticky="w")
self.end = tk.Entry(self).grid(row=1, column=1)
self.button = tk.Button(self, text="Anzeigen", command=self.on_button).grid(row=2, column=1)

def on_button(self):
messagebox.showinfo(self.entry.get())

app = App()
app.mainloop()




This question already has an answer here:




  • Tkinter: AttributeError: NoneType object has no attribute get

    2 answers








python tkinter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 31 '18 at 15:31







D. Studer

















asked Dec 31 '18 at 15:05









D. StuderD. Studer

889




889




marked as duplicate by Bryan Oakley python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 15:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Bryan Oakley python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 15:33


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Change self.entry.get() to self.end.get(). You are trying to use get() on a non-existent self.entry. Seeing that you have defined your entry field as self.end you need to change your messagebox statement to reflect the same. On top of that you need to use grid() on a new line separate from where you define your entry field.

    – Mike - SMT
    Dec 31 '18 at 15:06













  • If you had searched this site with that exact error message you would have found an answer.

    – Bryan Oakley
    Dec 31 '18 at 15:33



















  • Change self.entry.get() to self.end.get(). You are trying to use get() on a non-existent self.entry. Seeing that you have defined your entry field as self.end you need to change your messagebox statement to reflect the same. On top of that you need to use grid() on a new line separate from where you define your entry field.

    – Mike - SMT
    Dec 31 '18 at 15:06













  • If you had searched this site with that exact error message you would have found an answer.

    – Bryan Oakley
    Dec 31 '18 at 15:33

















Change self.entry.get() to self.end.get(). You are trying to use get() on a non-existent self.entry. Seeing that you have defined your entry field as self.end you need to change your messagebox statement to reflect the same. On top of that you need to use grid() on a new line separate from where you define your entry field.

– Mike - SMT
Dec 31 '18 at 15:06







Change self.entry.get() to self.end.get(). You are trying to use get() on a non-existent self.entry. Seeing that you have defined your entry field as self.end you need to change your messagebox statement to reflect the same. On top of that you need to use grid() on a new line separate from where you define your entry field.

– Mike - SMT
Dec 31 '18 at 15:06















If you had searched this site with that exact error message you would have found an answer.

– Bryan Oakley
Dec 31 '18 at 15:33





If you had searched this site with that exact error message you would have found an answer.

– Bryan Oakley
Dec 31 '18 at 15:33












1 Answer
1






active

oldest

votes


















0














You have two issues here in your code. The 1st one is your grid() statement.



Change these:



self.start = tk.Entry(self).grid(row=0, column=1)
self.end = tk.Entry(self).grid(row=1, column=1)


To this:



self.start = tk.Entry(self)
self.start.grid(row=0, column=1)


and this:



self.end = tk.Entry(self)
self.end.grid(row=1, column=1)


The 2nd is your messagebox statement.



Change this:



messagebox.showinfo(self.entry.get())


To this:



messagebox.showinfo(self.start.get())


Or this depending on what entry you are trying to access:



messagebox.showinfo(self.end.get())


You will also need to correct the indention of your self.end and self.button to be inline with everything else in your __init__ method.






share|improve this answer
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You have two issues here in your code. The 1st one is your grid() statement.



    Change these:



    self.start = tk.Entry(self).grid(row=0, column=1)
    self.end = tk.Entry(self).grid(row=1, column=1)


    To this:



    self.start = tk.Entry(self)
    self.start.grid(row=0, column=1)


    and this:



    self.end = tk.Entry(self)
    self.end.grid(row=1, column=1)


    The 2nd is your messagebox statement.



    Change this:



    messagebox.showinfo(self.entry.get())


    To this:



    messagebox.showinfo(self.start.get())


    Or this depending on what entry you are trying to access:



    messagebox.showinfo(self.end.get())


    You will also need to correct the indention of your self.end and self.button to be inline with everything else in your __init__ method.






    share|improve this answer






























      0














      You have two issues here in your code. The 1st one is your grid() statement.



      Change these:



      self.start = tk.Entry(self).grid(row=0, column=1)
      self.end = tk.Entry(self).grid(row=1, column=1)


      To this:



      self.start = tk.Entry(self)
      self.start.grid(row=0, column=1)


      and this:



      self.end = tk.Entry(self)
      self.end.grid(row=1, column=1)


      The 2nd is your messagebox statement.



      Change this:



      messagebox.showinfo(self.entry.get())


      To this:



      messagebox.showinfo(self.start.get())


      Or this depending on what entry you are trying to access:



      messagebox.showinfo(self.end.get())


      You will also need to correct the indention of your self.end and self.button to be inline with everything else in your __init__ method.






      share|improve this answer




























        0












        0








        0







        You have two issues here in your code. The 1st one is your grid() statement.



        Change these:



        self.start = tk.Entry(self).grid(row=0, column=1)
        self.end = tk.Entry(self).grid(row=1, column=1)


        To this:



        self.start = tk.Entry(self)
        self.start.grid(row=0, column=1)


        and this:



        self.end = tk.Entry(self)
        self.end.grid(row=1, column=1)


        The 2nd is your messagebox statement.



        Change this:



        messagebox.showinfo(self.entry.get())


        To this:



        messagebox.showinfo(self.start.get())


        Or this depending on what entry you are trying to access:



        messagebox.showinfo(self.end.get())


        You will also need to correct the indention of your self.end and self.button to be inline with everything else in your __init__ method.






        share|improve this answer















        You have two issues here in your code. The 1st one is your grid() statement.



        Change these:



        self.start = tk.Entry(self).grid(row=0, column=1)
        self.end = tk.Entry(self).grid(row=1, column=1)


        To this:



        self.start = tk.Entry(self)
        self.start.grid(row=0, column=1)


        and this:



        self.end = tk.Entry(self)
        self.end.grid(row=1, column=1)


        The 2nd is your messagebox statement.



        Change this:



        messagebox.showinfo(self.entry.get())


        To this:



        messagebox.showinfo(self.start.get())


        Or this depending on what entry you are trying to access:



        messagebox.showinfo(self.end.get())


        You will also need to correct the indention of your self.end and self.button to be inline with everything else in your __init__ method.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 31 '18 at 15:15

























        answered Dec 31 '18 at 15:09









        Mike - SMTMike - SMT

        9,54421434




        9,54421434

















            Popular posts from this blog

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas

            Can't read property showImagePicker of undefined in react native iOS