如下图,我想将图表放置在按钮的左侧。为啥总是在下方,请赐教。

求助:关于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')
 

 

 

相关文章:

  • 2021-05-30
  • 2021-08-16
  • 2021-12-14
  • 2021-05-14
  • 2022-03-08
  • 2021-09-11
  • 2021-09-04
  • 2022-12-23
猜你喜欢
  • 2021-10-26
  • 2021-04-11
  • 2021-07-08
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2021-05-31
相关资源
相似解决方案