Python Gui PyQt5 #1
PyQt5 ist ein GUI-Toolkit
Es bringt das Anwendungsframework Qt (c++) und Python zusammen.
PyQt5 unterschützt Windows, OS X, Linux, iOS und Android.
Instalation
pip install PyQt5
Erstes Programm
Zuerst muss sys und PyQt5 importiert werden.
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
Danach wird eine neue Applikation und ein neues Fenster erstellt und ausgegeben.
a = []
app = QApplication(a)
w = QWidget()
w.show()
Mit sys.exit(app.exec_()) wird das Programm beendet,
wenn das Fenster geschlossen wird.
Das Fenster sieht wie folgt aus.
Das Fenster ist leer und hat auch kein Icon.
Im folgenden wird die Größe und die Position, sowie der Titel und das Icon Festgelegt.
w.setGeometry(50,50,700,500)
w.setWindowTitle("Gui1")
w.setWindowIcon(QIcon('F.png'))
Als erstes wird das Fenster auf Position 50 : 50 verschoben.
700 ist die Breite und 500 ist die höhe.
Der Titel wird auf Gui1 gesetzt.
Das Bild muss im gleichen Ordner sein, dann kann es so benutzt werden.
Das Fenster:
Der komplette Code:
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
a = []
app = QApplication(a)
w = QWidget()
w.setGeometry(50,50,700,500)
w.setWindowTitle("Gui1")
w.setWindowIcon(QIcon('F.png'))
w.show()
sys.exit(app.exec_())
Leave Python Gui PyQt5 #1 to:
Read more #deutscht posts
Best Posts From Felix IT
We have not curated any of felix7d2's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Felix IT
- Xiaomi möchte nicht mehr als 5% Gewinn machen
- Neues Spionage Patent für Alaxer
- Schlechte Sicherheits Apps Android
- Windows-PC kann durch einen Besuch einer Seite gehackt werden
- BKA knackt schwache Passwörter ohne Supercomputer
- Short-URLs
- Dateien in Blockchain schpeichern
- Test - Bild
- Python Gui PyQt5 #2 Buttons
- Python Gui PyQt5 #1