我想将matplotlib放入主tkinter窗口中,但在遵循大量教程之后,我仍然努力将matplotlib放在主窗口中。在tkinter窗口中合并matplotlib
我需要它的原因是因为我试图为学校项目制作图形软件。
任何帮助将非常感激,这是我到目前为止的代码..
from tkinter import * #importing all files from Tkinter so all libraries are avaiable
root = Tk() #root is a variable which equals a tkinter class - creates blank window
root.geometry('1600x900') # Size 1600, 900 for the window
#-----------------------------------------------------------------------
---------------
button1xy = Button(text="xy")
buttony = Button(text="y=")
buttonclrscrn = Button(text="clear screen")
buttonbestfit = Button(text="line of best fit")#labels for the buttons
button1xy.grid(row=0)
buttony.grid(row=0, column=1)
buttonclrscrn.grid(row=0, column=2)
buttonbestfit.grid(row=0, column=3) #displaying them on the screen,
grid method
menu = Menu(root)
root.config(menu=menu)
def dropdownmenu():
submenu = Menu(menu)
menu.add_cascade(label=">", menu=submenu)
submenu.add_command(label="Linear")
submenu.add_command(label="Polynomial")
submenu.add_command(label="Trigonometrical")
submenu.add_command(label="Percentage Error") #drop down menu
which appears in toolbar when button is clicked on
buttonmenu = Button(text=">", command=dropdownmenu) #label and
command for the drop down menu button
buttonmenu.grid(row=0, column=8) #grid method for it to display
#-------------------------------------------------------------------
root.mainloop() #continuously keeps window on the screen until closed
#generates window
欢迎堆栈溢出时是非常有用的!您目前遇到的错误是什么?你到目前为止尝试过什么?这些额外的信息将帮助其他用户帮助您。 – meenaparam
也许我不明白你的问题,你想将matplotlib导入你正在导入tkinter的同一个文件? –
@BrenoBaiardi是的,我正在尝试制作一个图形模拟器供学生使用,因此我试图将matplotlib模块放入tkinter窗口 –