Reputation: 3
I have the current code below for some basic parameter entry into an AI assignment. It is just there to st the starting parameters and display the outpit of the different algorithms implemented, however the box that contains the output will not resize? I think I am doing something wrong with maybe the parent-child structure but I can't figure out what.
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
self.create_widgets()
def create_widgets(self):
self.mainframe= tk.Frame(master=self, width=768, height=576)
self.mainframe.pack(fill=tk.BOTH, expand=1)
self.xsizelabel = tk.Label(self.mainframe, text="Size (X)")
self.xsizelabel.pack(side="top")
self.xsize = tk.Entry(self.mainframe)
self.xsize.insert(0, 2)
self.xsize.pack(side="top")
self.ysizelabel = tk.Label(self.mainframe, text="Size (Y)")
self.ysizelabel.pack(side="top")
self.ysize = tk.Entry(self.mainframe)
self.ysize.insert(0, 1)
self.ysize.pack(side="top")
self.xstartlabel = tk.Label(self.mainframe, text="Starting Position (X)")
self.xstartlabel.pack(side="top")
self.xStart = tk.Entry(self.mainframe)
self.xStart.insert(0, 0)
self.xStart.pack(side="top")
self.ystartlabel = tk.Label(self.mainframe, text="Starting Position (Y)")
self.ystartlabel.pack(side="top")
self.yStart = tk.Entry(self.mainframe)
self.yStart.insert(0, 0)
self.yStart.pack(side="top")
self.outputstartlabel = tk.Label(self.mainframe, text="Output")
self.outputstartlabel.pack(side="top")
self.separator = tk.Frame(master=self.mainframe, width=768, height=576, bd=1)
self.separator.pack(fill=tk.BOTH, padx=5, pady=5)
self.output = tk.Scrollbar(self.separator)
self.output.pack(side=tk.RIGHT, fill=tk.Y)
self.listbox = tk.Listbox(self.separator, yscrollcommand=self.output.set)
self.listbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self.run_button = tk.Button(self.mainframe)
self.run_button["text"] = "Run with these settings"
self.run_button["command"] = self.runAlgorithm
self.run_button.pack(side="top")
self.quit = tk.Button(self.mainframe, text="QUIT", fg="red",
command=self.master.destroy)
self.quit.pack(side="bottom")
but the resulting window looks like this: default
nothing expands when I expand the window, dispite setting the autofill and expand options. what am I doing wrong?
Upvotes: 0
Views: 39
Reputation: 10916
I can't run your program because you didn't present the whole thing. I see that you have set the fill and expand options on self.mainframe, but you didn't set those options in the constructor. Therefore the base window, which contains self.mainframe, will not expand to fill its available space. You need to make all the parent windows expandable, because when you drag the edges of the main window you are acting on the top level frame.
Upvotes: 1