I'm developing a program with a tkinter GUI that has an embedded matplotlib bar chart. The program itself is sturdy, but the GUI gives me some weird issues.
On the PC in my office (windows 10, 1920x1080 monitor), running the program in sublime text shows a perfectly normal GUI. I then built the program into a single executable using pyinstaller, and running this also gives me perfectly normal results.
However, if I use a separate PC in my office connected to the same network (also windows 10, 3840x2160 monitor), that's where I experience issues. Running it before pyinstaller, the window appears much smaller than my PC and the widgets are not scaled down.
Running it after pyinstaller scales the widgets... but to a teeny tiny window.
Below is my minimal reproducible example. Please let me know what I may be doing wrong. I've successfully built programs like this before, so I'm not sure why this one is giving such a fuss. Thanks in advance.
import tkinter as tk
import numpy as np
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
from matplotlib import animation as animation, pyplot as plt, cm
from tkinter import *
# window settings (size, color...)
root = tk.Tk()
root.geometry('678x600')
# settings for the plot size and layout
plt.rcParams["figure.dpi"] = 96 #figure_dpi
plt.rcParams["figure.figsize"] = [6.75, 4.0]
fig = plt.figure() # make a figure for our plot
# text box and label for user to enter desired pulse width
pulse_txt = tk.Text(root, height=1, width=6, font=("Arial", 14))
pulse_lbl = tk.Label(root, text="label label hi", bg="#EEEDEB")
# button to stop counting and export file with counts
end_count_btn = tk.Button(root, text="button", width=10)
# Link the matplotlib figure to our main window and specify its location
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.get_tk_widget().place(relx = 0.02, rely = 0.25) ######
pulse_lbl.place(relx = 0.438, rely = 0.03)
pulse_txt.place(relx = 0.451, rely = 0.07)
end_count_btn.place(relx = 0.445, rely = 0.15)
ax = fig.add_subplot(111)
# create the plot and specify some starting axis info and the title
bars = plt.bar(np.linspace(1,1000,1000), np.zeros(1000), facecolor='#990000', width=1)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_title("plot")
ax.set_xlim([0,500])
# create the nifty toolbar below the plot
toolbar = NavigationToolbar2Tk(canvas, root)
toolbar.update()
root.mainloop()
exit(0)