简体   繁体   English

忘记与grid_forget(Python)

[英]forget versus grid_forget (python)

I'm using tkinter for GUI stuff. 我正在将tkinter用于GUI。 I noticed that I can use the 'grid' method to align widgets to the appropriate row and column, which references the grid_configure method. 我注意到我可以使用'grid'方法将小部件对齐到适当的行和列,该行和列引用了grid_configure方法。 However, the forget method, which references grid_forget, does not work in the same way. 但是,引用grid_forget的forget方法不能以相同的方式工作。 For example, I think that I should be able to do the following 例如,我认为我应该能够执行以下操作

def updateEquationInput(self):     
        self.labelXEQUALS.forget

but my label called self.labelXEQUALS isn't removed unless I use grid_forget instead. 但是除非我使用grid_forget,否则不会删除名为self.labelXEQUALS的标签。 Why is that? 这是为什么?

The code is missing () . 代码丢失()

self.labelXEQUALS.forget()
                        ^^

As you may know, without () , the function/method is not called. 如您所知,如果没有() ,则不会调用函数/方法。

BTW, forget is a shortcut for pack_forget , not grid_forget . 顺便说一句, forgetpack_forget的快捷方式,而不是grid_forget

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM