Aanvinkbox (checkbox)
Op deze pagina:
Een aanvinkbox die de venstertitel aan- of uitzet.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
from PyQt5 import QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication, QCheckBox
class Venster(QMainWindow):
def __init__(self):
super(Venster, self).__init__()
self.initUI()
def initUI(self):
cb = QCheckBox('Venstertitel', self)
cb.move(20, 20)
cb.toggle()
cb.stateChanged.connect(self.titelAanpassen)
self.setGeometry(400, 400, 250, 150)
self.setWindowTitle('Aanvinkbox')
self.show()
def titelAanpassen(self, status):
if status == QtCore.Qt.Checked:
self.setWindowTitle('Aanvinkbox')
else:
self.setWindowTitle(' ')
def main():
app = QApplication(sys.argv)
window = Venster()
sys.exit(app.exec())
if __name__ == '__main__':
main()