[wxpython-users] py2app and xrc.XRCCTRL()

wxPython user mailing list, post #18,496
Author:
Date:
Subject:
 Warren Smith
 2008-07-18 08:21:47
 [wxpython-users] py2app and xrc.XRCCTRL()
I've used Python for years, but I am fairly new to the Mac, wxPython,
and py2app.

I got a simple wxPython test app bundle working fine (it just puts an
unpopulated frame on the screen) . The same bundle runs on 10.5
Intel, 10.4 PPC, and 10.3 PPC.

So now I am attempting to package a more complex app that was being
developed by a recently departed co-worker. This app makes use of XRC
resources, which seems to be the right way to do things.

The app runs fine in my development environment. However when I
package it with py2app, calls to XRCCTRL() return None instead of a
component instance. The XRCID() method that XRCCTRL uses is returning
an Id, but the window.FindWindowById() is returning None.

Here is my environment:
OSX 10.5.4
MacPython 2.5.2 (insta
wxPython 2.6.4.0 (also tried 2.8.8.0 with same results)
py2app 0.4.2 (dev version needed for correct handling of setuptools
namespace packages)

I suspected that something wasn't being included in the bundle, so
I've tried adding all of the following via the py2app "packages"
option:
'wxPython',
'wx',
'wx.build',
'wx.lib',
'wx.py',
'wx.tools'

No joy. The bundle got significantly bigger, but I still get the same problem.

I'm stumped. I've scoured the Internet, but I can't find any
references to a similar problem.

Can anyone shed some light on this?

--
Warren Smith
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Robin Dunn
 2008-07-18 12:13:35
 Re: [wxpython-users] py2app and xrc.XRCCTRL()
Warren Smith wrote:
> I've used Python for years, but I am fairly new to the Mac, wxPython,
> and py2app.
>
> I got a simple wxPython test app bundle working fine (it just puts an
> unpopulated frame on the screen) . The same bundle runs on 10.5
> Intel, 10.4 PPC, and 10.3 PPC.
>
> So now I am attempting to package a more complex app that was being
> developed by a recently departed co-worker. This app makes use of XRC
> resources, which seems to be the right way to do things.
>
> The app runs fine in my development environment. However when I
> package it with py2app, calls to XRCCTRL() return None instead of a
> component instance. The XRCID() method that XRCCTRL uses is returning
> an Id, but the window.FindWindowById() is returning None.

It is probably not finding the xrc file. Double check that you are
using the correct pathname for the file.


--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Warren Smith
 2008-07-18 15:47:46
 Re: [wxpython-users] py2app and xrc.XRCCTRL()
On Fri, Jul 18, 2008 at 1:13 PM, Robin Dunn <[email protected]> wrote:
>
> It is probably not finding the xrc file. Double check that you are using
> the correct pathname for the file.
>

Yep. That was it. It couldn't load the .xrc file.

However, the problem wasn't an incorrect path. My co-worker had used
os.dirname(__file__) to load the .xrc files that are stored alongside
the .py files. This works fine until py2app bundles both files into
site-packages.zip.

I modified the .xrc loading code to use __name__ with
pkg_resources.resource_string() and all is well.

Thanks!

--
Warren Smith
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users