I'm having some trouble getting a (ttk, and no I cannot change it to tk) button to maintain its size when it reveals an image. I start with a grid with only black background and no images.
https://i.stack.imgur.com/7ZdOj.png
Clicking on one of the buttons correctly changes the background color and reveals the image, but the button height and width dramatically changes.
https://i.stack.imgur.com/h0gv5.png
Everything seems to snap back to the right size once at least 1 image is revealed in every row and every column as seen below:
https://i.stack.imgur.com/7t2S3.png
My suspicion is something having to do with the stickyness of the widgets but I cannot seem to get the buttons to stay the same size. Is there a way to make this happen? Note: The issue does not occur if all 25 buttons have images from the start.
The button is called self.button_dict[(row_index, col_index)]
and the following is the code that gets called when the button is invoked.
# change button color
self.set_style(f"bclicked{row_index}{col_index}.TButton", background=new_color, bordercolor=current_border_color, highlightthickness=10, padding=0)
self.button_dict[(row_index, col_index)].configure(style=f"bclicked{row_index}{col_index}.TButton", command = lambda row_index=row_index, col_index=col_index:
self.change_button_color(new_color, current_color, row_index, col_index, current_border_color, placing_ship))
# reset the annotation behavior
self.button_dict[(row_index, col_index)].bind('<Button-3>', lambda event, row_index=row_index, col_index=col_index:
self.change_button_color(new_color, self.marking_colors["Annotating Color"], row_index, col_index, "#333333", False, right_clicked=True))
self.checks_found[row_index, col_index] = 1
self.button_dict[(row_index, col_index)].configure(image = self.images[row_index*self.col_size + col_index])
self.button_dict[(row_index, col_index)].image = self.images[row_index*self.col_size + col_index]