Tkinter NavigationToolbar2TkAgg - TypeError “Label object is not callable”
I am making a gui using tkinter
that takes in data points "dollars" and plots them onto a matplotlib chart. I understand to embed a matplotlib
plot onto tkinter
requires using FigureCanvasTkAgg
and NavigationToolbar2TkAgg
. This method works when I didn't use inheritance between parent class and child class.
When I tried to implement multiple pages into my program, like the link below:
Using buttons in Tkinter to navigate to different pages of the application?
My function is under the Page1
class, which is a subclass of the Page
class. I started getting an unresponsive toolbar whenever I pressed buttons. With the TypeError "Label object is not callable
.
I know the error is coming from declaring the NavigationToolbar2TkAgg
object. Please help, I suspect I might have an inheritance issue since I created a separate frame for toolbar and Figure
canvas.
def plot_data(self,dollars):
"""
This function takes in a list for dollars calculates
the years and converts the lists into numpy arrays and plots
them onto a matplotlib figure embedded into tkinter.
"""
#create a figure object to hold the matplotlib plots
self.figure = Figure(figsize=(5,4), dpi = 100)
#create a subplot first row first column
self.a = self.figure.add_subplot(111)
#update the list of dollars for the plot
self.dollars = np.array(dollars)
self.years = np.arange(0,len(dollars),1)
#plots the numpy arrays into a matplotlib figure 'pyplot'
self.a.plot(self.years,self.dollars,linestyle='none',marker='o')
#holds matplotlib figure in a container to be displayed in tkinter window 'window'
self.canvas = FigureCanvasTkAgg(self.figure, master=self)
#show matplotlib figure on tkinter window
self.canvas.show()
#displays the matplotlib figure on the grid
self.canvas.get_tk_widget().grid(row=10,column=1,columnspan=2,rowspan=20)
#create the toolbar synced with canvas
self.toolbarFrame = tk.Frame(self)
self.toolbarFrame.grid(row=31,column=1)
#creates a navigation toolbar linked to the matplotlib figure with
#the master being the toolbar tk.Frame
self.toolbar = NavigationToolbar2TkAgg(self.canvas,self.toolbarFrame)
#update the plot
self.toolbar.update()
python matplotlib tkinter
add a comment |
I am making a gui using tkinter
that takes in data points "dollars" and plots them onto a matplotlib chart. I understand to embed a matplotlib
plot onto tkinter
requires using FigureCanvasTkAgg
and NavigationToolbar2TkAgg
. This method works when I didn't use inheritance between parent class and child class.
When I tried to implement multiple pages into my program, like the link below:
Using buttons in Tkinter to navigate to different pages of the application?
My function is under the Page1
class, which is a subclass of the Page
class. I started getting an unresponsive toolbar whenever I pressed buttons. With the TypeError "Label object is not callable
.
I know the error is coming from declaring the NavigationToolbar2TkAgg
object. Please help, I suspect I might have an inheritance issue since I created a separate frame for toolbar and Figure
canvas.
def plot_data(self,dollars):
"""
This function takes in a list for dollars calculates
the years and converts the lists into numpy arrays and plots
them onto a matplotlib figure embedded into tkinter.
"""
#create a figure object to hold the matplotlib plots
self.figure = Figure(figsize=(5,4), dpi = 100)
#create a subplot first row first column
self.a = self.figure.add_subplot(111)
#update the list of dollars for the plot
self.dollars = np.array(dollars)
self.years = np.arange(0,len(dollars),1)
#plots the numpy arrays into a matplotlib figure 'pyplot'
self.a.plot(self.years,self.dollars,linestyle='none',marker='o')
#holds matplotlib figure in a container to be displayed in tkinter window 'window'
self.canvas = FigureCanvasTkAgg(self.figure, master=self)
#show matplotlib figure on tkinter window
self.canvas.show()
#displays the matplotlib figure on the grid
self.canvas.get_tk_widget().grid(row=10,column=1,columnspan=2,rowspan=20)
#create the toolbar synced with canvas
self.toolbarFrame = tk.Frame(self)
self.toolbarFrame.grid(row=31,column=1)
#creates a navigation toolbar linked to the matplotlib figure with
#the master being the toolbar tk.Frame
self.toolbar = NavigationToolbar2TkAgg(self.canvas,self.toolbarFrame)
#update the plot
self.toolbar.update()
python matplotlib tkinter
add a comment |
I am making a gui using tkinter
that takes in data points "dollars" and plots them onto a matplotlib chart. I understand to embed a matplotlib
plot onto tkinter
requires using FigureCanvasTkAgg
and NavigationToolbar2TkAgg
. This method works when I didn't use inheritance between parent class and child class.
When I tried to implement multiple pages into my program, like the link below:
Using buttons in Tkinter to navigate to different pages of the application?
My function is under the Page1
class, which is a subclass of the Page
class. I started getting an unresponsive toolbar whenever I pressed buttons. With the TypeError "Label object is not callable
.
I know the error is coming from declaring the NavigationToolbar2TkAgg
object. Please help, I suspect I might have an inheritance issue since I created a separate frame for toolbar and Figure
canvas.
def plot_data(self,dollars):
"""
This function takes in a list for dollars calculates
the years and converts the lists into numpy arrays and plots
them onto a matplotlib figure embedded into tkinter.
"""
#create a figure object to hold the matplotlib plots
self.figure = Figure(figsize=(5,4), dpi = 100)
#create a subplot first row first column
self.a = self.figure.add_subplot(111)
#update the list of dollars for the plot
self.dollars = np.array(dollars)
self.years = np.arange(0,len(dollars),1)
#plots the numpy arrays into a matplotlib figure 'pyplot'
self.a.plot(self.years,self.dollars,linestyle='none',marker='o')
#holds matplotlib figure in a container to be displayed in tkinter window 'window'
self.canvas = FigureCanvasTkAgg(self.figure, master=self)
#show matplotlib figure on tkinter window
self.canvas.show()
#displays the matplotlib figure on the grid
self.canvas.get_tk_widget().grid(row=10,column=1,columnspan=2,rowspan=20)
#create the toolbar synced with canvas
self.toolbarFrame = tk.Frame(self)
self.toolbarFrame.grid(row=31,column=1)
#creates a navigation toolbar linked to the matplotlib figure with
#the master being the toolbar tk.Frame
self.toolbar = NavigationToolbar2TkAgg(self.canvas,self.toolbarFrame)
#update the plot
self.toolbar.update()
python matplotlib tkinter
I am making a gui using tkinter
that takes in data points "dollars" and plots them onto a matplotlib chart. I understand to embed a matplotlib
plot onto tkinter
requires using FigureCanvasTkAgg
and NavigationToolbar2TkAgg
. This method works when I didn't use inheritance between parent class and child class.
When I tried to implement multiple pages into my program, like the link below:
Using buttons in Tkinter to navigate to different pages of the application?
My function is under the Page1
class, which is a subclass of the Page
class. I started getting an unresponsive toolbar whenever I pressed buttons. With the TypeError "Label object is not callable
.
I know the error is coming from declaring the NavigationToolbar2TkAgg
object. Please help, I suspect I might have an inheritance issue since I created a separate frame for toolbar and Figure
canvas.
def plot_data(self,dollars):
"""
This function takes in a list for dollars calculates
the years and converts the lists into numpy arrays and plots
them onto a matplotlib figure embedded into tkinter.
"""
#create a figure object to hold the matplotlib plots
self.figure = Figure(figsize=(5,4), dpi = 100)
#create a subplot first row first column
self.a = self.figure.add_subplot(111)
#update the list of dollars for the plot
self.dollars = np.array(dollars)
self.years = np.arange(0,len(dollars),1)
#plots the numpy arrays into a matplotlib figure 'pyplot'
self.a.plot(self.years,self.dollars,linestyle='none',marker='o')
#holds matplotlib figure in a container to be displayed in tkinter window 'window'
self.canvas = FigureCanvasTkAgg(self.figure, master=self)
#show matplotlib figure on tkinter window
self.canvas.show()
#displays the matplotlib figure on the grid
self.canvas.get_tk_widget().grid(row=10,column=1,columnspan=2,rowspan=20)
#create the toolbar synced with canvas
self.toolbarFrame = tk.Frame(self)
self.toolbarFrame.grid(row=31,column=1)
#creates a navigation toolbar linked to the matplotlib figure with
#the master being the toolbar tk.Frame
self.toolbar = NavigationToolbar2TkAgg(self.canvas,self.toolbarFrame)
#update the plot
self.toolbar.update()
python matplotlib tkinter
python matplotlib tkinter
edited Nov 12 '18 at 2:43
martineau
66k989178
66k989178
asked Nov 12 '18 at 0:35
Alanlyyy
91
91
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I have fixed my issue. The code above does not contain any issues. I actually declared one of my instance variables in my class incorrectly.
Here is the error I made:
TypeError: Label object is not callable
Ex) tk.Label = tk.Label(.....)
Feel free to use the function above to embed a figure and navigation bar to your tkinter GUI as it works.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254656%2ftkinter-navigationtoolbar2tkagg-typeerror-label-object-is-not-callable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have fixed my issue. The code above does not contain any issues. I actually declared one of my instance variables in my class incorrectly.
Here is the error I made:
TypeError: Label object is not callable
Ex) tk.Label = tk.Label(.....)
Feel free to use the function above to embed a figure and navigation bar to your tkinter GUI as it works.
add a comment |
I have fixed my issue. The code above does not contain any issues. I actually declared one of my instance variables in my class incorrectly.
Here is the error I made:
TypeError: Label object is not callable
Ex) tk.Label = tk.Label(.....)
Feel free to use the function above to embed a figure and navigation bar to your tkinter GUI as it works.
add a comment |
I have fixed my issue. The code above does not contain any issues. I actually declared one of my instance variables in my class incorrectly.
Here is the error I made:
TypeError: Label object is not callable
Ex) tk.Label = tk.Label(.....)
Feel free to use the function above to embed a figure and navigation bar to your tkinter GUI as it works.
I have fixed my issue. The code above does not contain any issues. I actually declared one of my instance variables in my class incorrectly.
Here is the error I made:
TypeError: Label object is not callable
Ex) tk.Label = tk.Label(.....)
Feel free to use the function above to embed a figure and navigation bar to your tkinter GUI as it works.
answered Nov 12 '18 at 3:22
Alanlyyy
91
91
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254656%2ftkinter-navigationtoolbar2tkagg-typeerror-label-object-is-not-callable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown