wxPython, pywxrc, InitXmlResource, and crashes

Here comes one weird situation, and one weird bug(?) report, from a
relative newbie with wxPython.

Basically, if I try to embed .xrc files into .py files (using pywxrc),
and then run the InitXmlResource() method, *only* the first one will
work. All others will fail.

I've tried renaming the method, I've tried trick after trick for finding
and fixing this issue, but I'm not capable (yet) of debugging this
error, as it's generating a segmentation fault.

This has also occurred on two separate platforms.

I've also attached the simplest case I could create which would show
this problem. One source file, two .xrc files. Save them all in the same
directory, and run the commands I've attached. You'll be able to see the
problem occur.

To show that the problem only occurs on the second (and subsequent?)
calls, remove the line from test.py which reads
"test2.InitXmlResource()", and re-run. Everything works just fine.

I need to keep these .xrc files as separate python modules. Without
trying to go into a detail, it's a requirement that these things be
separate.

Anybody have any suggestions for me to ponder?

Thanks for any help you can provide!

···

--
Michael J. Pedersen
My IM IDs: Jabber/pedersen@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
           Yahoo/pedermj2002, MSN/pedermj022171@hotmail.com
My GnuPG KeyID: 4E724A60 My Public Key Available At: pgp.mit.edu
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60
--

Versions here:
----------------------
Linux Platform
Linux: Debian testing/unstable
wxPython: 2.6.3.2, built from source, using RPM rebuild instructions
  found at http://www.bitpim.org/developer.html
Python: 2.3.5
----------------------
----------------------
Windows Platform
Windows: 2000sp4, all current updates
wxPython: 2.6.2.1, downloaded from wxpython.org/sf.net
Python: 2.4.2
----------------------

Commands Here:
----------------------
pywxrc -p -o test1.py test1.xrc
pywxrc -p -o test2.py test2.xrc
python test.py
----------------------

Source Code Listings Here:
test1.xrc:
----------------------
<?xml version="1.0" encoding="ascii"?>
<resource>
  <object class="wxDialog" name="DIALOG1">
    <title></title>
    <object class="wxButton" name="wxID_OK">
      <label>test1</label>
    </object>
  </object>
</resource>
----------------------

test2.xrc:
----------------------
<?xml version="1.0" encoding="ascii"?>
<resource>
  <object class="wxDialog" name="DIALOG2">
    <title></title>
    <object class="wxButton" name="wxID_OK">
      <label>test2</label>
    </object>
  </object>
</resource>
----------------------

test.py
----------------------
import wx
import wx.xrc

import test1
import test2

class icatest(wx.App):
  def OnInit (self):
    wx.InitAllImageHandlers()
    wx.xrc.XmlResource.Get().InitAllHandlers()
    test1.InitXmlResource()
    test2.InitXmlResource()
    return(True)

def main ():
  app = icatest()
  app.MainLoop()

if __name__ == '__main__':
    __name__ = "Tester"
    main()
----------------------

Can’t repro this on
XPsp2 with Python 2.4.2 and wxPython 2.6.2.1 which should be very
similar to your Windows configuration.

How does it fail
exactly?

I’m working on a
rewrite of pywxrc that also generates classes from the XRC elements.
You can get it from the CVS trunk:

.

Maybe it will work
better for you. In any case you seem to be a heavy XRC user and I would
love to hear your comments on the new pywxrc.

Michael J. Pedersen
wrote:

···

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/tools

Well, I had a hard time reading, but still got through (sorry, I still
like to use a text based mail client :slight_smile:

And it was *worth* it to get through it all. At least, I think it was.
The test code below now works, thanks to the new pywxrc.

Now, tonight, I'll be plugging it into my real code base (which,
naturally, has a lot more to it than what I wrote below), and giving it
a spin there. If that one works... Well, there just won't be any more to
say, other than thank you.

And I *will* be saying that tonight, I think.

