Since you are using the grid geometry manager, you just need to use the grid method to place them in their new rows and columns. You may need to also call rowconfigure and/or columnconfigure to attach appropriate weights to the new rows and columns.
Since you are using the grid geometry manager, you just need to use the grid method to place them in their new rows and columns. You may need to also call rowconfigure and/or columnconfigure to attach appropriate weights to the new rows and columns. Here's a bit of a contrived example showing the general principle.It could be more efficient but hopefully it gives you a rough idea: import Tkinter as tk class App(tk.
Tk): def __init__(self, *args, **kwargs): tk.Tk. __init__(self, *args, **kwargs) self. Forms = self.
Toolbar = tk. Frame(self) self.toolbar. Pack(side="top", fill="x", expand=False) button2 = tk.
Button(self. Toolbar, text="2 columns", command=self. Layout2col) button3 = tk.
Button(self. Toolbar, text="3 columns", command=self. Layout3col) button2.
Pack(side="left") button3. Pack(side="left") self. Forms_frame = tk.
Frame(self, borderwidth=2, relief="groove") self. Forms_frame. Pack(side="top", fill="both", expand="True", padx=2, pady=2) for I in range(6): frame = tk.
LabelFrame(self. Forms_frame, text="Form %s" % i) self.forms. Append(frame) label = tk.
Label(frame, text="Field %s" % i) entry = tk. Entry(frame, width=20) label. Pack(side="left", fill="y") entry.
Pack(side="left", fill="both", expand=True) self. Layout2col() def layout3col(self): self. Forms0.
Grid(column=0, row=0, padx=4, pady=2, sticky="ew") self. Forms1. Grid(column=0, row=1, padx=4, pady=2, sticky="ew") self.
Forms2. Grid(column=1, row=0, padx=4, pady=2, sticky="ew") self. Forms3.
Grid(column=1, row=1, padx=4, pady=2, sticky="ew") self. Forms4. Grid(column=2, row=0, padx=4, pady=2, sticky="ew") self.
Forms5. Grid(column=2, row=1, padx=4, pady=2, sticky="ew") self. Forms_frame.
Grid_columnconfigure(0, weight=1) self. Forms_frame. Grid_columnconfigure(1, weight=1) self.
Forms_frame. Grid_columnconfigure(2, weight=1) def layout2col(self): self. Forms0.
Grid(column=0, row=0, padx=4, pady=2, sticky="ew") self. Forms1. Grid(column=0, row=1, padx=4, pady=2, sticky="ew") self.
Forms2. Grid(column=0, row=2, padx=4, pady=2, sticky="ew") self. Forms3.
Grid(column=1, row=0, padx=4, pady=2, sticky="ew") self. Forms4. Grid(column=1, row=1, padx=4, pady=2, sticky="ew") self.
Forms5. Grid(column=1, row=2, padx=4, pady=2, sticky="ew") self. Forms_frame.
Grid_columnconfigure(0, weight=1) self. Forms_frame. Grid_columnconfigure(1, weight=1) self.
Forms_frame. Grid_columnconfigure(2, weight=0) if __name__ == "__main__": app = App() app.mainloop().
I like the simplicity and idea behind your example, however, I'm modifying some legacy code and don't have the time to rewrite my layouts as definitions. I tried to create a def that would simply do grid_columnconfig(), but that didn't work. I've reduced the code so that it looks like what I'm working with and it is also functional.
– Stephen Jun 15 at 18:03 After some testing, I've discovered that I can add additional columns but can't seem to remove columns no longer needed. I've modified your code to demonstrate what I'm having a problem with. – Stephen Jun 15 at 21:12 @Stephen: You can't really remove rows because rows don't really exist as objects.
What you can do, however, is reset any configuration option for a row or column so it doesn't take up space (assuming nothing is actually in that row or column). You can use grid_size to get how many rows and columns it thinks it has, then reset the weight to zero for all the empty rows or columns. If you have forms that need to be removed (versus moved to a different row or column) use grid_forget.
– Bryan Oakley Jun 15 at 22:53 Well, I read through the documentation and did a little more experimenting, and the way the code is currently written there doesn't seem to be a clean way to make happen what I want to happen. Thanks for your help with this one. – Stephen Jun 16 at 21:49 @Stephen: rest assured, what you want to do is possible -- there are no limitations in Tkinter that prevent you to change a layout at runtime.
Unfortunately, your description of the problem just isn't sufficient to know what the real problem is. – Bryan Oakley Jun 16 at 23:19.
You might also need to pack() again, first.
I have tried update on just about everything without any success. I'm not currently using pack(), so I'm not familiar with that. I'll take a look at pack() and see how I should integrate that.
Thanks for the tip. – Stephen Jun 15 at 15:38 Keep in mind, it's been about a year since I've worked with Python/TKinter, so ymmv. – jpm Jun 15 at 15:40 Ok, did some quick research.
Didn't realize that pack() was a layout manager. I'm currently using the grid manager. – Stephen Jun 15 at 15:57.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.