See the attached sample program. I include a BMP file which is used by it.
Put the two in the same directory and then run "python tree.py -d". This is
what you get if you *don't* specify the wxTR_HAS_BUTTONS style - notice that
the root has a little '+' next to it, to expand it, and an icon as well.
Now run "python tree.py" (no -d). This is the same, but with
wxTR_HAS_BUTTONS specified. Now, the little '+' has gone!
While I'm happy enough that I can get both behaviours depending on the style
I set, the reality differs from the documentation, which says
"""
wxTR_HAS_BUTTONS Use this style to show + and - buttons to the left of
parent items. Win32 only.
"""
This seems to be the exact opposite of what I am seeing...
Is this just a documentation bug? (I'm running Python 2.1, wxPython 2.3.1,
on Windows 2000, BTW).
Paul.
------ Tree.py ------
#!/usr/bin/env python
from wxPython.wx import *
import sys
class MyFrame(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, -1, title,
size = (800, 600),
style=wxDEFAULT_FRAME_STYLE |
wxNO_FULL_REPAINT_ON_RESIZE)
# Build the tree view
if '-d' in sys.argv:
tree = wxTreeCtrl(self, -1)
else:
tree = wxTreeCtrl(self, -1,
style = wxTR_HAS_BUTTONS)
il = wxImageList(16, 16)
im = il.Add(wxBitmap("explorer.bmp",
wxBITMAP_TYPE_BMP))
tree.AssignImageList(il)
root = tree.AddRoot("Root", im)
for i in xrange(10):
tree.AppendItem(root, "Item %d" % i, im)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(None, -1, "Test")
self.SetTopWindow(frame)
frame.Show(true)
return true
def main():
app = MyApp(0)
app.MainLoop()
if __name__ == '__main__':
main()
explorer.bmp (1.32 KB)