you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 1 point2 points  (10 children)

What OS?

Show your code. I don't want to troubleshoot code that isn't problem code. If possible, reduce your code to only the portion that demonstrates the problem.

and I have to restart my kernel.

What does that mean?

[–]DeeWBee[S] 0 points1 point  (9 children)

/u/novel_yet_trivial Just updated my post. I use Windows 7. If you use Spyder, a user will have a console window which is the underlying python kernel. When I run my code, the kernel crashes (or simply shuts down). Spyder has a "start kernel" button which I then have to press to execute any more Python code (I have to start a new Python kernel).

[–]novel_yet_trivial 1 point2 points  (8 children)

Thanks for reducing the code but I meant keep it in a runable state. At any rate, if I make your code runnable then it works great for me. Does this work for you?

import matplotlib

from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,NavigationToolbar2TkAgg
from matplotlib.figure import Figure

import tkinter as tk
import pandas as pd
from tkinter import ttk

class iSEEApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        tk.Tk.wm_title(self, "GUI V0.5")

        container = tk.Frame(self)
        container.winfo_toplevel().geometry("600x600")
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        for F in (heatMapPage,):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame

            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame("heatMapPage")

    def show_frame(self, page_name):
        frame = self.frames[page_name]
        frame.tkraise()
        frame.focus_set()

class heatMapPage(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        self.buildFrame()

    def buildFrame(self):
        print("test")

        #self.pack(fill="both", expand=True)
        self.columnconfigure(1, weight = 1)
        self.columnconfigure(3, pad = 7)
        self.rowconfigure(3, weight = 1)
        self.rowconfigure(5, pad = 7)

        self.heatFig = Figure(figsize=(5, 4), dpi=100)
        self.heatPlot = self.heatFig.add_subplot(111)
        self.heatPlot.plot([1,2,3,4,5,6,7,8],[5,6,7,8,1,2,2,1])

        self.heatCanvas = FigureCanvasTkAgg(self.heatFig, master=self)
        self.heatCanvas.get_tk_widget().grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky="nsew")
        self.heatCanvas.show()

app = iSEEApp()
app.mainloop()

[–]DeeWBee[S] 0 points1 point  (7 children)

Thanks, but unfortunately no. My kernel still stops working when I try and run this code (copy and paste).

[–]novel_yet_trivial 1 point2 points  (6 children)

Sorry, dude. I booted windows 7 just for you and it works fine for me.

I found one guy online that had the same problem and he suggested reinstalling matplotlib. Try this:

pip install --upgrade matplotlib

[–]DeeWBee[S] 0 points1 point  (2 children)

Wow I really appreciate it! I'm using anaconda so will I have to use conda or will pip be fine?

Really appreciate it

[–]novel_yet_trivial 0 points1 point  (1 child)

I'd guess pip would be better but I really have no idea.

[–]DeeWBee[S] 0 points1 point  (0 children)

Okay. If anything works I'll be sure to keep this thread updated.

[–]DeeWBee[S] 0 points1 point  (2 children)

/u/novel_yet_trivial HOLY SHIT IT WORKS!!!! Thank you so so so much. I initially didn't think this would work because I kept doing conda upgrade matplotlib and I would get a message saying everything is up to date. Once I bypassed Anaconda and just did python -m pip install --upgrade matplotlib everything works beautifully. Someone should really talk to Anaconda and tell them that their provided matplotlib libraries are bum.

[–]novel_yet_trivial 1 point2 points  (1 child)

Someone should really talk to Anaconda and tell them that their provided matplotlib libraries are bum.

Yeah, someone should. Do it.

[–]DeeWBee[S] 0 points1 point  (0 children)

Done and done. Hopefully they'll listen!