Widget Inspection Tool broken in 4.2.2

Pressing CTRL-ALT-I with the 4.2.2 demo and 4.2.2 installed… I get this error:

$ python wxPython-demo-4.2.2\demo
Traceback (most recent call last):
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\mixins\inspection.py", line 155, in _OnKeyPress
    self.ShowInspectionTool()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\mixins\inspection.py", line 168, in ShowInspectionTool
    InspectionTool().Show(wnd)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 112, in Show
    self._frame.SetObj(selectObj)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 295, in SetObj
    self.UpdateInfo()
    ~~~~~~~~~~~~~~~^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 288, in UpdateInfo
    self.info.UpdateInfo(self.obj)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 624, in UpdateInfo
    st += self.FmtWidget(obj)
          ~~~~~~~~~~~~~~^^^^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 659, in FmtWidget
    count = len([c for c in obj.GetChildren() if not c.IsTopLevel()])
                            ~~~~~~~~~~~~~~~^^
TypeError: 'WindowList_iterator' object is not iterable
Traceback (most recent call last):
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\core.py", line 3427, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
                  ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 270, in _postStartup
    self.UpdateInfo()
    ~~~~~~~~~~~~~~~^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 288, in UpdateInfo
    self.info.UpdateInfo(self.obj)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 624, in UpdateInfo
    st += self.FmtWidget(obj)
          ~~~~~~~~~~~~~~^^^^^
  File "C:\Users\ntmccork\AppData\Roaming\Python\Python313\site-packages\wx\lib\inspection.py", line 659, in FmtWidget
    count = len([c for c in obj.GetChildren() if not c.IsTopLevel()])
                            ~~~~~~~~~~~~~~~^^
TypeError: 'WindowList_iterator' object is not iterable

well, what about

        if obj.GetChildren():
            count = len([c for c in obj.GetChildren() if not c.IsTopLevel()])
        else:
            count = 0

on line 659 of inspection.py (never used it so far) :rofl:

You are probably using Python >= 3.13.1 which had a modification in byte code generation.

It has been fixed in the wxPython repository:

You need to use an older Python version or try a recent wxPython snapshot build from Index of /Phoenix/snapshot-builds

Thanks Dietmar,
I posted on Github issues too, and found that using a pre-release of version 4.2.3 fixes the issue!

thanks again for your thoughts!

2 Likes

Another option to get a recent version if you prefer using pypi is to use wxPythonMeticy.

1 Like