As someone who is relatively new to coding, I am trying to create my own chess game. Currently, I am facing a challenge in attempting to make my buttons invisible while still allowing them to execute piece movements. Any advice or guidance would be greatly appreciated. Thank you in advance for your assistance. Here's my Background and these are my button.
from tkinter import *
import tkinter as tk
from PIL import Image, ImageTk
# create object
window = Tk()
# Adjust the size
window.geometry('500x500')
# title
window.title('ChessBoard')
# import image
icon = PhotoImage(file='Board.png')
image = Image.open('Board.png')
# make icon
window.iconphoto(True, icon)
# resize image
resize_image = image.resize((430, 450))
img = ImageTk.PhotoImage(resize_image)
# create label and add resize image
label1 = Label(image= img)
label1.image = img
label1.pack()
# Making my buttons
list_box = {}
for x in range(8):
label1.columnconfigure(x, weight=1)
for y in range(8):
list_box['box{0}{1}'.format(x, y)]= tk.Button(label1, height=3, width=6,)
list_box['box{0}{1}'.format(x, y)].grid(row=x, column=y, padx=1, pady=1)
# start the main event loop
window.mainloop()
I've try to use this code but I kept getting this:
window.wm_attributes('-transparentcolor', '#2b9438')
list_box['box{0}{1}'.format(x, y)] = tk.Button(label1, height=3, width=6, bg='#2b9438')