I\'m trying to use Tkinter Canvas
(self._canvas
) to create window using create_window
function. The window field for
You can bind self._canvas
with the event <Configure>
, and then call itemconfig
with the id of the frame added to the canvas (not directly the reference to the widget):
def __init__(self, rows, cols, master=None):
# ...
self._frame_id = self._canvas.create_window(0, 0, window=self._tableFrame, anchor=N+W)
self._canvas.pack(side=LEFT, fill=BOTH, expand=True)
self._canvas.bind("<Configure>", self.resize_frame)
def resize_frame(self, e):
self._canvas.itemconfig(self._frame_id, height=e.height, width=e.width)
By the way, I recommend you to rewrite your import
statements, which in my opinion are quite repetitive and unpythonic:
import Tkinter as tk
# Use tk.Tk, tk.Canvas, etc.