Howto read value of entry in tkinter [duplicate]
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()
python tkinter
marked as duplicate by Bryan Oakley
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.
add a comment |
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()
python tkinter
marked as duplicate by Bryan Oakley
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.
Changeself.entry.get()
toself.end.get()
. You are trying to useget()
on a non-existentself.entry
. Seeing that you have defined your entry field asself.end
you need to change your messagebox statement to reflect the same. On top of that you need to usegrid()
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
add a comment |
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()
python tkinter
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
python tkinter
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
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
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.
Changeself.entry.get()
toself.end.get()
. You are trying to useget()
on a non-existentself.entry
. Seeing that you have defined your entry field asself.end
you need to change your messagebox statement to reflect the same. On top of that you need to usegrid()
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
add a comment |
Changeself.entry.get()
toself.end.get()
. You are trying to useget()
on a non-existentself.entry
. Seeing that you have defined your entry field asself.end
you need to change your messagebox statement to reflect the same. On top of that you need to usegrid()
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
edited Dec 31 '18 at 15:15
answered Dec 31 '18 at 15:09
Mike - SMTMike - SMT
9,54421434
9,54421434
add a comment |
add a comment |
Change
self.entry.get()
toself.end.get()
. You are trying to useget()
on a non-existentself.entry
. Seeing that you have defined your entry field asself.end
you need to change your messagebox statement to reflect the same. On top of that you need to usegrid()
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