appJar
appJar copied to clipboard
Remove by position
Would it be possible to have a method to remove any widget by its position instead of title?
Does sound reasonable - appJar uses grid layout, so if it’s supported, we can do it...
According to this article: https://stackoverflow.com/questions/23189610/remove-widgets-from-grid-in-tkinter you can iterate over items in a grid:
for label in a.grid_slaves():
if int(label.grid_info()["row"]) > 6:
label.grid_forget()
As demonstrated in the code committed above, it's easy enough to iterate over all widgets in the grid, and get their position.
So, removing by position would just be a case of performing the above, and removing the relevant widget.
However, it would also need to be removed from the relevant dictionary in the widget store, and potentially other places...
There are many remove methods removeXXX(name)
.
These could all be replaced by a single remove that could accept positions, or name (perhaps change this to title to match the others?), and an optional kind parameter. If no kind (or position) is set try and remove ALL widgets of name
.
remove((0, 0), (0, 1))
remove('mylabels', 'my entries')
remove('mylabel', kind='label')
Maybe renaming removeAllWidgets
to removeAll
, or even just remove
. with no arguments?