I'm currently making kind of a configuration screen for a minesweeper, and I'd like the player to be able to choose how many row, columns and bombs are in the grid.
I already have all the logic behind, I'm currently implementing the GUI and I have trouble with the configuration screen:
I currently have this: Current gui.
And here's the code portion involved:
def __choice_screen(self):
"""Allows the user to configure the game settings"""
self.master.title("Configuration")
self.pack(fill=tk.BOTH, expand=1)
self.canvas = tk.Canvas(self, width=400, height=200)
self.canvas.pack(fill=tk.BOTH, side=tk.TOP)
# Choosing rows and col
lig = tk.IntVar()
lig.set(8)
self.lig_scale = tk.Scale(self, from_=5, to=20, orient=tk.HORIZONTAL, variable=lig)
self.lig_scale.pack(side=tk.BOTTOM)
col = tk.IntVar()
col.set(8)
self.col_scale = tk.Scale(self, from_=5, to=20, orient=tk.HORIZONTAL, variable=col)
self.col_scale.pack(side=tk.BOTTOM)
# Choosing number of bombs
self.nb_bombes = tk.Spinbox(self, from_=1, to=(lig.get() * col.get()), wrap=True, width=4)
self.nb_bombes.pack(side=tk.TOP)
# DEBUG:
self.debug = tk.Label(self, text=f"DEBUG: {lig.get() * col.get()}")
self.debug.pack(side="top", fill="x")
self.master.mainloop()
I would like the maximal value of the Spinbox to be dynamically changed as (rows * columns) (i.e the number of cells in the grid), but it's not working (it's stuck to 64, which is the default values multiplied).
I've searched but didn't find a solution (I tried to link variables to the scales but it doesn't work as you can see), so thanks if someone can help :)
(Sorry for my english I'm french =D)