Wednesday, January 6, 2016

Python Tkinter Frame border color

It turns out that in Tkinter, you can set the width of a frame's border, but you can't set it's color. Since ttk objects differ from Tkinter objects, this may not necessarily be true for ttk frames (but I haven't checked yet). The only apparent way of creating color Tkinter frames around things is to layer frames within frames. First pack a frame with the desired color as it's bg color. Then pack another frame in that one, set fill="both" with some padx and pady to set the edges of the second frame in from the edges of the first frame, allowing the color of the first frame to show around the edges of the second frame. Then pack stuff into the second frame. Some links:

https://bytes.com/topic/python/answers/38448-changing-color-default-frame-border

http://stackoverflow.com/questions/4241036/how-do-i-center-a-frame-within-a-frame-in-tkinter

For possible future reference:

http://stackoverflow.com/questions/4320725/how-to-set-border-color-of-certain-tkinter-widgets