31 lines
659 B
Python
31 lines
659 B
Python
from PySide6.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton
|
|
import sys
|
|
|
|
class MainWindow(QMainWindow):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
self.is_checked = True
|
|
|
|
self.setWindowTitle('my App')
|
|
self.setMinimumSize(400,300)
|
|
|
|
button=QPushButton('Press me')
|
|
button.setCheckable(True)
|
|
button.clicked.connect(self.toggled)
|
|
button.setChecked(self.is_checked)
|
|
|
|
self.setCentralWidget(button)
|
|
|
|
|
|
def toggled(self, checked):
|
|
self.is_checked = checked
|
|
|
|
print(self.is_checked)
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
window = MainWindow()
|
|
window.show()
|
|
|
|
app.exec() |