Exception with the Widget_Inspection_Tool (WIT)

Hello,

Robin has recently suggested to use the WIT which I had never heard before. So, as suggested in the Wiki I added the two following lines to my app:

   1 import wx.lib.inspection
   2 wx.lib.inspection.InspectionTool().Show()

But, when I launch my application I get the following error:

Traceback (most recent call last):
File "C:\test_app\test.py", line 447, in <module>
wx.lib.inspection.InspectionTool().Show()
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\inspection.py", line 94, in Show
self._frame.SetObj(selectObj)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\inspection.py", line 239, in SetObj
self.tree.BuildTree(obj, includeSizers=self.includeSizers)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\inspection.py", line 361, in BuildTree
root = self._AddWidget(realRoot, w, includeSizers)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\inspection.py", line 389, in _AddWidget
self._AddWidget(item, child, includeSizers)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\inspection.py", line 389, in _AddWidget
self._AddWidget(item, child, includeSizers)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\inspection.py", line 388, in _AddWidget
if not child in widgetsInSizer and not child.IsTopLevel():
AttributeError: GenericTreeItem instance has no attribute 'IsTopLevel'

I tested my app with Python 2.5.2 and wxPython 2.8.6.1/2.8.9.1.

Any suggestion?
Mathias

Mathias,

Mathias Lorente wrote:

Hello,

Robin has recently suggested to use the WIT which I had never heard before.

It has been mentioned here and there. It was introduced in 2.8.01, check out the "changes" doc in wx/docs folder - a must read on each release :wink:

So, as suggested in the Wiki I added the two following lines to my app:

  1 import wx.lib.inspection
  2 wx.lib.inspection.InspectionTool().Show()

