[wxPython] reparenting nodes in wxTreeCtrl

Is it possible to reparent a node in a wxTreeCtrl?

e.g., I have:

a

-b

-c

  >-d

... and I want to move c from under a to under b, resulting in:

a

···

-b

  >-c
    >-d

I currently have implemented setting up a static bitmap image in my program
and it works just fine. This requires me to have a file in the program's
directory to work. It works fine but I would like to eliminate the external
file, keeping the image data within the program itself.

After messing around a bit I have finally managed to come up with a way to
store the image data in a string. Now I would like to use it but I've hit a
bit of a roadblock in that I have not found any useful way to import that
data into a wxImage or wxBitmap (either would do). While both classes
support input from streams, neither appears to be implemented in wxPython
(according to the docs).

My proposed way of getting the data:

t = base64.decodestring(LogoData)
# I used the base64 module to create the data. pickle didn't cut it.

# at this point 't' contains the binary data of my logo in gif form

s = wxMemoryInputStream(t, len(t))
# access the data as a memory stream

bmp = wxImage(s, wxBITMAP_TYPE_ANY).ConvertToBitmap()

logo = wxStaticBitmap(self, -1, bmp)

This, of course, does not work.

It's a shame that we can't just pass an open file handle, as then I could
use StringIO.StringIO() to 'read' the 'file'.

I'm reasearching further, but any pointers would be appreciated.

AdTHANKSvance

There is utility in wxPythons tool dir.

HTH
Niki Spahiev

After messing around a bit I have finally managed to come up with a way to
store the image data in a string.

Take a look at the tools/img2py.py script, and how it's output is used in
the demo in demo/images.py. I have plans to improve this, and also to
support loading from streams into wxImage, but img2py does work today and
will solve your problem.

···

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

Is it possible to reparent a node in a wxTreeCtrl?

e.g., I have:

a
>-b
>
>-c
  >-d

... and I want to move c from under a to under b, resulting in:

a
>-b
  >-c
    >-d

It's been talked about before but I don't think anything has been added to
the wxTreeCtrl to allow this. You'll have to copy/delete the items
yourself.

···

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

There is utility in wxPythons tool dir.

I think I see the one you're talking about. Thanks!

Take a look at the tools/img2py.py script, and how it's output is used in
the demo in demo/images.py. I have plans to improve this, and also to
support loading from streams into wxImage, but img2py does work today and
will solve your problem.

Thanks, I had begun to suspect as much. Looking forward to future
enhancements; I may look into that myself if I can get up to speed...