from PyQt5.QtWidgets import QPushButton, QWidget, QApplication, QHBoxLayout

from PyQt5.QtCore import QObject



class Button(QPushButton):

    def __init__(self, callback):

        super(Button, self).__init__()


        self.setText("Hi")

        self.clicked.connect(callback)



class Example(QObject):

    def __init__(self):

        super(Example, self).__init__()


        self.btn = Button(self.callback)


    def callback(self):

        print("callback")



class Widget(QWidget):

    def __init__(self):

        super(Widget, self).__init__()


        ex_ = Example()


        h_box = QHBoxLayout()

        h_box.addWidget(ex_.btn)


        self.setLayout(h_box)

        self.show()



if __name__ == "__main__":

    import sys


    app = QApplication(sys.argv)

    wd = Widget()

    sys.exit(app.exec_())