遇到奇怪的问题:canvas.bbox('ALL')给None。
所以主题说只有在代码中canvas有一些方法时才会给出坐标。.create_xxx()问题是该类FigureCanvasTkAgg在其__init__方法中使用create_image方法,我认为在我的小片段中,当我创建 thic 类的实例时,它应该在调用instance.bbox命令时给我一些坐标框。但它不是...
self.Frame = Frame(root, bg = 'white')
self.Frame.place (relx = 0.37 , rely = 0.05 , relheight = 0.85 , relwidth = 0.51)
self.canvas = FigureCanvasTkAgg ( fig , master = self.Frame) # A tk.DrawingArea.
self.canvas.get_tk_widget ().place ( relx = 0 , rely = 0)
self.canvas.get_tk_widget ().config ( yscrollcommand = self.vbar.set ,
scrollregion = (0,0,w,639*h/10 ))
self.canvas.get_tk_widget ().update_idletasks ()
print(self.canvas.get_tk_widget ().winfo_width(),self.canvas.get_tk_widget ().winfo_height() )
self.Frame.update_idletasks ()
print(self.canvas.get_tk_widget ().bbox('ALL'))
self.toolbar = NavigationToolbar2Tk ( self.canvas , self.Frame )
self.vbar.pack ( side = RIGHT , fill = Y)
临摹微笑
相关分类