Closed lwj-zxd closed 3 years ago
Please give a bit more context, like when did it fail, doing what? In essence, that error is "normal" when closing the SLM. In order to give the images to display to the SLM, slmPy uses a wxPython GUI that runs inside a thread, not to block the following commands. wxPython is not designed to do that, so it complains, but it works. I actually used the example provided on the wxPython wiki here. This error will most likely be displayed all the time when leaving the SLM, so if something goes wrong, it is probably elsewhere.
I won't reply next time if you make no effort to present your problem correctly, it is annoying and not polite.
Sorry for presenting my problem incorrectly. And I complete my problem here. I got an Exception when I used the example code given by you to control my spatial light modulator. Actually this code still work although it gives this Exception. I don't know if it is normal so I submit this issues.
Example code:
import slmpy import time import numpy as np slm = slmpy.SLMdisplay(isImageLock = True) resX, resY = slm.getSize() ImgResX = resX//2 ImgResY = resY//2 X,Y = np.meshgrid(np.linspace(0,ImgResX,ImgResX),np.linspace(0,ImgResY,ImgResY)) for i in range(100): testIMG = np.round((2*8-1)(0.5+0.5np.sin(2np.piX/50+1.0i/10*np.pi))).astype('uint8') slm.updateArray(testIMG) time.sleep(0.05) slm.close()
Exception: Exception in thread Thread-95: Traceback (most recent call last): File "C:\Users\OPTLAB\anaconda3\lib\threading.py", line 932, in _bootstrap_inner self.run() File "E:\lwj\SLM\slmpy.py", line 145, in run app.MainLoop() File "C:\Users\OPTLAB\anaconda3\lib\site-packages\wx\core.py", line 2237, in MainLoop rv = wx.PyApp.MainLoop(self) wx._core.wxAssertionError: C++ assertion "wxThread::IsMain()" failed at ....\src\msw\thread.cpp(1333) in wxMutexGuiLeaveOrEnter(): only main thread may call wxMutexGuiLeaveOrEnter()!