Skip to content

Instantly share code, notes, and snippets.

@saleph
Created September 4, 2015 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saleph/58ca3ed27107b4448603 to your computer and use it in GitHub Desktop.
Save saleph/58ca3ed27107b4448603 to your computer and use it in GitHub Desktop.
[qt5] checkbox
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