Skip to content

AttributeError: 'RasterWindow' object has no attribute 'SetClientSizeWH' #169

Open
@afk-moneymaker

Description

@afk-moneymaker

Hello, I have been trying to familiarize myself with the library. However, I encountered a problem.
The spectral library calls SetClientSizeWH. If the call is changed to SetClientSize, the error does not occur anymore, but others are raised. I therefore assume that the library versions I am using are incompatible with each other. But which combination works?

Code

import os

from spectral import *
import spectral.io.envi as envi

if __name__ == "__main__":
    path = os.path.dirname(__file__) + "/../../data/raw/"
    header = path + "ENVIDATA.hdr"
    data = path + "ENVIDATA.dat"
    img = envi.open(header, data)

    view_indexed(img)

Error message

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~\source\repos\hyperspectral-imaging\src\core\__init__.py:12
      9     data = path + "ENVIDATA.dat"
     10     img = envi.open(header, data)
---> 12     view_indexed(img)
     13     # view = imshow(img, colors=spy_colors)
     14     # gt = img.read_band(0)
     15     # view = imshow(classes=gt, colors=spy_colors)
   (...)
     20
     21 # Run with: & PROJECT/.venv/Scripts/ipython.exe PROJECT/src/core/__init__.py --pylab=WX -i

File ~\source\repos\hyperspectral-imaging\.venv\Lib\site-packages\spectral\graphics\graphics.py:277, in view_indexed(*args, **kwargs)
    274 if 'colors' not in kwargs:
    275     kwargs['colors'] = spy_colors
--> 277 return view(*args, **kwargs)

File ~\source\repos\hyperspectral-imaging\.venv\Lib\site-packages\spectral\graphics\graphics.py:97, in view(*args, **kwargs)
     94 else:
     95     rgb = rgb.astype(np.uint8)
---> 97 frame = RasterWindow(None, -1, rgb, **kwargs)
     98 frame.Raise()
     99 frame.Show()

File ~\source\repos\hyperspectral-imaging\.venv\Lib\site-packages\spectral\graphics\rasterwindow.py:36, in RasterWindow.__init__(self, parent, index, rgb, **kwargs)
     33 self.kwargs = kwargs
     34 wx.Frame.__init__(self, parent, index, title,
     35                   wx.DefaultPosition)
---> 36 self.SetClientSizeWH(self.bmp.GetWidth(), self.bmp.GetHeight())
     37 wx.EVT_PAINT(self, self.on_paint)
     38 wx.EVT_LEFT_DCLICK(self, self.left_double_click)

AttributeError: 'RasterWindow' object has no attribute 'SetClientSizeWH'

Technical details

  • Windows 10
  • x86_64

Dependency Versions

  • numpy: 2.1.0
  • pillow: 10.4.0
  • wxPython: 4.2.1
  • matplotlib: 3.9.2
  • ipython: 8.26.0 (Which I use as the interpreter)
  • PyOpenGL: 3.1.7
  • spectral: 0.23.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions