If I have several rows and columns with several entry/label widgets in the SAME frame, is it possible to choose just a single one of them and delete it whilst leaving the others alone.
e.g.
class Window():
def __init__(self):
self.root = Tk()
self.win1 = Frame(self.root)
entry1 = Entry(win1, row=1, column=1)
entry2 = Entry(win1, row=1, column=2)
label1 = Label(win1, row=1, column=3)
def main1(self):
label2 = Label(win1, row=1, column=4)
labeln = Label(win1, row=1, column=n)
I would then like to remove from column 3 onwards, where n could be a random number. Is it possible to get grid_forget and insert the number of columns? Is it also possible for the rows as well?
UPDATE: OR is it possible to simply return back to the window created under init and delete those created under main1 (but have been created in the same frame)?
Thank you.
Read up on the grid_remove and grid_forget methods; these will alow you to remove existing widgets from view. You can also destroy widgets, causing them to vanish.
It’s been a while since I’ve done this (and don’t currently have a computer on which to create an example), but I think the one sticky point may be that you will have to go in and explicitly set the grid row and/or column heights, widths or weights back to zero to reclaim the space. It’s quite doable though.
Your other choice is to create all of your widgets via a method or function. You can then pretty easily destroy and recreate all the widgets. This is probably less pleasant for the user since the whole UI will “blink”.