XRC errors on Vista

I have an application that fails on some windows
machines. When it does fail, I see

Exception: C++ assertion "wxAssertFailure"
failed at ..\..\src\msw\combobox.cpp(
406) in wxComboBox::GetEditHWND():
not read only combobox without edit control?
Traceback (most recent call last):
  File "MedIDWare.py", line 78, in <module>
  File "UI\MedIDWareController.pyo", line 51, in __init__
  File "UI\MedIDWareView.pyo", line 46, in __init__
  File "wx\_core.pyo", line 7981, in __init__
  File "wx\_core.pyo", line 7555, in _BootstrapApp
  File "UI\MedIDWareView.pyo", line 92, in OnInit
  File "UI\MedIDWareView.pyo", line 99, in InitFrame
  File "wx\xrc.pyo", line 149, in LoadFrame
PyAssertionError: C++ assertion "wxAssertFailure" failed at ..\..\src\msw\combob
ox.cpp(406) in wxComboBox::GetEditHWND(): not read only combobox without edit co
ntrol?

I've checked the code mechanics, and the LoadFrame call is happening in the
suggested location. I've tried removing all the CB_READONLY styles in the xrc
file just to see what would happen, and there was no change.

What could I be doing wrong?

Can you create a small runnable example? See here for more info: http://wiki.wxpython.org/MakingSampleApps

That would help us a lot. Which version of wxPython and Python are you using?

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

Mike Driscoll <kyosohma <at> gmail.com> writes:

Can you create a small runable example?

Hey Mike,
I'm really just posting here to see if anyone recognizes it.

Which version of wxPython and Python are you using?

python 2.7.2, wxPython2.8-win32-unicode-2.8.12.1-py27

The app runs fine on my Windows 7 machine, and my Windows XP machine, but it's
reported to fail on many Vista and Windows 7 machines.

Well, hopefully the XRC guys will be able to spot something. I don’t use XRC enough to tell from just that traceback.

···

On Fri, Sep 23, 2011 at 2:14 PM, Jim Carroll jim@maplesong.com wrote:

Mike Driscoll <kyosohma gmail.com> writes:

Can you create a small runable example?

Hey Mike,

I’m really just posting here to see if anyone recognizes it.

Which version of wxPython and Python are you using?

python 2.7.2, wxPython2.8-win32-unicode-2.8.12.1-py27

The app runs fine on my Windows 7 machine, and my Windows XP machine, but it’s

reported to fail on many Vista and Windows 7 machines.


Mike Driscoll

Blog: http://blog.pythonlibrary.org

We'll need a runnable sample to play with.

···

On 9/23/11 12:31 PM, Mike Driscoll wrote:

On Fri, Sep 23, 2011 at 2:14 PM, Jim Carroll <jim@maplesong.com > <mailto:jim@maplesong.com>> wrote:

    Mike Driscoll <kyosohma <at> gmail.com <http://gmail.com>> writes:
     > Can you create a small runable example?

    Hey Mike,
    I'm really just posting here to see if anyone recognizes it.

     > Which version of wxPython and Python are you using?

    python 2.7.2, wxPython2.8-win32-unicode-2.8.12.1-py27

    The app runs fine on my Windows 7 machine, and my Windows XP
    machine, but it's
    reported to fail on many Vista and Windows 7 machines.

Well, hopefully the XRC guys will be able to spot something. I don't use
XRC enough to tell from just that traceback.

--
Robin Dunn
Software Craftsman

Robin Dunn <robin <at> alldunn.com> writes:

> The app runs fine on my Windows 7 machine, and my Windows XP
> machine, but it's
> reported to fail on many Vista and Windows 7 machines.
>
> Well, hopefully the XRC guys will be able to spot something. I don't use
> XRC enough to tell from just that traceback.

We'll need a runnable sample to play with.

I just tried to py2exe the Calc.pyw example from:

  UsingXmlResources - wxPyWiki

It runs on my machine, but on the test target, I'm getting:

Traceback (most recent call last):
  File "Calc.pyw", line 71, in <module>
  File "Calc.pyw", line 68, in main
  File "wx\_core.pyc", line 7981, in __init__
  File "wx\_core.pyc", line 7555, in _BootstrapApp
  File "Calc.pyw", line 9, in OnInit
  File "Calc.pyw", line 15, in InitFrame
  File "wx\xrc.pyc", line 254, in XRCCTRL
AttributeError: 'NoneType' object has no attribute 'FindWindowById'

