kernwin.i: Title is now correctly displayed

kernwin.i: Chooser properly lists non-string items also
This commit is contained in:
gergely.erdelyi 2008-12-10 11:30:58 +00:00
parent ca5ed24ff0
commit 97213fabb4

View File

@ -204,23 +204,25 @@ ulong choose_choose(void *self,
} }
return choose( return choose(
flags, // various flags: see above for description flags,
x0, y0, // x0=-1 for autoposition x0, y0,
x1, y1, x1, y1,
self, // object to show self,
width, // Max width of lines width,
&choose_sizer, // Number of items &choose_sizer,
&choose_getl, // Description of n-th item (1..n) &choose_getl,
// 0-th item if header line
title ? title : deftitle, title ? title : deftitle,
1, 1,
1, 1,
NULL, NULL, /* del */
NULL, NULL, /* inst */
NULL, NULL, /* update */
NULL, NULL, /* edit */
&choose_enter &choose_enter,
); // number of the default icon to display NULL, /* destroy */
NULL, /* popup_names */
NULL /* get_icon */
);
} }
%} %}
@ -251,8 +253,10 @@ class Choose:
""" """
Callback: getl - get one item from the list Callback: getl - get one item from the list
""" """
if n <= len(self.list): if n == 0:
return self.list[n-1] return self.title
if n <= self.sizer():
return str(self.list[n-1])
else: else:
return "<Empty>" return "<Empty>"