求助:关于python tkinter模块 pack() 函数问题。请各位大神赐教!
如下图,我想将图表放置在按钮的左侧。为啥总是在下方,请赐教。
代码:
# 功能按钮
# ---------------------------------------------------------------------
ft2 = tkFont.Font(family="微软雅黑", size=16, weight=tkFont.BOLD)
tk.Button(canvas, text="退出", bg="cadetblue", command=self._quit,
font=ft2, height=2, fg="red", width=10)\
.pack(side="top", anchor="ne", pady=10, padx=15)
tk.Button(canvas, text="导入", bg="cadetblue", command=self.import_data,
font=ft2, height=2, fg="green", width=10)\
.pack(side="top", anchor="ne", pady=10, padx=15)
tk.Button(canvas, text="显示2D_FFT", bg="cadetblue", command=self.show_2DFFT,
font=ft2, height=2, fg="green", width=10)\
.pack(side="top", anchor="ne", pady=10, padx=15)
tk.Button(canvas, text="力波解析", bg="cadetblue", command=self.wave_table,
font=ft2, height=2, fg="green", width=10)\
.pack(side="bottom", anchor="se", pady=10, padx=15)
tk.Button(canvas, text="阶次切片", bg="cadetblue", command=self.order_table,
font=ft2, height=2, fg="green", width=10)\
.pack(side="bottom", anchor="se", pady=10, padx=15)
tk.Button(canvas, text="原始数据", bg="cadetblue", command=self.raw_data,
font=ft2, height=2, fg="green", width=10)\
.pack(side="bottom", anchor="se", pady=10, padx=15)
放置图表:
"""清除原有图表,生成新的图表"""
fig = Figure(figsize=(3, 2), dpi=100) #创建画布
canvas = FigureCanvasTkAgg(fig, master=self.root) # A tk.DrawingArea.
canvas.get_tk_widget().pack(side='left', fill='y', expand='yes')
toolbar = NavigationToolbar2Tk(canvas, self.root) #创建工具栏
toolbar.update()
canvas.get_tk_widget().pack(side='left', fill='y', expand='yes')