The problem is if you run this code below and resize the window then you will get unexpected behavior. Widgets are not rendered like they should and the backgrounds have some
@Idlehands Thanks for citing Fredrik Lundh's effbot.org explanation on background
. I think I finally understand Fredrik Lundh's documentation. Namely,
bg=""
is a valid argument that will prevent the updating of the Frame
widget's background, and background
or bg
of a Frame
widget defaults to the application background color. Hence, when the Tk window is resized, e.g. when the right edge of the Tk window is move to the left to reach the Canvas
widget's right edge and followed by moving right back to its original position, the following phenomenon happens:
Frame
widget's width reduces in size. When this happens, I suspect the Tk
widow background colour that filled the Frame
widget is lost.Frame
widget's width next returns to its original size, it's background needs to be updated (i.e. filled) with a defined colour. Because bg=""
prevents updating, i.e. prevents filling the Frame widget background with a defined background colour, the Frame
widget's background will default to the "application background colour". Meaning it will be filled with the exact color of the area directly behind the Frame
widget and the Tk
window, as if it became 'transparent'. Answering @Turjak_art question, tkinter
did not yield an Error or Exception because bg=""
is a valid argument of the Frame
widget.
Edit:
Image showing Frame background with fast resizing.
Image showing Frame background with slow resizing.