I'm trying to make this canvas, which has a scrollingtext widget inside, resize according to the contents of these two entry widgets when I click a button.
Whenever I click the button, though, it just glitches a bit and then goes back to its original size.
Any idea why this is happening?
textBoxFrame = ttkb.Frame(right_frame)
textBoxFrame.grid(row=0, column=0, columnspan=2, sticky="NSEW")
textBoxFrame.grid_rowconfigure(0, weight=1)
textBoxFrame.grid_columnconfigure(0, weight=1)
innerCanvas = ttkb.Frame(textBoxFrame)
innerCanvas.pack()
textBox = ttkb.ScrolledText(innerCanvas, wrap=WORD)
textBox.grid(row=0, column=0)
def onResizeClick():
try:
boxwidth = int(box_width_setting.get())
boxheight = int(box_height_setting.get())
resizeTextbox(innerCanvas, boxwidth, boxheight)
except ValueError:
print("Please pass valid integers")
def resizeTextbox(canvas, boxwidth, boxheight):
canvas.grid_forget()
canvas.configure(width=boxwidth, height=boxheight)
resizeTextbox(innerCanvas, 80, 45)
box_resize = ttkb.Button(box_setting_frame, text="resize", command=onResizeClick)
box_resize.grid(row=1, column=1)
I'm using the function that's supposed to resize the widget to set its size initially, so I know that it works to some extent.