Reputation: 1
I have created a tkinter app which plots pyplot subplots on the screen (using matplotlib). When testing this on a Windows 10 laptop, I am finding that as soon as the plot is created, the tkinter root window shrinks dramatically.
I have boiled down the issue to the following code:
import tkinter as tk
import matplotlib.pyplot as plt
def plot():
fig, axs = plt.subplots(3, 6, sharey=True)
print('Button pushed')
return
root = tk.Tk()
b1 = tk.Button(root, text='Plot', command=(lambda: plot()))
b1.pack(side=tk.LEFT, padx=5, pady=5)
root.mainloop()
On my Windows 10 laptop, as soon as the "Plot" button is pushed, the tkinter root window dramatically shrinks. Interestingly, I do not see this same behavior on my Linux Mint laptop.
The desired behavior is for a plot to be shown on the screen (later, when plt.show()
is to be called), not embedded in the tkinter window, and not affecting the tkinter window at all.
Upvotes: 0
Views: 370
Reputation: 1
I had the exact same problem. I don't really have a clear answer, but I experienced this issue only when using python 3.7 not when using python 3.6. So my only suggestion is to change your python version as long as you don't specifically need python 3.7
Also you can take a look at this post: Tkinter window changes dimensions or resolution when I use pyplot
It's a similar issue and it can be fixed by adjusting the window layout settings on windows. It might not be exactly what you're looking for but give it a try.
Upvotes: 0