wavefrontshaping / slmPy

A simple Python module based on wxPython to interact with spatial light modulators handled as secondary monitors.
Other
63 stars 26 forks source link

wxPython 4.1.1, InitBuffer() error #1

Open univox360 opened 3 years ago

univox360 commented 3 years ago

I find the following issues on python 3.6 with wxPython 4.1.1

Your basic slm code:

` import slmpy

import time

import numpy as np

slm = slmpy.SLMdisplay()

resX, resY = slm.getSize()

X, Y = np.meshgrid(np.linspace(0, resX, resX), np.linspace(0, resY, resY)) testIMG = np.round((2 * 8 - 1) (0.5 + 0.5 np.sin(2 np.pi * X / 50))).astype('uint8')

slm.updateArray(testIMG)

slm.close() `

Gives the following error:

C:\Users\labuser\Miniconda3\python.exe C:/Users/labuser/PycharmProjects/opticalcompute/slmtest.py C:\Users\labuser\PycharmProjects\opticalcompute\slmPy-master\slmpy.py:40: wxPyDeprecationWarning: Call to deprecated item EmptyImage. Use :class:Image instead. self.img = wx.EmptyImage(2,2) Traceback (most recent call last): File "C:\Users\labuser\PycharmProjects\opticalcompute\slmPy-master\slmpy.py", line 59, in UpdateImage self.InitBuffer() File "C:\Users\labuser\PycharmProjects\opticalcompute\slmPy-master\slmpy.py", line 50, in InitBuffer self.clientSize = self.GetClientSize() RuntimeError: wrapped C/C++ object of type SLMframe has been deleted Process finished with exit code -1073741819 (0xC0000005)

Fixing the depcrecation issue wx.EmptyImage(2,2) -> wx.Image(2,2) in "slmpy.py" stil gives:

C:\Users\labuser\Miniconda3\python.exe C:/Users/labuser/PycharmProjects/opticalcompute/slmtest.py Traceback (most recent call last): File "C:\Users\labuser\PycharmProjects\opticalcompute\slmPy-master\slmpy.py", line 59, in UpdateImage self.InitBuffer() File "C:\Users\labuser\PycharmProjects\opticalcompute\slmPy-master\slmpy.py", line 52, in InitBuffer dc = wx.ClientDC(self) RuntimeError: wrapped C/C++ object of type SLMframe has been deleted

Process finished with exit code -1073741819 (0xC0000005)

I am not too experienced with python or wxPython, so maybe the solution is obvious. Thanks.

-Elliot

wavefrontshaping commented 3 years ago

Hi Elliot,

It seems that the deprecation warning has nothing to do with the actual error. I have Python 3.8 and wxPython 4.1.1, I have the warning, but it sill works correctly without error. I cannot reproduce the error on my computer but I will investigate. Can you try on Python 3.8?

wavefrontshaping commented 3 years ago

OK, I pushed a modification, what does it do?

univox360 commented 3 years ago

Thank you very much. I will try to test today. -Elliot

On Thu, Jan 28, 2021 at 11:40 PM Sébastien M. P. notifications@github.com wrote:

OK, I pushed a modification, what does it do?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wavefrontshaping/slmPy/issues/1#issuecomment-769636821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFM6ZUCZHYTCFQRQTJZAIC3S4JQ57ANCNFSM4WVZJ2HQ .

-- -Elliot

univox360 commented 3 years ago

Sorry, got a bit delayed.

I tested on python 3.8 and wxPython 4.1.1

I get the very same error:

Traceback (most recent call last): File "C:\Users\ejfull\PycharmProjects\pythonProject1\slmPy-master\slmpy.py", line 59, in UpdateImage self.InitBuffer() File "C:\Users\ejfull\PycharmProjects\pythonProject1\slmPy-master\slmpy.py", line 52, in InitBuffer dc = wx.ClientDC(self) RuntimeError: wrapped C/C++ object of type SLMframe has been deleted

Process finished with exit code -1073741819 (0xC0000005)

wavefrontshaping commented 3 years ago

I cannot make sense of it. Upon calling InitBuffer, it says SLMframe does not exist anymore, but it happens inside the SLMframe object... Not having the possibility to reproduce the error, I do not see how I can fix it right now. Sorry but I have no answer...

wavefrontshaping commented 3 years ago

Hi rewrote a big chunk of the code, could you try again?