I am trying to display an image with ttk / tkinter in python. The image has a white border, and I want to display this image on a larger white background - so it has a lot of white space.
For this, I use "padx" and "pady" in the label with 100px each. Unfortunately, the fill area is gray.
Now I tried to change the foreground and background shortcut to no avail. The fill area remains gray. Then I put the label in the Frame widget and tried to change the color of the foreground / background frame. But, unfortunately, the Frame widget does not listen to the width = and height = values. Also, if I change the foreground color, the SUNKEN border will change color - really cool, but completely useless to me: /.
Can someone help me with this? The current idle code is as follows:
style = Style() style.configure('Dlr.TFrame', background="blue", relief=SUNKEN) frm = Frame(self, style="Dlr.TFrame") # does not work: ,height=500,width=500) frm.grid(row=0, column=0, rowspan=8, columnspan=2, sticky=N+S+E+W) style.configure("Dlr.TLabel", background="white") style.configure("Dlr.TLabel.padding", background="white") # just guessed ... self.IMG = Label(frm, style="Dlr.TLabel") self.IMG.grid(row=0, column=0, padx=100, pady=100)
source share