Reputation: 393
Why isn't the text widget filling out the entire yellow frame?
I even made sure to make the text widget sticky - what am I missing?`
(can_frame
is short for canvas_frame - the name I gave the frame that I putted into the canvas
from tkinter import *
enter code here
class window:
def __init__(self, root):
root.grid_rowconfigure (0, weight=1)
root.grid_columnconfigure(1, weight=1)
self.frame = Frame(root)
self.frame.grid(row=0, column=1, sticky='nsew')
self.frame.grid_columnconfigure(0, weight=1)
self.frame.grid_rowconfigure(0, weight=1)
self.canvas = Canvas(self.frame)
self.can_frame = Frame(self.canvas, bg='yellow')
self.canvas.grid( row=0, column=0, sticky='nsew')
self.can_frame.grid(row=0, column=0, sticky='nsew')
self.canvas.grid_columnconfigure((0,1), weight=1)
self.canvas.grid_rowconfigure( (0,1), weight=1)
self._frame_id = self.canvas.create_window((1,1), window=self.can_frame, anchor='sw', tags="self.frame")
self.canvas.bind( '<Configure>', self.resize_frame)
self.can_frame.bind( '<Configure>', self.onFrameConfigure)
inp = Text(self.can_frame, width=40, relief='groove') # TEXT WIDGET CREATED HERE
inp.grid(row=0, column=0, sticky='nsew') # it's sticky so why isn't it filling out the -
# - yellow frame?
def resize_frame(self, e):
self.canvas.itemconfig(self._frame_id, height=e.height, width=e.width)
def onFrameConfigure(self, e):
# update scrollregion after starting 'mainloop'
# when all widgets are in canvas
self.canvas.configure(scrollregion=self.canvas.bbox('all'))
Please don't post any solution without a canvas, I need the canvas to create a scrollbar later on, in order to scroll through all of different text widgets. Thanks!
Upvotes: 0
Views: 317
Reputation: 386285
When using grid
, you should always give at least one row and one column a positive weight. In your case, you have not given a weight to any of the columns in can_frame
, so any extra space will go unused.
Upvotes: 1