[wxPython] wxTreeCtrl::SetItemImage ? äääks !

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] wxTreeCtrl::SetItemImage ? äääks !

Simo Haapakka
first some backround :
OS = RedHat 6.0
when I first installed wxPython-2.1b3-1.i386.rpm
running demo.py gave following list:

Traceback (innermost last):
  File "./demo.py", line 3, in ?
    import Main
  File "/usr/lib/python1.5/site-packages/wxPython/demo/Main.py", line
15, in ?
    from   wxPython.wx import *
  File "/usr/lib/python1.5/site-packages/wxPython/__init__.py", line 16,
in ?
    import wxc
ImportError: /usr/lib/python1.5/site-packages/wxPython/wxcmodule.so:
undefined symbol: __pure_virtual

but after downloading sources and ...
demo started to work except :
    - wxDirDialog :        known
    - wxSlider :              is very very small
    - PrintFramework :  segfaults if trying to print to file or printer

my packages :
rpm -qa | egrep -e "python.*" -e "wx.*" -e "gtk.*" :

gtk+10-1.0.6-5
gtk+-1.2.1-10
pythonlib-1.22-5
python-_tkinter-1.5.2-2
postgresql-python-6.5-1
python-numpy-signaltools-0.5-2
wxGTK-2.1.0-9
python-imaging-_tkinter-1.0b1-3
python-zlib-1.5.2-2
python-scientific-1.0-3
python-mxTextTools-1.0.2-4
gtk+-devel-1.2.1-10
gtk-engines-0.5-16
python-demos-1.5.2-2
python-docs-1.5.1-10
python-1.5.2-2
pygtk-0.5.12-2
python-devel-1.5.2-2
python-tkinter-1.5.2-2
python-imaging-1.0b1-3
python-opengl-1.5.5-2
python-numpy-1.11-2
python-xml-0.5.1-2
wxGTK-devel-2.1.0-9
wxPython-2.1b3-1

and the problem
what's wrong with following code ( items bounds change but NO image )
--------------------------------------------------------------
#!/usr/bin/env python
from wxPython.wx import *

class testFrame(wxFrame):
    def __init__(self, title):
        wxFrame.__init__(self, None, -1, title,
                         wxDefaultPosition, wxSize(600, 480))

        self.tree = wxTreeCtrl(self, NewId(), wxDefaultPosition,
                               wxDefaultSize,
                               wxTR_HAS_BUTTONS)

        self.bmp1 = wxImage('1.gif',
                      wxBITMAP_TYPE_GIF).ConvertToBitmap()
        if self.bmp1.Ok() != true: raise "Error loading bitmap"
        self.bmp2 = wxImage('2.gif',
                      wxBITMAP_TYPE_GIF).ConvertToBitmap()
        if self.bmp2.Ok() != true: raise "Error loading bitmap"

##         wxImageList::wxImageList
##         wxImageList()
##         Default constructor. ??
##         wxImageList(int width, int height, const bool mask = TRUE,
int initialCount = 1)
        self.imgList = wxImageList(32,32,true,2)

##         wxImageList::Add
##         int Add(const wxBitmap& bitmap, const wxBitmap& mask =
wxNullBitmap) ??
        idx = self.imgList.Add(self.bmp1)
        idx2 = self.imgList.Add(self.bmp2)

        self.root = self.tree.AddRoot("testing...")
        child = self.tree.AppendItem(self.root, "First")

        self.tree.SetImageList(self.imgList)
        print 'ImageList: img count
',self.tree.GetImageList().GetImageCount()

##         wxTreeCtrl::SetItemImage
##         void SetItemImage(const wxTreeItemId& item, int image)

        self.tree.SetItemImage(child,idx)
        self.tree.SetItemSelectedImage(child,idx2)

class MyApp(wxApp):
    def OnInit(self):
        wxImage_AddHandler(wxGIFHandler())

        frame = testFrame("wxTreeCtrl test")
        frame.Show(true)
        self.SetTopWindow(frame)

        return true

app = MyApp(0)
app.MainLoop()



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users