I have a toplevel
window in which I created a canvas
and a frame
within it to support scrolling functionallity.
Part of the canvas
and frame
code looks like this:
##Canvas
self.canvas = tk.Canvas(self.toplevel, borderwidth=0)
self.canvas.bind_all("<MouseWheel>", self.__on_mousewheel)
self.canvas.pack(side="left", fill="both", expand=True)
##Frame
self.frame = tk.Frame(self.canvas, background="red")
self.frame.bind("<Configure>", lambda event, canvas=self.canvas: self.__on_frame_configure())
self.canvas.create_window((1,1), window=self.frame, anchor="n")
......
"Later" in the code I populate the frame
with a dynamically generated number of checkbuttons. (depends on user input)
Problem #1
I can not retrieve the width (preferably in pixels) of the text
attribute of checkbuttons
. I have found a workaround for that!
Problem #2
I want to programmatically resize the width of the frame
.
self.frame.update()
print("Im here",self.frame.winfo_width())
self.frame.configure(width=self.frame.winfo_width() + 30)
print("Now im here",self.frame.winfo_width())
self.canvas.configure(width=self.frame.winfo_width())
self.canvas.configure(height=self.frame.winfo_height())
Outcome of print statements:
Im here 904
Now im here 934
When I inspect the gui, I notice that only that canvas gets resized.
Pic of the right part of the gui which is supposed to be filled in with red background of the frame
.