I'm making a grid layout of text boxes, something that resembles Microsoft Excel.
I have made a canvas (Inside a frame) and used create_window to add a frame with 100 text boxes (each one inside of a frame) into the canvas, to be able to scroll them in and out of view, using scrollbars on the right side and the bottom, much like in Microsoft Excel. The reason the text boxes are each in their own frame, is so i can define their size in pixels by making the text boxes fill the frame. My issue is that when i set the size of the frame that holds the text box, it doesn't change the size of the frame at all. It is by default the size of the text box, as if the frame isn't even there. please help? Code Below:
def __init__(self, master):
master.title('Table Viewmode')
#'widthxheight+Xoffset+Yoffset'
master.geometry('800x600+500+200')
self.tableContainer = Frame(master)
self.tableContainer.pack(side="left", fill="both", expand=True)
#Frame and Canvas
self.tableCanvas = Canvas(self.tableContainer)
self.tableFrame = Frame(self.tableCanvas)
#Canvas stretch config
self.tableCanvas.grid(row=0, column=0, sticky=N+S+E+W)#.pack(side="left", fill="both", expand=True)
self.tableContainer.grid_columnconfigure(0, weight=1)
self.tableContainer.grid_rowconfigure(0, weight=1)
#Scrollbars
self.yscrollBar = Scrollbar(self.tableContainer, orient=VERTICAL,
command=self.tableCanvas.yview)
self.yscrollBar.grid(row=0, column=1, sticky=N+S)
self.tableCanvas.config(yscrollcommand=self.yscrollBar.set)
self.xscrollBar = Scrollbar(self.tableContainer, orient=HORIZONTAL,
command=self.tableCanvas.xview)
self.xscrollBar.grid(row=1, column=0, sticky=W+E)
self.tableCanvas.config(xscrollcommand=self.xscrollBar.set)
self.xscrollBar.config()
self.tableCanvas.create_window((4,4), window=self.tableFrame, anchor="nw")
self.createTable(10,10)
self.tableFrame.bind("<Configure>", self.frameConfigureHandler)
#Lines of code in question
def createTable(self, rows, columns):
self.frameList = []
for row in range(0, rows):
for column in range(0, columns):
frame = Frame(self.tableFrame)
frame.config(width=10,height=10)
text = Text(frame)#, height=1, width=2) I can change the size of the text boxes, this works fine.
text.insert(END, str(row)+str(column))
text.pack(side=LEFT, expand=True, fill=BOTH)
frame.grid(row = row, column = column)
def frameConfigureHandler(self, event):
self.tableCanvas.configure(scrollregion=self.tableCanvas.bbox("all"))
frame.pack_propagate(False)? And frame will not try to change size to fit to child/children size. effbot.org: pack_propagate(flag) - furas