Python Forum
Graph is not appearing in correct frame?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Graph is not appearing in correct frame?
#1
I am unsure if this is a Python, (custom)tkinter or matplotlib question; though the common ground is Python.

I am creating an app to display a range of graphs based upon some data.

I am using customtkinter as my GUI development system.

I have my main window with two frames; graph_select_frame and graph_frame; the former for a set of radio buttons and the latter to display the selected graph.

Currently, I have the radio buttons working and the graph_frame appears. All I am trying to get is the graph_frame to display a single graph (independent of any selection made).

I have attached my three files relating to the system so far; based upon what I can glean from the online documentation.

The problem is that the graph is appearing in (over the top of) the selection frame and not inside the graph_frame.

How do I make the matplotlib frame a child of the graph_frame and not, as it appears, a child of the main window?

Attached Files

Thumbnail(s)
   

.py   GraphCreate.py (Size: 5.85 KB / Downloads: 137)
.py   GraphSelect.py (Size: 2.68 KB / Downloads: 94)
.py   main.py (Size: 973 bytes / Downloads: 104)
Reply
#2
Likely has to do with this:
class MplCanvas(FigureCanvasTkAgg):
    
    def __init__(self, parent=None, width=5, height=4, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)
        self.axs = fig.add_subplot(111
        super(MplCanvas, self).__init__(fig)
You are not passing parent to the super(MplCanvas, self).__init__(fig). Do this
class MplCanvas(FigureCanvasTkAgg):
    
    def __init__(self, parent=None, width=5, height=4, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)
        self.axs = fig.add_subplot(111)
        super().__init__(fig, parent)
garynewport likes this post
Reply
#3
Thank you, would never have spotted this and it works perfectly now! Smile

Now, on to the next problem... LOL
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Grid Line not appearing at 0 JoeDainton123 1 1,677 Oct-05-2020, 06:41 PM
Last Post: Larz60+
  Window Not Appearing MGallo 14 8,089 Sep-30-2017, 07:52 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020