Button is not showing in my program is there anything missing?

Viewed 28

Click to see outputI have written this code for creating button in pyqt 6 ,but it not showing buttons,it prints statement inside function but the code for buttons is not working

from PyQt6.QtWidgets import QApplication,QWidget,QPushButton,QLayout
from PyQt6.QtGui import QIcon
import sys


class windowexamle(QWidget):
    def __init__(self):
        super().__init__()
        self.setGeometry(200, 200, 400, 300)
        self.show()
        self.setWindowTitle('Button')
        self.setWindowIcon(QIcon('python.png'))
        self.create_widgets()

    def create_widgets(self):
        btn1 = QPushButton("Click Me", self)
        btn2=QPushButton('clickme', self)
        print("Iam being called")


app = QApplication(sys.argv)
window = windowexamle()
sys.exit(app.exec())
0 Answers
Related