Access position of grid layout in tkinter
Is there a quick way to access the location I placed certain widget.
For example, if I have a button
self.exampleButton = tk.Button(self)
self.exampleButton.grid(row=3,column=0,sticky="EW")
Is there a way that I can get the row or column? Something like self.exampleButton.getPosition
?
Is creating a dictionary to store the information, like {self.exampleButton:(3,0)}
, the best way?
Tkinter has a handy grid_info()
function:
info = exampleButton.grid_info()
print((info["row"], info["column"]))