[Tkinter-discuss] experimental tk program in python3
python at bdurham.com
python at bdurham.com
Fri Dec 17 14:41:45 CET 2010
Hi Michael,
> For widgets that don't accept keyboard focus you can use the highlightbackground option to create a colored border (although you cannot add a "3D"-relief this way) ... <snipped>
I took your example and added another frame and widgets that gain focus.
Your highlightbackground suggestion only works when there's a single
frame without widgets that can gain focus themselves. Interesting: On my
machine, the highlightbackground appears to work the opposite of its
stated purpose, eg. when button2 has focus, frame 1 shows its
highlightbackground and vice-versa.
<code>
from Tkinter import *
root = Tk()
f1 = Frame(root, bg='white', highlightthickness=2,
highlightbackground='red', width=200, height=200)
f1.pack(padx=100, pady=100, fill='both', expand=1)
Button( f1, text='Button 1' ).pack()
f2 = Frame(root, bg='white', highlightthickness=2,
highlightbackground='green', width=200, height=200)
f2.pack(padx=100, pady=100, fill='both', expand=1)
Button( f2, text='Button 2' ).pack()
root.mainloop()
</code>
I'm going to start a new thread on the topic of creating frames with
custom border colors.
Regards,
Malcolm
More information about the Tkinter-discuss
mailing list