Thus, when you do frame_x = Frame(.).grid(.), frame_x has the value of. In python, when you do x=y().z(), x has the value of z(). The reason you aren't putting the widgets into the frame is because of this line: frame_x = Frame(root).grid(row = 1, column = i) Because of that, they are not destroyed when you destroy the frame. It doesn't matter if it's overlapped or not.īased on the tiny bit of code you posted, the main problem is that you aren't putting the entry and button in the frame. If you destroy a widget, it is destroyed. tkinter doesn't "work on an overlapping basis". I'm not entirely sure what you mean by that, but if it means what I think it means, it is a false statement. I guess tkinter works on overlapping basis and doesn't change a grid element until something is specifically overlapped over it. I know I should start working with classes at some point.įirst off, I want to address this part of the question: So it would be great if you can share me a framework without using classes. I prefer the inefficient way by only using functions to do everything I have to. I am not very comfortable with classes in general. Please refer the image above and let me know if it doesn't make sense. I tried destroying the entire frame just after entering the for loop, but that doesn't work as for the first time no widget is created before destroying and python throws NameError saying I can't use a variable before assignment.Īnyways, please let me know how do I do this efficiently.Īnd also in general, if there is a better way to go about the whole thing. But I guess tkinter works on overlapping basis and doesn't change a grid element until something is specifically overlapped over it. Later if he changes the value to j = 2 and the presses the button, ideally it should make the widgets at block j= 3 and 4 disappear. Let's say if the user enters j = 4 first. But the problem is that I want it to work dynamically. (Let me know if you want a more detailed code block.) Please note this is not a functional code, I have tried to keep it to the point just to give an idea of the method I am using. I am creating individual layer widgets using for loop: for n in range(i):įrame_x = Frame(root).grid(row = 1, column = i)Įntry_x = Entry(frame_x).grid(row = 2, column = i)īutton_x = Button(frame_x).grid(row=3, column = i) Let's say the variables used for this pointer system are i, j, and k. So if you can see the image above, I am trying to create a GUI for a particular project which requires multi-layer (I am calling it 3D array based) widgets. I tried finding solutions to this but as much as I find it obvious, the solution to this doesn't seem to be easy to understand. So I am relatively new to using tkinter and I am struggling with a very specific doubt here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |