I routinely use PyDev in Eclipse for Python development. However, I'm trying PyQt for the first time in the same environment. It works well, with one exception. If the program errors out anywhere within the Qt main event loop, including within my own code, no error information is output to the PyDev console.
To demonstrate this I created the following simple PyQt app:
import sys
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication
# test.ui contains a single Push Button named pushButton
base, form = uic.loadUiType("../ui/test.ui")
class MainWindow(base, form):
def __init__(self, parent=None):
super(base, self).__init__(parent)
self.setupUi(self)
self.pushButton.clicked.connect(self.button_pressed)
def button_pressed(self):
print('button pressed')
print(invalid_variable) # intentional error
pass
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyle("fusion")
main_window = MainWindow()
main_window.show()
sys.exit(app.exec_())
If I place an intentional error such as print(invalid_variable) anywhere after if __name__ == '__main__': and before the app.exec_() command, the program properly terminates with a traceback and the expected NameError: name 'invalid_variable' is not defined. However, if I press the button in my dialog using the above code, button pressed appears on the console but then the application terminates silently and with no error information in the console. Other debugging operations, such as breakpoints and expressions, work fine.
Is this expected behavior? If so, what do you recommend for facilitating debugging of PyQt apps in this environment. If not, I'd appreciate insight into what I need to do to rectify the problem.
- Python version: python-3.4.3.amd64
- PyDev version: PyDev for Eclipse 4.3.0.201508182223
- PyQt version: PyQt5-5.5-gpl-Py3.4-Qt5.5.0-x64
Update 2015-09-30:
When I run the test app directly with python.exe, it outputs the error correctly to stderr in both error scenarios. So this issue does seem specific to the PyDev environment. I additionally created an entirely fresh Eclipse workspace with only the Python interpreter configured and ran my test again on a freshly created PyDev project using the same source code. The results were the same.