S
S
sam_tack2016-06-04 15:17:09
Python
sam_tack, 2016-06-04 15:17:09

How to import all classes in PyQt5?

I started to study PyQt5, and the following problem arose: how to import all classes so as not to write each one separately?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-06-06
@sam_tack

In PyQt5, it is enough to import the Qt module, and through it to get access to everything you need. If you immediately import all classes, you will simply litter your program.
For example:

from PyQt5 import Qt


class ExampleWidget(Qt.QWidget):

    def __init__(self):
        super().__init__()
        layout = Qt.QVBoxLayout(self)
        layout.addWidget(Qt.QLabel("Label"))
        layout.addWidget(Qt.QLineEdit("LineEdit"))
        layout.addWidget(Qt.QPushButton("PushButton"))
        pb = Qt.QProgressBar()
        pb.setValue(66)
        layout.addWidget(pb)


if __name__ == '__main__':
    app = Qt.QApplication([])
    w = ExampleWidget()
    w.show()
    app.exec()

S
sim3x, 2016-06-04
@sim3x


Each time write only the import that you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question