Why my scrollbar and canvas doesn't synchronise?

谁说胖子不能爱 提交于 2019-12-11 17:33:38

问题


I have created a scrollable canvas. In which a frame window is there and there are many canvases in it which shows data in form of various labels? Actually I have created everything like frame configuration to update canvas scollregion but I sometimes randomly gets a bug that is when I destroy a canvas in a frame then sometimes the size of scrollbar adjust automatically but sometimes it doesn't change and scollbar shows a region with no data a large blank space at the bottom is generated sometimes and also when I cleared the frame window completely by destroying all of its children widgets then even I checked on console by print statements that everything is cleared but still the results on gui tkinter windows are still there till I switch the page and it is also occuring randomly why? Sometimes everything goes as planned but sometimes not can you figure why?


回答1:


There may be many problems, but it seems that the most significant is that you are creating two canvases but only saving a reference to the last one that was created.

At startup self.canvas will point to the first canvas. When you click on "Detail Box2", self.canvas is reset to be a new canvas. You no longer have a reference to the first canvas. From that point on, any time you do anything with self.canvas, it's only doing it to the second canvas.

Until you fix that, I don't think it's possible for anything else to work correctly.



来源:https://stackoverflow.com/questions/57028973/why-my-scrollbar-and-canvas-doesnt-synchronise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!