I was wondering how to create an amount(that is taken from a user input) of the same type of buttons that can be controlled individually? I tried to use classes to do this, but it only creates a single button.
class GridBtn(QMainWindow):
def __init__(self, self_global, x, y):
super(GridBtn, self).__init__()
self.button = QPushButton("0", self_global)
self.move(x,y)
def change_val(self, val):
self.button = QPushButton(val, self_global)
def returnx(self, x):
return x
def returny(self, y):
return y
That is the GridBtn class that the grid generator references.
self.grid_x = 3
self.grid_y = 3 #later changed to user input, just for testing
for x in range(self.grid_x):
for y in range(self.grid_y):
for grid_btn in range(self.grid_y):
print("test") #testing if works
#need to fix this to make more efficient
grid_btn = GridBtn(self, x*10, y*10)
self.button_grid_layout.addWidget(grid_btn.button,x,y)
This is trying to create a specific amount of buttons, but just creates one button, like this: