app = QApplication(sys.argv)
myWindow = MyWindow()
myWindow.show()
app.exec_()
When app.exec_() is executed in a code like this, console command line stops and nothing is entered. If I thread, will it be solved? I threaded, but maybe because I'm not good enough, the console command line is alive, but when I press pushbutton, the event that needs to happen does not happen.
If you have experienced this, it would be very helpful for undergraduate students if you could briefly explain how to enable input and output through console line with GUI in the same environment as windowpower shell. Thank you.
pyqt5 python console thread
The reason why it doesn't work is that you can't get other input because the gui main thread is performed. And it's also because event loops are being carried out
Then is there no way... You can integrate event loops with ipython or jupyter.
Install ipython (of course pyqt5) and run ipython and try as below.
In [1]: %gui qt5
In [2]: from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
In [3]: w = QWidget()
...: ...: w.resize(250, 150)
...: ...: w.move(300, 300)
...:
...: ...: btn = QPushButton('Button', w)
...: ...: btn.setToolTip('This is a <b>QPushButton</b> widget')
...: ...: btn.resize(btn.sizeHint())
...: ...: btn.move(50, 50)
...:
...: ...: w.setWindowTitle('Simple')
In [4]: w.show()
© 2024 OneMinuteCode. All rights reserved.