[Tkinter-discuss] Techniques for creating the appearance of frames with custom border colors
Michael Lange
klappnase at web.de
Fri Dec 17 18:27:52 CET 2010
Thus spoketh python at bdurham.com
unto us on Fri, 17 Dec 2010 12:04:18 -0500:
> Michael,
>
> Your code works wonderfully - thank you very much!!
>
> One question: Why did you add your inner frame to the canvas as a window
> via c.create_window() vs. just packing the frame?
>
To be honest, for no special reason, it seemed the "natural choice" to
me :)
BTW, in my example I did frame.configure(width=...) in the <Configure>
event binding, which at a second glance I would replace with
canvas.itemconfigure (w, width=event.width-2...)
A real advantage of the window items vs. pack() might be that it is
probably easier to handle when there are multiple widgets placed in the
canvas.
> I tried the frame packing technique per the following code change
> (replacing c.createwindow with pack):
>
> f = Frame(c, width=w-2, height=h-2)
> # w = c.create_window(1, 1, window=f, anchor='nw')
> f.pack() # note: will not work if passed fill='both', expand=1
>
> And the code seemed to work with the following caveats:
>
> - the top row of the rectangle is not displayed (I can't figure this one
> out)
You can avoid this with pack(pady=(1,0))
Regards
Michael
More information about the Tkinter-discuss
mailing list