How to make GridContainer Cell Buttons Bigger

Godot Version

Godot 4.3

Question

So I’m coding a Advanced Tic Tac Toe game where you can either play simple or advanced multiplayer AI or by yourself… But whenever I go to yourself the little boxs for ultimate tic tac toe are small and i cant seem to resize them very well. Here is a screenshot

At the top left corner you can see, I can click on them but I can’t really see them and I want to make them bigger, here is my miniboard thing:

this is the code for miniboard.gd:

extends Node

Array to hold references to mini boards

var mini_boards =

func _ready():
var grid_container = $GridContainer # Ensure the GridContainer node is present
if not grid_container:
print(“GridContainer not found!”)
return # Exit if the GridContainer is not found

print("Creating mini boards...")
for i in range(3):
	for j in range(3):
		var mini_board = preload("res://miniboard.tscn").instantiate()  # Use instantiate() instead of instance()
		if mini_board is Control:  # Check if mini_board is of type Control
			# Set a larger minimum size for the mini board
			if mini_board.has_method("set_minimum_size"):
				mini_board.set_minimum_size(Vector2(400, 400))  # Increase size for bigger boards
			else:
				print("mini_board does not support set_minimum_size method.")
			
			# Set size flags to allow for expansion
			mini_board.size_flags_horizontal = Control.SIZE_EXPAND
			mini_board.size_flags_vertical = Control.SIZE_EXPAND

			# Optionally, set a fixed size if you want them to be a specific size
			# mini_board.rect_size = Vector2(400, 400)  # Uncomment this line to set a fixed size

		mini_boards.append(mini_board)
		grid_container.add_child(mini_board)  # Add mini boards to the grid
		print("Mini board added at position: ", i, j)

print("All mini boards created successfully.")

Let me know if you need anymore code to fix the issue, thank you! :slight_smile:

I think there’s no minimum_size or set_minimum_size in control node.
Screenshot From 2024-10-15 16-08-36


You may use set_custom_minimum_size function.

1 Like

Thank you, that fixed it!
image
and they are out further, so that works! Thank you again! :slight_smile:

1 Like