I am using PyQt5 and IPython 7.3.0 on Ubuntu 18.04. I am loading this tiny Python module from an ipython
console invoked with eith --gui=qt5
switch or %gui qt5
executed after the shell has started. In either case, it displays a black window. Is it an IPython bug, or am I missing something?
from PyQt5.QtWidgets import QApplication, QWidget
class Viewer(QWidget):
def __init__(self, text):
super().__init__()
self.setWindowTitle('Viewer')
self.show()
def view_from_ipython():
ex = Viewer('Hello')
import time; time.sleep(5)
The module above is named as demo.py
.
$ ipython --gui=qt5
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import demo
In [2]: demo.view_from_ipython()
It shows a black window as shown below.
Update 1:
I forgot to mention that I want to show up the window in a non-modal way, meaning that the window that pops up should not prohibit the user from interacting with the ipython session. The solutions pointed out so far blocks the interactive session. I want to make it behave in the same way as matplotlib
graph plotting works (just to give an idea).