This works for me in the shell (e.g. Boa's shell).

But, when I launch my application I get the following error:

Check the second code example on the wiki if you want to use within your application.

Werner

Thanks for your hint but...

Werner F. Bruhin wrote:

Mathias,

Mathias Lorente wrote:

Hello,

Robin has recently suggested to use the WIT which I had never heard before.

It has been mentioned here and there. It was introduced in 2.8.01, check out the "changes" doc in wx/docs folder - a must read on each release :wink:

So, as suggested in the Wiki I added the two following lines to my app:

  1 import wx.lib.inspection
  2 wx.lib.inspection.InspectionTool().Show()

This works for me in the shell (e.g. Boa's shell).

Yes, it works like a charm for my little test program

But, when I launch my application I get the following error:

Check the second code example on the wiki if you want to use within your application.

I added the second peace of code (removing the first one) and when I use Ctrl+Alt+I I get the same error.

Any other idea?
Mathias

···

Werner

Mathias Lorente wrote:

Thanks for your hint but...

Werner F. Bruhin wrote:

Mathias,

Mathias Lorente wrote:

Hello,

Robin has recently suggested to use the WIT which I had never heard before.

It has been mentioned here and there. It was introduced in 2.8.01, check out the "changes" doc in wx/docs folder - a must read on each release :wink:

So, as suggested in the Wiki I added the two following lines to my app:

  1 import wx.lib.inspection
  2 wx.lib.inspection.InspectionTool().Show()

This works for me in the shell (e.g. Boa's shell).

Yes, it works like a charm for my little test program

But, when I launch my application I get the following error:

Check the second code example on the wiki if you want to use within your application.

I added the second peace of code (removing the first one) and when I use Ctrl+Alt+I I get the same error.

Any other idea?
Mathias

Not without a code example. I use it as a menu item with the following code in it:

<code>

def onInspect(self, event):
    '''
    Run the Widget Inspection Tool
    '''
    import wx.lib.inspection
    wx.lib.inspection.InspectionTool().Show()

</code>

Then I just go to my menu and open it. This would work with a button also. I'm using wxPython 2.8.9.1 (msw-unicode) on Windows XP. I haven't tried this on Ubuntu, so I'm not sure if it works the same way there, but I would expect it to.

Mike

Mathias,

Mathias Lorente wrote:

Thanks for your hint but...

Werner F. Bruhin wrote:

Mathias,

Mathias Lorente wrote:

Hello,

Robin has recently suggested to use the WIT which I had never heard before.

It has been mentioned here and there. It was introduced in 2.8.01, check out the "changes" doc in wx/docs folder - a must read on each release :wink:

So, as suggested in the Wiki I added the two following lines to my app:

  1 import wx.lib.inspection
  2 wx.lib.inspection.InspectionTool().Show()

This works for me in the shell (e.g. Boa's shell).

Yes, it works like a charm for my little test program

But, when I launch my application I get the following error:

Check the second code example on the wiki if you want to use within your application.

I added the second peace of code (removing the first one) and when I use Ctrl+Alt+I I get the same error.

What happens when you just create a script as shown on the wiki page and run it?

If above works, but yours is still not working then you might want to show some code.

Werner

Werner,

Werner F. Bruhin wrote:

Mathias,

Mathias Lorente wrote:

Thanks for your hint but...

Werner F. Bruhin wrote:

Mathias,

Mathias Lorente wrote:

Hello,

Robin has recently suggested to use the WIT which I had never heard before.

It has been mentioned here and there. It was introduced in 2.8.01, check out the "changes" doc in wx/docs folder - a must read on each release :wink:

So, as suggested in the Wiki I added the two following lines to my app:

  1 import wx.lib.inspection
  2 wx.lib.inspection.InspectionTool().Show()

This works for me in the shell (e.g. Boa's shell).

Yes, it works like a charm for my little test program

But, when I launch my application I get the following error:

Check the second code example on the wiki if you want to use within your application.

I added the second peace of code (removing the first one) and when I use Ctrl+Alt+I I get the same error.

What happens when you just create a script as shown on the wiki page and run it?

Like my little test application, the script from the Wiki also works fine.
So, I'm afraid I have to check my real application but cannot send you any peace of code as it is really huge with lot of dependencies.

Thanks,
Mathias

···

If above works, but yours is still not working then you might want to show some code.

Werner

Mathias,

Mathias Lorente wrote:

....

Like my little test application, the script from the Wiki also works fine.
So, I'm afraid I have to check my real application but cannot send you any peace of code as it is really huge with lot of dependencies.

Looking again at the exception I wonder if you are using the customtreectrl in your code? Maybe there is an issue with that control and the WIT?

Werner

Werner,

Werner F. Bruhin wrote:

Mathias,

Mathias Lorente wrote:

....

Like my little test application, the script from the Wiki also works fine.
So, I'm afraid I have to check my real application but cannot send you any peace of code as it is really huge with lot of dependencies.

Looking again at the exception I wonder if you are using the customtreectrl in your code? Maybe there is an issue with that control and the WIT?

Werner

Bad news. You are right and I found that GetChildren methods have been defined while sub-classing custumtreectrl... I should have to rename these methods... snif

Thanks for your help,
Mathias

Mathias Lorente wrote:

Werner,

Werner F. Bruhin wrote:

Mathias,

Mathias Lorente wrote:

....

Like my little test application, the script from the Wiki also works fine.
So, I'm afraid I have to check my real application but cannot send you any peace of code as it is really huge with lot of dependencies.

Looking again at the exception I wonder if you are using the customtreectrl in your code? Maybe there is an issue with that control and the WIT?

Werner

Bad news. You are right and I found that GetChildren methods have been defined while sub-classing custumtreectrl... I should have to rename these methods... snif

Thanks for your help,
Mathias

Finally it works fine. I've "just" modified inspection.py to avoid retrieving child for widgets which inherit from customtreectrl.
I know I should not do such a thing but it is the simpler way for the moment. When I have enough time I will change the name of the methods and all the references.

Thanks again for your help, Werner.
Mathias