Demo entry 1076636

A simple Python3/PyQt5 example

   

Submitted by Dimitris on Jan 16, 2015 at 09:01
Language: Python 3. Code size: 691 Bytes.

#!/usr/bin/env python3

from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget
from PyQt5.QtCore import Qt


class Example(QWidget):

    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setFixedSize(200, 100)
        self.setWindowTitle('Example')
        label = QLabel('Hello')
        layout = QVBoxLayout()
        layout.addWidget(label)
        layout.setAlignment(Qt.AlignCenter)
        self.setLayout(layout)


if __name__ == '__main__':

    import sys
    from PyQt5.QtWidgets import QApplication

    app = QApplication(sys.argv)
    ex = Example()
    ex.show()
    sys.exit(app.exec_())

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).