slmPy icon indicating copy to clipboard operation
slmPy copied to clipboard

wxPython 4.1.1, InitBuffer() error

Open univox360 opened this issue 5 years ago • 6 comments

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

univox360 avatar Jan 27 '21 19:01 univox360

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 avatar Jan 28 '21 16:01 wavefrontshaping

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

wavefrontshaping avatar Jan 29 '21 07:01 wavefrontshaping

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

On Thu, Jan 28, 2021 at 11:40 PM Sébastien M. P. [email protected] 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 avatar Jan 29 '21 15:01 univox360

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)

univox360 avatar Feb 11 '21 18:02 univox360

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 avatar Mar 22 '21 13:03 wavefrontshaping

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

wavefrontshaping avatar Apr 08 '21 07:04 wavefrontshaping