Home > other >  Tkinter matplot resolution problem
Tkinter matplot resolution problem

Time:03-08

Try drawing in tkinter, I set up a root window, about two frame, put the widget on the right, the left side to do the plot, when choose to perform a FIG, axes=PLT, subplots (1, 4) statements, clearly see the root window be forced to shrink, the component and the message on the smaller, seems to be the resolution increased, but call
Winfo_screenheight (), and
Winfo_screenwidth () are always a numerical display, excuse me each tall person, what reason is this? How to keep the resolution may not call for subplots and change? The following is the code:

The import tkinter as tk
The import matplotlib. Pyplot as PLT
The from matplotlib. Backends. Backend_tkagg import FigureCanvasTkAgg


Def set_paras () :
Root. Wm_title (" shares ")
Root. Geometry (" 1200 x750 + 10 + 10 ")
PLT. RcParams [' font. Sans-serif]=[' SimHei]
PLT. RcParams [' axes. Unicode_minus]=False
PLT. RcParams [' savefig. Dpi]=100
PLT. RcParams [' figure. Dpi]=100
PLT. RcParams [' figure. Figsize]=(6.4, 4.8)
Root. The update ()
Return

Root=tk. Tk ()
Maxx, maxy right_f butx, buty1=1200, 750, 250, 10, 20,
Buty2 reph, repw repy=70, 13, 32, 180
Set_paras ()

Framel=tk. Frame (root, width=maxx - right_f, height=maxy)
Framel. Place (x=0, y=0, the anchor="nw")
Framer=tk. Frame (root, width=right_f, height=maxy, bg="lightcyan")
Framer. Place (x=maxx - right_f, y=0, the anchor="nw")
Framel. The grid (row=0, the column=1, sticky="ns")

But1=tk. The Button (master=framer, text="Quit", the command=root. Quit). The place (x=butx + 150, y=buty1, anchor="nw")
Report1=tk. Text (master=framer, width=repw, height=reph, bg="# EFEFEF")
Report1. Place (x=butx, y=maxy - repy, anchor="nw")
Report1. Insert (tk) insert, "something... \ n ")

FIG.=PLT Figure ()
Canvas1=FigureCanvasTkAgg (FIG, framel)
Canvas1. Get_tk_widget (). Pack (side="top", the fill="both")

# # # this way, execution and does not perform better than that seems to increase the resolution of tkinter window, window and small content inside a # # # # # # # # # # # # # # # # # # #
FIG. (ax1, ax2)=PLT. Subplots (nrows=ncols=1, 2)

root.mainloop()

CodePudding user response:

Just try again, the FIG, (ax1, ax2)=PLT. Subplots (nrows=ncols=1, 2) changed to ax=FIG. Add_subplot (411), etc., won't affect the tkinter like subplots window size and resolution,
  • Related