I am making a GUI application for a class. I have made the form layout (
make_form()) using both Frame and grid, but I am not exactly sure that one should be mixing those two together. What is the best way to make a layout, using grid to incorporate not just the labels and Entry fields, but also the buttons?
import tkinter as tk fields = "Dimensions", "Parent population size", "Children populatoin size", \ "Recombination population size", "Maximum iterations", "Low boundary domain", \ "High boundary domain", "Parameter size" def quit(): root.destroy() def clear_initial_conditions(initial_conditions): for ic in initial_conditions: ic.delete(0, "end") def get_initial_conditions(initial_conditions): for ic in initial_conditions: field = ic text = ic.get() if text.isdigit(): print("%s: %s" % (field, text)) else: print("Field \"%s\" does not have a valid number, correct to integer" % field) def make_form(root, fields): initial_conditions =  for field in fields: row = tk.Frame(root) row.pack(side = tk.TOP, fill = tk.X, padx = 10, pady = 10) lab = tk.Label(row, width = 30, text = field, anchor = tk.W) lab.grid(row = 0, column = 0) ent = tk.Entry(row) ent.grid(row = 0, column = 1, sticky = tk.W) initial_conditions.append((field, ent)) return initial_conditions if __name__ == "__main__": root = tk.Tk() root.option_add('*font', ('verdana', 8)) root.title("Pack - Example 12") ents = make_form(root, fields) root.bind("<Return>", (lambda event, e = ents: get_initial_conditions(e))) b1 = tk.Button(root, text = "Find minimum", command = (lambda e = ents: get_initial_conditions(e))) b1.pack(side = tk.LEFT, padx = 10, pady = 10) b2 = tk.Button(root, text = "Clear", command = (lambda e = ents: clear_initial_conditions(e))) b2.pack(side = tk.LEFT, padx = 10, pady = 10) root.mainloop()