Unsolved PyQt, after app quit, my command line is unresponsive
-
Hi, I have some weird behaviour that I can not understand.
I run this code "python3 ToonPi.py" from my Raspberry Pi command line.
This generates a screen with picture and button using PyQt5 and Qt5.5. When I click the button the app quits, so far so good.
However, from that point on my command line no longer works and I can not see the blinking line which I
normally see when I want to type something in. I have to reboot my RPi to try again.
Anyone have any idea on this?Below are both the py file and the QML file.
QML Fileimport QtQuick 2.3 import QtQuick.Controls 1.4 ApplicationWindow { id: window visible: true width: 800; height: 480 Rectangle { id: screen width: 800; height: 480 SystemPalette { id: activePalette } Item { width: parent.width anchors { top: parent.top; bottom: toolBar.top } Image { id: background anchors.fill: parent source: "./pics/toonback.png" fillMode: Image.PreserveAspectCrop } } Button{ x: 100 y: 100 text : "Quit" onClicked: { Qt.quit() } } Rectangle { id: toolBar width: parent.width; height: 30 color: activePalette.window anchors.bottom: screen.bottom Text { id: score anchors { right: parent.right; verticalCenter: parent.verticalCenter } text: "Score: Who knows?" } } } }
And the Python file
import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtQml import QQmlApplicationEngine def main(): engine = QQmlApplicationEngine("basic.qml") engine.quit.connect(myApp.quit) # Execute the Application and Exit myApp.exec_() # Main Function if __name__ == '__main__': # Create main app myApp = QApplication(sys.argv) sys.exit(main())
-
hello,
So reset or clear wont make it "blink" again? -
You mean reboot? After reboot its fine.
What do you mean by reset or clear? -
Perhaps because you are not returning the value. There's no return.
Did you try adding
return myApp.exec_()
exec_() will return an integer. (usually 0)