Newbie problem with wxListCtrl
Frank P. Miles
fpmi at home.com
Sun Oct 15 00:44:20 EDT 2000
Hello all --
I'm trying to use wxPython for a database front-end project. Perhaps I
haven't
stared at the source code enough, but the documentation hasn't been
enough to get around
the basic problem of using wxListCtrl. Here's a simple bit of code:
<start of code>
#! /usr/bin/python
from wxPython.wx import *
class MyFrame(wxFrame):
def __init__(self, parent):
wxFrame.__init__(self, parent, -1, "test", size=(400, 200))
self.lc = wxListCtrl(self, -1, style =
wxLC_REPORT|wxSUNKEN_BORDER)
self.lc.InsertColumn(0, "Column 0 Long enough")
self.lc.InsertColumn(1, "B-Column Real long")
for i in range(10):
self.lc.SetStringItem(i, 0, "%d" % i)
self.lc.SetStringItem(i, 1, "boogers all!")
self.lc.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)
self.lc.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL)
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
<\end of code>
No data are printed, nor are the column headings of sufficient length.
I've tried this both under Linux and Win98, with the same result, so
it would seem that it's my code, not a system configuration problem.
The wxPython demo works fine in both. I've tried other insertion
methods
other than SetStringItem -- though perhaps not the 'right' one.
Any insights as to how to fix this -- or documentation that will clarify
my confusion would be appreciated!
-frank
More information about the Python-list
mailing list