My goal is to have the application structure with classes and the MVC approach following the recommendations of Bryan Oakley Ref. Stackoverflow Questions How to get variable data from a class, Calling functions from a Tkinter Frame to another, etc. and the present minimum workable example is heavily relying on Bryan's code.
I am not understanding why the frame self.frame_base = ttk.Frame(self)
does not expand with the container frame container = ttk.Frame(self)
.
I want the Labelframe "Select Data" to fill its base window and resize with it.
I tried several ideas with no success i.e. with self.frame_base = ttk.Frame(parent)
the frame and its content disappears.
There is something in the parent references that I am not getting right and would appreciate any support.
Regards Alioth
import tkinter as tk
import tkinter.ttk as ttk
class progTest(ttk.Frame):
def __init__(self, parent):
ttk.Frame.__init__(self, parent)
self.parent = parent
container = ttk.Frame(self)
container.pack(side="top", fill="both", expand = True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
self.frames["testGui"] = testGui(parent=container)
self.frames["testGui"].grid(row=0, column=0, sticky = 'nwes')
frame = self.frames["testGui"]
frame.tkraise()
class testGui(ttk.Frame):
def __init__(self, parent):
ttk.Frame.__init__(self, parent)
self.parent = parent
# Calling up of the main Gui window
self.createMainWindow(parent)
def createMainWindow(self, parent):
self.frame_base = ttk.Frame(self)
# self.frame_base = ttk.Frame(parent)
self.frame_base.grid(column = 0, row = 0, sticky = 'nwes')
self.frame_base.columnconfigure(0, weight = 1)
self.frame_base.rowconfigure(0, weight = 1)
self.labelframe_flt = ttk.LabelFrame(self.frame_base, text = "Select Data", padding = 2)
self.labelframe_flt.grid(column = 0, row = 0, sticky = "nwes", padx = 2, pady = 2)
ttk.Label(self.labelframe_flt, text="Parameter", width = 14).grid(column = 0, row = 0, sticky = "w")
self.combo_to = ttk.Combobox(self.labelframe_flt, width = 46)
self.combo_to.grid(column = 1, row = 0, padx = 10, pady = 2)
self.combo_to.config(values = ["aa", "bb", "cc", "dd"])
self.combo_to.current(0)
self.frame_base.columnconfigure(0, weight = 1)
self.frame_base.columnconfigure(1, weight = 1)
#------------------------------------------------------------------------------
def main():
root = tk.Tk()
progTest(root).pack()
root.minsize(500, 100)
root.mainloop()
#------------------------------------------------------------------------------
if __name__ == '__main__' :
main()