I am making a chess program and I want to be able to drag the pieces. In order to do this, I put the image of the piece on a Canvas
so it can be dragged (I can also use a Label
if I want). However, when I drag the piece there is a white square that surrounds the image of the piece.
When I researched the problem, many people gave this solution:
drag_canvas = Canvas(self, height=80, width=80, bg="yellow")
root.wm_attributes("-transparentcolor", "yellow")
This caused the background to be transparent but it was not the chessboard that was visible, it was the program behind the GUI
Is there any way I can have the background be transparent and show the chessboard behind rather than the program behind the tkinter window?
Note: I do not mind using any other widget (e.g. a Label
) but they must use modules that come default with Python (so no PIL) as this program needs to be used in an environment where I cannot download other modules.
The only possible
config(...
option, to set the background to nothingTo get this result:
you have to hold the chess board and figures within the same
.Canvas(...
.Tested with Python: 3.5 - TkVersion: 8.6