This is the code again:
self.list = wxListCtrl(self, tID,
style=wxLC_REPORT|wxSUNKEN_BORDER)#|wxLC_VRULES|wxLC_HRULES)
if 0:
self.list.InsertColumn(0, "ID")
self.list.InsertColumn(1, "Name",
wxLIST_FORMAT_CENTER)
else:
info = wxListItem()
info.m_mask = wxLIST_MASK_TEXT |
wxLIST_MASK_FORMAT
info.m_format = 0
info.m_text = "ID"
self.list.InsertColumnInfo(0, info)
info.m_format = wxLIST_FORMAT_CENTER
info.m_text = "Name"
self.list.InsertColumnInfo(1, info)
total = len(self.Kueri())
grade = self.Kueri()
for sum_of_data in range(total):
self.list.SetStringItem(sum_of_data, 0,
grade[sum_of_data][0])
self.list.SetStringItem(sum_of_data, 1,
grade[sum_of_data][1])
def Kueri(self):
s = odbc.odbc('mysql/user/passwd')
cur = s.cursor()
cur.execute('select * from user')
rec = cur.fetchall()
return rec
I took this code from the demo of wxListCtrl & it
didn;t say anything about InsertStringItem before
SetStringItem. I don't know if the
grade[sum_of_data][0]
type is string or else I just know that it was the
data taken from the database (def Kueri()).
M. Danu F.
--- Robin Dunn <robin@alldunn.com> wrote: > >
> This is the code:
> for sum_of_data in range(total):
>
>
self.list.SetStringItem(sum_of_data,0,grade[sum_of_data][0])
>
>
self.list.SetStringItem(sum_of_data,1,grade[sum_of_data][1])
>
> When running this codes I got Error:
>
> TypeError: String or Unicode type nedded
>
Well, what is the type of "grade[sum_of_data][0]" ?
If it's not a string
then you need to convert it to one before calling
the method.
BTW, The first column of each item in a list ctrl
needs to be created with
InsertStringItem. You can then use SetStringItem
for the remaining columns
of the item. See the demo for an example.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax
with wxPython!
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
···
__________________________________________________
Do You Yahoo!?
Yahoo! Tech - Get in touch with the latest in technology.