Clicker Game

 avatar
unknown
plain_text
a year ago
929 B
8
Indexable
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QLabel, QVBoxLayout

class ClickerApp(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('Clicker App')
        self.setGeometry(100, 100, 300, 200)

        self.click_count = 0

        self.label = QLabel('Clicks: 0', self)
        self.button = QPushButton('Click me', self)
        self.button.clicked.connect(self.increment_click_count)

        layout = QVBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.button)
        self.setLayout(layout)

    def increment_click_count(self):
        self.click_count += 1
        self.label.setText(f'Clicks: {self.click_count}')

def main():
    app = QApplication(sys.argv)
    clicker_app = ClickerApp()
    clicker_app.show()
    sys.exit(app.exec())

if __name__ == '__main__':
    main()
Editor is loading...
Leave a Comment