Pertemuan 6

PYQT5
 avatar
unknown
python
10 months ago
1.1 kB
5
Indexable
from PyQt5.QtWidgets import *
from PyQt5 import QtCore
from PyQt5.QtGui import *

def main():
    app = QApplication([])
    window = QWidget()

    width = 500
    height = 400

    window.setWindowTitle("Nama_NPM")
    window.setStyleSheet("background-color:#00ffff; font-weight: bold")
    window.setFixedSize(width, height)

    layout = QVBoxLayout()

    label = QLabel("Ingin Tahu?")
    label.setAlignment(QtCore.Qt.AlignCenter)
    label.setFont(QFont("Garamond",25))


    button = QPushButton("Klik Disini!")
    button.setStyleSheet("background-color:white;")
    button.setFont(QFont("Sans Serif", 10))

    button.clicked.connect(onclicked)

    layout.addWidget(label)
    layout.addWidget(button)

    window.setLayout(layout)

    window.show()
    app.exec()

def onclicked():
    message = QMessageBox()
    message.setWindowTitle("Program AP2B")
    message.setText("Harap Tenang, Sedang Ujian")
    message.setFont(QFont("Courier",20))
    message.setStyleSheet("background-color:#d9db24; font-weight: bold;")
    message.exec()

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