OK, the problem with the test code is that it does not create a QApplication instance, does not call dv.show() (although the __init__ method for DataViewer -does- call it, which it shouldn't). Your test code should look more like this:
def _test() :
import sys
from PyQt5.QtCore import Qt
import numpy as np
import ClearMap.Visualization.Qt.DataViewer as dv
img1 = np.random.rand(*(100,80,30));
myViewer = dv.DataViewer(img1)
myViewer.show()
sys.exit(app.exec_())
def _test() :
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import Qt
import numpy as np
import ClearMap.Visualization.Qt.DataViewer as dv
app = QApplication(sys.argv)
img1 = np.random.rand(*(100,80,30));
myViewer = dv.DataViewer(img1)
myViewer.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
The reason the widget works inside a normal application is because the application almost certainly creates the QApplication instance and calls its exec() method so that the normal Qt event loop is up and running and the widget is responding to events. The original _test() method did none of that. Modifying it so it behaves like a mini-standalone app fixes that.
Bookmarks