EterPythonLib\PythonWindowManagerModule.cpp
// Search for this function
PyObject* wndImageLoadImage(PyObject* poSelf, PyObject* poArgs)
{
// ... existing code ...
}
// Add below
PyObject* wndImageUnloadImage(PyObject* poSelf, PyObject* poArgs)
{
UI::CWindow* pWindow;
if (!PyTuple_GetWindow(poArgs, 0, &pWindow)) {
return Py_BuildException();
}
if (!((UI::CImageBox*)pWindow)->UnloadImage()) {
return Py_BuildException("Failed to unload image");
}
return Py_BuildNone();
}
// Search for this method registration
{ "LoadImage", wndImageLoadImage, METH_VARARGS },
// Add below
{ "UnloadImage", wndImageUnloadImage, METH_VARARGS },
EterPythonLib\PythonWindow.cpp
// Search for this method
BOOL CImageBox::LoadImage(const char* c_szFileName)
{
// ... existing code ...
}
// Add below
BOOL CImageBox::UnloadImage()
{
if (!m_pImageInstance)
return FALSE;
OnDestroyInstance();
return TRUE;
}
EterPythonLib\PythonWindow.h
// Search for this method declaration
BOOL LoadImage(const char* c_szFileName);
// Add below
BOOL UnloadImage();
root/ui.py
# Search for this class definition
class ImageBox(Window):
# ... existing members ...
# Find these lines
self.eventFunc = {}
self.eventArgs = {}
# Add below
self.imageLoaded = False
# ...
# Search for this line where you load the image
wndMgr.LoadImage(self.hWnd, imageName)
# Add below
self.imageLoaded = True
# ...
# Search for this destructor definition
def __del__(self):
# ... existing code ...
# Add below
if self.imageLoaded:
self.UnloadImage()