It is a different error, but I think it's related.

My setup.py (minus the manifest) looks like:

setup(name="Calc",
      scripts=["Calc.pyw"],
       
      windows=[
            {
                'script': 'Calc.pyw',
                'copyright': 'Copyright (C) Me 2011',
                'other_resources': [(24, 1, manifest)],
                'icon_resources': [(1, 'Calc.ico')],
            },
      ],
      data_files = [
         ("Microsoft.VC90.CRT", glob(CRT_PATH + "\\*.*")),
         ('.', [
            'Calc.xrc',
            ],
         ),
      ],
)

I can send the Calc.pyw and Calc.xrc, but they're exactly as they are in the
tutorial.

It is probably not finding the .xrc file. Did you include it when you copied to the target machine? Since it is loaded in that sample without a full path name then you need to make sure that the .xrc file is in the current working directory when the program is run. (Or modify the code to use the path of where the executable is located, or something like that.)

···

On 9/26/11 10:44 AM, Jim Carroll wrote:

Robin Dunn<robin<at> alldunn.com> writes:

     The app runs fine on my Windows 7 machine, and my Windows XP
     machine, but it's
     reported to fail on many Vista and Windows 7 machines.

Well, hopefully the XRC guys will be able to spot something. I don't use
XRC enough to tell from just that traceback.

We'll need a runnable sample to play with.

I just tried to py2exe the Calc.pyw example from:

   UsingXmlResources - wxPyWiki

It runs on my machine, but on the test target, I'm getting:

Traceback (most recent call last):
   File "Calc.pyw", line 71, in<module>
   File "Calc.pyw", line 68, in main
   File "wx\_core.pyc", line 7981, in __init__
   File "wx\_core.pyc", line 7555, in _BootstrapApp
   File "Calc.pyw", line 9, in OnInit
   File "Calc.pyw", line 15, in InitFrame
   File "wx\xrc.pyc", line 254, in XRCCTRL
AttributeError: 'NoneType' object has no attribute 'FindWindowById'

It is a different error, but I think it's related.

--
Robin Dunn
Software Craftsman

>>> The app runs fine on my Windows 7 machine, and my Windows XP
>>> machine, but it's
>>> reported to fail on many Vista and Windows 7 machines.
>>>
>>> Well, hopefully the XRC guys will be able to spot something. I don't use
>>> XRC enough to tell from just that traceback.
>>
It is probably not finding the .xrc file. Did you include it when you
copied to the target machine? Since it is loaded in that sample without
a full path name then you need to make sure that the .xrc file is in the
current working directory when the program is run. (Or modify the code
to use the path of where the executable is located, or something like that.)

The .xrc file (in this example) is right in the same directory with the script,
and It's also right next to the .exe file in the py2exe-ed version.

The setup.py that I included in my post ensures that the xrc is carried through:
      data_files = [
         ("Microsoft.VC90.CRT", glob(CRT_PATH + "\\*.*")),
         ('.', [
            'Calc.xrc',
            ],
         ),
      ],

It does run on my windows machine... so it's not just a wouldn't-work-anywhere
sort of problem. Any sample I gave you (including the whole commercial product)
would probably work on your machine. Our client tells us that it doesn't work
on many machines, and sent us one by FedEx that we could use to troubleshoot.

One strange thing is that on my machine, the CRT_PATH doesn't include a
manifest, just the three redistribute-able DLLs... could that manifest be
causing things to fail?

Does XRC require MFC dlls restributed as well?

      The app runs fine on my Windows 7 machine, and my Windows XP
      machine, but it's
      reported to fail on many Vista and Windows 7 machines.

Well, hopefully the XRC guys will be able to spot something. I don't use
XRC enough to tell from just that traceback.

It is probably not finding the .xrc file. Did you include it when you
copied to the target machine? Since it is loaded in that sample without
a full path name then you need to make sure that the .xrc file is in the
current working directory when the program is run. (Or modify the code
to use the path of where the executable is located, or something like that.)

The .xrc file (in this example) is right in the same directory with the script,
and It's also right next to the .exe file in the py2exe-ed version.

Yes, but what is the current working dir on the machines that fail? Is it the path where the exe is located or is it somewhere else? For example, I can get the calc sample to fail with the same traceback simply by changing the CWD where it is run from, no py2exe needed:

dazzler:robind ~/Desktop/calc
  > py calc.py ### Works with no exception raised

dazzler:robind ~/Desktop/calc
  > cd .. ### change to the parent folder