Thanks for the quick reply! (Oh, I'm on EST, which is GMT-4 right now,
so you won't see anything from me until tomorrow)

<p style="margin-bottom: 0cm; margin-top: 0pt;">Can't repro this on
XPsp2 with Python 2.4.2 and wxPython 2.6.2.1 which should be very

similar to your Windows configuration.</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">How does it fail
exactly?</p>

On Windows, failure was in the from of a GPF (ie: This program has
performed an illegal operation and will now close). On Linux,
segmentation fault/core dump.

<p style="margin-bottom: 0cm; margin-top: 0pt;">I'm working on a
rewrite of pywxrc that also generates classes from the XRC elements.
You can get it from the CVS trunk:</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><a class="moz-txt-link-freetext" href="http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/tools&quot;&gt;http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/tools&lt;/a&gt;\.&lt;/p&gt;

Got it, and trying it (as I said above)

<p style="margin-bottom: 0cm; margin-top: 0pt;">Maybe it will work
better for you. In any case you seem to be a heavy XRC user and I would
love to hear your comments on the new pywxrc.<br>

Very much a heavy XRC user. Using them exclusively in C++, and trying to
make sure I continue to do so in wxPython. Good stuff :slight_smile:

···

On Thu, Apr 27, 2006 at 09:04:21AM +0200, Eli Golovinsky wrote:

--
Michael J. Pedersen
My IM IDs: Jabber/pedersen@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
           Yahoo/pedermj2002, MSN/pedermj022171@hotmail.com
My GnuPG KeyID: 4E724A60 My Public Key Available At: pgp.mit.edu
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60

I moved back to using plain old text based mail because of you. I guess the world is still not ready for more complicated things.

I'm glad I could help you out although I still have no idea why the old pywxrc doesn't work for you.

You should know that the XRCed version in the trunk supports automatic Python code generation using the new pywxrc module. I think you may find it useful.

If you encounter any problems, please post them here and also drop me a note at gooli at tuzig dot com as I don't always keep up with the flow of this list.

Michael J. Pedersen wrote:

···

Well, I had a hard time reading, but still got through (sorry, I still
like to use a text based mail client :slight_smile:

And it was *worth* it to get through it all. At least, I think it was.
The test code below now works, thanks to the new pywxrc.

Now, tonight, I'll be plugging it into my real code base (which,
naturally, has a lot more to it than what I wrote below), and giving it
a spin there. If that one works... Well, there just won't be any more to
say, other than thank you.

And I *will* be saying that tonight, I think.

Thanks for the quick reply! (Oh, I'm on EST, which is GMT-4 right now,
so you won't see anything from me until tomorrow)

I moved back to using plain old text based mail because of you. I guess
the world is still not ready for more complicated things.

Heh, I was just giving you a hard time. I don't mind reading through the
HTML code when somebody is trying to help me out, and I should have said
so. Sorry about that.

I'm glad I could help you out although I still have no idea why the old
pywxrc doesn't work for you.

I don't know why it didn't work either, but the new version works, and
handles everything as flawlessly as can be asked.

I've integrated it into my processes, and now I'm able to do exactly
what I was looking to do with it. Some more work remains to be done, but
this code is doing its job splendidly, thanks to these updates.

You should know that the XRCed version in the trunk supports automatic
Python code generation using the new pywxrc module. I think you may find
it useful.

I dunno. That's something I'll have to see. I like XRCed, definitely. It
seems to be the most reliable, and the least "fluffy" of the XRC editors
out there, in that it doesn't try to force you to use it to write the
code for the XRC files. Silly as it may seem, I really do prefer it that
way.

One more of the ways in which I'm a bit of an anachronism, I guess. Give
me a bunch of tools that work well, and I'll hang them together. Don't
much like having somebody else do it for some weird reason.

If you encounter any problems, please post them here and also drop me a
note at gooli at tuzig dot com as I don't always keep up with the flow
of this list.

Nope, no problems. Just very much happiness right now. New pywxrc works
as expected. Thank you so very much!

···

On Thu, Apr 27, 2006 at 04:51:46PM +0200, Eli Golovinsky wrote:

--
Michael J. Pedersen
My IM IDs: Jabber/pedersen@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
           Yahoo/pedermj2002, MSN/pedermj022171@hotmail.com
My GnuPG KeyID: 4E724A60 My Public Key Available At: pgp.mit.edu
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60

Michael J. Pedersen wrote:

You should know that the XRCed version in the trunk supports automatic Python code generation using the new pywxrc module. I think you may find it useful.

I dunno. That's something I'll have to see. I like XRCed, definitely. It
seems to be the most reliable, and the least "fluffy" of the XRC editors
out there, in that it doesn't try to force you to use it to write the
code for the XRC files. Silly as it may seem, I really do prefer it that
way.

Currently it just imports pywxrc and has options to generate the .py file either on-demand or automatically when you save the .xrc file. Not too much extra fluff there. The additional new features that I'd like to see get added will be similarly light weight, and will probably also be doable from the standalone pywxrc.

One more of the ways in which I'm a bit of an anachronism, I guess. Give
me a bunch of tools that work well, and I'll hang them together. Don't
much like having somebody else do it for some weird reason.

I don't think you're alone in this. :slight_smile:

BTW, not that it matters much any more <wink!> but I think I've found the cause of the problem you had with using the old version of pywxrc. There was some improper object ownership tracking and so something was getting deleted twice.

···

On Thu, Apr 27, 2006 at 04:51:46PM +0200, Eli Golovinsky wrote:

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

Currently it just imports pywxrc and has options to generate the .py
file either on-demand or automatically when you save the .xrc file. Not
too much extra fluff there. The additional new features that I'd like
to see get added will be similarly light weight, and will probably also
be doable from the standalone pywxrc.

Ah, okay. Just please avoid tying it in to something else, and making
the something else mandatory? For instance, one of the nicest debuggers
out there is GVD. Cross platform, and does the job in the way that I
expect (which is why I call it nice). Got integrated into an Ada IDE,
and the standalone was completely dropped. I had to go to
http://www.archive.org/ to get a copy of it.

It's really quite frustrating to see such a tool shut down like that,
and rendered useless such that you *must* go with an older version to
get the basic functionality out of it. wxGlade seemed to want to do more
than just be an xrc editor, too. And DialogBlocks, while really nice,
wouldn't provide an option to *just* edit the danged xrc file.

All in all, XRCed fits the bill perfectly: Edit the XRC file, and get
out of the way. That's good. And the options you've mentioned seem like
they'll fit into that pattern well, which is even better.

>One more of the ways in which I'm a bit of an anachronism, I guess. Give
>me a bunch of tools that work well, and I'll hang them together. Don't
>much like having somebody else do it for some weird reason.
I don't think you're alone in this. :slight_smile:

If I were alone in it, then there'd be no Linux, or a hundred other
things. Sometimes, though, when you're surrounded by people who
continuously remind you that you do more work putting things together
than they do just letting them run, it can be frustrating and seem
mighty much like you're alone.

BTW, not that it matters much any more <wink!> but I think I've found
the cause of the problem you had with using the old version of pywxrc.
There was some improper object ownership tracking and so something was
getting deleted twice.

Very nice! At least it means it wasn't just me doing something strange,
which I was very worried I was doing somehow. Glad I could provide
something useful to help improve things.

On a side note: I bought wxPython in Action. Haven't had much of a
chance to read it yet, but one thing I was disappointed by: Lack of
coverage of XRC. So, since you're here, I'll ask point blank: Why was
there so little coverage? I didn't find any coverage in the index, or in
the table of contents, so assume that if it's in there at all, it's
pretty minimal.

···

On Thu, Apr 27, 2006 at 08:21:38PM -0700, Robin Dunn wrote:

--
Michael J. Pedersen
My IM IDs: Jabber/pedersen@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
           Yahoo/pedermj2002, MSN/pedermj022171@hotmail.com
My GnuPG KeyID: 4E724A60 My Public Key Available At: pgp.mit.edu
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60

Michael J. Pedersen wrote:

On a side note: I bought wxPython in Action. Haven't had much of a
chance to read it yet, but one thing I was disappointed by: Lack of
coverage of XRC. So, since you're here, I'll ask point blank: Why was
there so little coverage? I didn't find any coverage in the index, or in
the table of contents, so assume that if it's in there at all, it's
pretty minimal.

When we realized we were going to be way over our "page budget" we
dropped some things that had already been written, and dropped plans for
some things that hadn't been written yet. XRC was one of those things.

···

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

If the XRC pages were some of the "already been written", any chance of
them appearing on (say) the wiki?

- --
  Nigel Rowe
  rho snail swiftdsl stop com stop au

···

On Saturday 29 April 2006 01:54, Robin Dunn wrote:

Michael J. Pedersen wrote:
> On a side note: I bought wxPython in Action. Haven't had much of a
> chance to read it yet, but one thing I was disappointed by: Lack of
> coverage of XRC. So, since you're here, I'll ask point blank: Why
> was there so little coverage? I didn't find any coverage in the
> index, or in the table of contents, so assume that if it's in there
> at all, it's pretty minimal.

When we realized we were going to be way over our "page budget" we
dropped some things that had already been written, and dropped plans
for some things that hadn't been written yet. XRC was one of those
things.

I've got to agree with the other poster who asked if some of the XRC
stuff could be posted someplace, especially if it deals with
implementing custom controls and subclasses.

If not, I'll figure it out eventually, and will be posting something
someplace. I simply cannot stand the lack of info about XRC in general.
I can see it does a great job, and can make it work, but try and find
documentation about doing much of anything with it. Very hard to do.

···

On Fri, Apr 28, 2006 at 08:54:35AM -0700, Robin Dunn wrote:

When we realized we were going to be way over our "page budget" we
dropped some things that had already been written, and dropped plans for
some things that hadn't been written yet. XRC was one of those things.

--
Michael J. Pedersen
My IM IDs: Jabber/pedersen@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
           Yahoo/pedermj2002, MSN/pedermj022171@hotmail.com
My GnuPG KeyID: 4E724A60 My Public Key Available At: pgp.mit.edu
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60

Nigel Rowe wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael J. Pedersen wrote:

On a side note: I bought wxPython in Action. Haven't had much of a
chance to read it yet, but one thing I was disappointed by: Lack of
coverage of XRC. So, since you're here, I'll ask point blank: Why
was there so little coverage? I didn't find any coverage in the
index, or in the table of contents, so assume that if it's in there
at all, it's pretty minimal.

When we realized we were going to be way over our "page budget" we
dropped some things that had already been written, and dropped plans
for some things that hadn't been written yet. XRC was one of those
things.

If the XRC pages were some of the "already been written", any chance of them appearing on (say) the wiki?

Sorry, we hadn't gotten to that point yet. Nor even to the point of deciding what and how much to write about it.

···

On Saturday 29 April 2006 01:54, Robin Dunn wrote:

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

Okay, now I'm starting to become annoyed with the state of XRC. It's one
of the best ideas to come out of wxWidgets, but the documentation for it
is actually *worse* than pitiful. Heck, it took me a full day of
searching to find one of the most important documents for it
(tn0014.txt). It's easy to find now, but it was a *royal* pain when I
went looking for it cause I needed it.

So, getting this well documented for both C++ and wxPython is going to
become one of my 3 major goals. Any preferred place for posting such
docs (remember, it's going to include C++ and wxPython)?

···

On Tue, May 02, 2006 at 01:13:51AM -0700, Robin Dunn wrote:

>If the XRC pages were some of the "already been written", any chance of
>them appearing on (say) the wiki?
Sorry, we hadn't gotten to that point yet. Nor even to the point of
deciding what and how much to write about it.

--
Michael J. Pedersen
My IM IDs: Jabber/pedersen@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
           Yahoo/pedermj2002, MSN/pedermj022171@hotmail.com
My GnuPG KeyID: 4E724A60 My Public Key Available At: pgp.mit.edu
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60

Michael J. Pedersen wrote:

So, getting this well documented for both C++ and wxPython is going to
become one of my 3 major goals. Any preferred place for posting such
docs (remember, it's going to include C++ and wxPython)?

If you don't get a better answer, I'd say start with a page on wiki.wxpython.org. I feel your pain on this, although not as strongly, and have given myself a tickler to put something up (in my imaginary spare time ;^).

A wiki page will allow those of us who feel similarly to collaborate, and maybe come up with something good. Besides, there's already a fair amount of material there that wouldn't be a bad start if there were a "main page" that pulls it all together (do a Text search for "xrc").

···

--
Don Dwiggins
Advanced Publishing Technology

Actually, I'm thinking something more serious than that. There's
half-notes spread around, tech notes, quick little cheat sheet style
how-to's, etc. However, I want to see something more comprehensive, and
more professionally laid out. While not a book, I want to put together a
chapter of a book, or a better how-to type.

Wiki's are great, make no mistake, but what I've got in mind might not
fit so well with a wiki page. Though, I suppose, it could be many
screenfuls, table of contents... Okay, there's ideas. And I suppose I
could compromise.

Alright, here we go: http://wiki.wxpython.org/index.cgi/XRCInformation

It's not got a lot there yet, but it *is* in place. And is going to be
updated as I can find the way to fill in the blanks.

Well, lots of the blanks are already filled in for me, personally,
especially with C++. I just wanted to make a beginning page, and add
more tonight.

···

On Tue, May 02, 2006 at 09:55:48AM -0700, Don Dwiggins wrote:

Michael J. Pedersen wrote:
>So, getting this well documented for both C++ and wxPython is going to
>become one of my 3 major goals. Any preferred place for posting such
>docs (remember, it's going to include C++ and wxPython)?
If you don't get a better answer, I'd say start with a page on
wiki.wxpython.org. I feel your pain on this, although not as strongly,
and have given myself a tickler to put something up (in my imaginary
spare time ;^).

A wiki page will allow those of us who feel similarly to collaborate,
and maybe come up with something good. Besides, there's already a fair
amount of material there that wouldn't be a bad start if there were a
"main page" that pulls it all together (do a Text search for "xrc").

--
Michael J. Pedersen
My IM IDs: Jabber/pedersen@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
           Yahoo/pedermj2002, MSN/pedermj022171@hotmail.com
My GnuPG KeyID: 4E724A60 My Public Key Available At: pgp.mit.edu
My GnuPG Key Fingerprint: C31C 7E90 5992 9E5E 9A02 233D D8DD 985E 4E72 4A60

Michael J. Pedersen wrote:

Alright, here we go: http://wiki.wxpython.org/index.cgi/XRCInformation

It's not got a lot there yet, but it *is* in place. And is going to be
updated as I can find the way to fill in the blanks.

Well, lots of the blanks are already filled in for me, personally,
especially with C++. I just wanted to make a beginning page, and add
more tonight.

Excellent start! And now that it's there, it will grow. Eventually, your "chapter of a book" will emerge. I'll try to chip in what I can.

···

--
Don Dwiggins
Advanced Publishing Technology
"Caminante, no hay camino, se hace camino al andar."
   -- Antonio Machado
   (Roughly: "Walker, there is no road. The road is made as you walk.")

Michael J. Pedersen wrote:

···

On Tue, May 02, 2006 at 09:55:48AM -0700, Don Dwiggins wrote:

A wiki page will allow those of us who feel similarly to collaborate, and maybe come up with something good. Besides, there's already a fair amount of material there that wouldn't be a bad start if there were a "main page" that pulls it all together (do a Text search for "xrc").

Actually, I'm thinking something more serious than that. There's
half-notes spread around, tech notes, quick little cheat sheet style
how-to's, etc. However, I want to see something more comprehensive, and
more professionally laid out. While not a book, I want to put together a
chapter of a book, or a better how-to type.

Wiki's are great, make no mistake, but what I've got in mind might not
fit so well with a wiki page. Though, I suppose, it could be many
screenfuls, table of contents... Okay, there's ideas. And I suppose I
could compromise.

You may be surprised how much you can do with a wiki page. I've been very impressed with the work going on with this one: http://wiki.wxpython.org/index.cgi/AnotherTutorial

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

Michael J. Pedersen wrote:

So, getting this well documented for both C++ and wxPython is going to
become one of my 3 major goals. Any preferred place for posting such
docs (remember, it's going to include C++ and wxPython)?

I see you've started a page in the wiki. For now, that's as fine a place as any.

···

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