Search code examples
python-3.xtkinterpython-imaging-librarytkinter-entry

Tkinter fullscreen leaves border


I am trying to make an image slide show application using Tkinter and Pillow. I would like the image to go full screen, so currently my code looks like this (I think these are all the important bits, ask me if you need to see more):

canvas = Canvas(root, width=screenwidth, height=screenheight, bg=‘black’)#screenwidth and height previously assigned (checked to be correct) variables containing screen dimensions. 
image = image.resize((resizew, resizeh) Image.ANTIALIAS)
imagesprite = canvas.create_image(midx, midy, image=photo) #had changed our resized image to a tkinter photo image previously, midx and midy are just half the screen dimensions.  

The problem: No matter what settings I change there is always some form of grey bar around the edge of the window. I have tried changing the window size, changing the canvas size, setting the window geometry manually using root.geometry to no avail. However, some of the combinations of settings lead to there being fewer bars; I have seen between 1 and 3. Pictures of the output in its current state are attached. There are no errors in the shell, not (currently) is there a border on the left of the image

[1]: https://i.sstatic.net/1DLfg.jpgenter image description here


Solution

  • You need to set highlightthickness=0 when creating the canvas:

    canvas = Canvas(root, width=screenwidth, height=screenheight, bg='black', highlightthickness=0)