dazzler:robind ~/Desktop
  > py calc/calc.py ### this fails
Traceback (most recent call last):
   File "calc/calc.py", line 73, in <module>
     main()
   File "calc/calc.py", line 70, in main
     app = MyApp(0)
   File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/wx-2.9.2-osx_cocoa/wx/_core.py", line 8593, in __init__
     self._BootstrapApp()
   File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/wx-2.9.2-osx_cocoa/wx/_core.py", line 8158, in _BootstrapApp
     return _core_.PyApp__BootstrapApp(*args, **kwargs)
   File "calc/calc.py", line 10, in OnInit
     self.InitFrame()
   File "calc/calc.py", line 16, in InitFrame
     self.panel = xrc.XRCCTRL(self.frame, "MainPanel")
   File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/wx-2.9.2-osx_cocoa/wx/xrc.py", line 270, in XRCCTRL
     return window.FindWindowById(XRCID(str_id))
AttributeError: 'NoneType' object has no attribute 'FindWindowById'

The setup.py that I included in my post ensures that the xrc is carried through:
       data_files = [
          ("Microsoft.VC90.CRT", glob(CRT_PATH + "\\*.*")),
          ('.', [
             'Calc.xrc',
             ],
          ),
       ],

It does run on my windows machine... so it's not just a wouldn't-work-anywhere
sort of problem. Any sample I gave you (including the whole commercial product)
would probably work on your machine. Our client tells us that it doesn't work
on many machines, and sent us one by FedEx that we could use to troubleshoot.

One strange thing is that on my machine, the CRT_PATH doesn't include a
manifest, just the three redistribute-able DLLs... could that manifest be
causing things to fail?

That could be a problem, but not what you're seeing here.

Does XRC require MFC dlls restributed as well?

No.

I just went back and looked at your original message and I do not think that it is likely that this is the same problem. Try adding a combobox to the calc sample with the same attributes and see if that triggers the problem. If so then sent it in a reply. If not then keep trying to reproduce in a small sample. MakingSampleApps - wxPyWiki

···

On 9/26/11 11:55 AM, Jim Carroll wrote:

--
Robin Dunn
Software Craftsman

Robin Dunn <robin <at> alldunn.com> writes:

I just went back and looked at your original message and I do not think
that it is likely that this is the same problem. Try adding a combobox
to the calc sample with the same attributes and see if that triggers the
problem. If so then sent it in a reply. If not then keep trying to
reproduce in a small sample. MakingSampleApps - wxPyWiki

Thanks for your time Robin!

I added a combo box to the calc sample, and it still ran on the target
machine...

Then, to get rid of XRC as a variable in the code that's failing. I used
wxFormBuilder to spit out the python source, and used that directly. Now, on
the target machine I get:

PyAssertionError: C++ assertion "wxAssertFailure" failed at ..\..\src\msw\combob
ox.cpp(406) in wxComboBox::GetEditHWND(): not read only combobox without edit co
ntrol?

But I can see in the stack trace that It's happening exactly on this
(formbuilder-generated) line:

    self.PiReligion = wx.ComboBox( self.PersonalInfo, wx.ID_ANY,
wx.EmptyString, wx.DefaultPosition, wx.Size( 25,-1 ), PiReligionChoices,
wx.CB_DROPDOWN )

PiReligionChoices is an empty list.

    self.PiReligion = wx.ComboBox( self.PersonalInfo, wx.ID_ANY,
wx.EmptyString, wx.DefaultPosition, wx.Size( 25,-1 ), PiReligionChoices,
wx.CB_DROPDOWN )

I haven't verified this yet, but I think my combo box was too small.

After reading:
  wxComboBox::GetEditHWND() - serious bug! - wxWidgets Discussion Forum

I tried changing the width of the combo box, so that the
ChildWindowFromPoint had a chance of working. 25 pixels
wide probably means just a drop-down button with
no edit field next to it.

My first test with a larger combo box did not fail in the same place! :slight_smile:

I haven't verified this yet, but I think my combo box was too small.

After reading:
  wxComboBox::GetEditHWND() - serious bug! - wxWidgets Discussion Forum

I tried changing the width of the combo box, so that the
ChildWindowFromPoint had a chance of working. 25 pixels
wide probably means just a drop-down button with
no edit field next to it.

Verified! the width of 25 pixels was keeping the ChildWindowFromPoint from
finding the Edit's HWND!

As always, thanks for the help Robin!