Created
September 4, 2015 13:23
-
-
Save saleph/58ca3ed27107b4448603 to your computer and use it in GitHub Desktop.
[qt5] checkbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt5.QtWidgets import QWidget, QCheckBox, QApplication | |
from PyQt5.QtCore import Qt | |
class Example(QWidget): | |
def __init__(self): | |
super().__init__() | |
self.init_ui() | |
def init_ui(self): | |
check_box = QCheckBox('Show title', self) | |
check_box.move(20, 20) | |
check_box.toggle() | |
check_box.stateChanged.connect(self.change_title) | |
self.setGeometry(300, 300, 250, 150) | |
self.setWindowTitle('QCheckBox') | |
self.show() | |
def change_title(self, state): | |
if state == Qt.Checked: | |
self.setWindowTitle('QCheckBox') | |
else: | |
self.setWindowTitle(' ') | |
if __name__ == "__main__": | |
app = QApplication(sys.argv) | |
ex = Example() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment