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?

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)
- screen redraws seem (subjectively) to be less efficient (yellow
background bleeds through)

Regards,
Malcolm


<snipped>
From: "Michael Lange" <klappn...@web.de>

I don't think there are such options in Tk by default, so 3. probably is
not an option (unless you do very fancy things with ttk styles, but
these
are probably also possible with the ttk module).
With a canvas you can try something like:

from Tkinter import *
root = Tk()
root.geometry('500x500')

c = Canvas(root, bg='yellow', bd=0, highlightthickness=0, takefocus=0)
c.pack(fill='both', expand=1, padx=100, pady=100)
c.update_idletasks()
w, h = c.winfo_width(), c.winfo_height()
r = c.create_rectangle(0, 0, w-1, h-1, outline='red', fill='',
dash=(5,5))
f = Frame(c, width=w-2, height=h-2)
w = c.create_window(1, 1, window=f, anchor='nw')

def foo(event):
    w, h = event.width, event.height
    event.widget.coords(r, 0, 0, w-1, h-1)
    f.configure(width=w-2, height=h-2)
c.bind('<Configure>', foo)

root.mainloop()

This seems to work ok, I'm not sure if this might break in some
situations though.
</snipped>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to