So my problem is that instead of manually writing a ton of code for a bunch of buttons, I want to create a class for a QPushButton
and then change so many variables upon calling that class to create my individual buttons.
My problem is that my button does not seem to be clickable despite calling the clicked.connect function and having no errors upon running the code. Here are the relevant parts of the button class:
class Button(QtGui.QPushButton):
def __init__(self, parent):
super(Button, self).__init__(parent)
self.setAcceptDrops(True)
self.setGeometry(QtCore.QRect(90, 90, 61, 51))
self.setText("Change Me!")
def retranslateUi(self, Form):
self.clicked.connect(self.printSomething)
def printSomething(self):
print "Hello"
Here is how I call the button class:
class MyWindow(QtGui.QWidget):
def __init__(self):
super(MyWindow,self).__init__()
self.btn = Button(self)
layout = QtGui.QVBoxLayout(self)
layout.addWidget(self.btn)
self.setLayout(layout)