使用Python wxWidgets中的字符串时的选项卡替代方法的wxlistbox

2024-10-01 13:32:58 发布

您现在位置:Python中文网/ 问答频道 /正文

如前所述:http://docs.wxwidgets.org/trunk/classwx_list_box.html

Notice that currently TAB characters in list box items text are not handled consistently under all platforms, so they should be replaced by spaces to display strings properly everywhere. The list box doesn't support any other control characters at all.

到目前为止,在Windows7中使用python2.7 32位代码时,在wxListBox选择的字符串中使用\t没有效果;正如预期的那样

我有一堆来自数据库的行,我有多个列,我想在wxListBox的一行中显示(并最终用于选择一行或多行)。现在,我使用推荐的空格作为字符串中值之间的分隔符。然而,这并不理想,因为列的长度是可变的。在

是否有一个不是简单分隔符的\t替代方法?这里的要点是将每行的所有列整齐地呈现出来,即

    column1        value1            value2
    column442142   values24234234    val2

而不是

^{pr2}$

wxGrid出现在我的脑海中,但我不认为这对我有用,因为我不想在一行中选择特定的单元格(我似乎找不到禁用它的函数),我只希望用户能够选择一行或多行。在


Tags: 字符串orgboxhttpdocshtmlalllist
2条回答
print "    4 whitespaces replace a tab"

print "%20s"%some_string_padded_to_20_chars

我的建议是使用wxListCtrl来显示简单的多列数据,如果您需要更多的特性,可以使用wxDataViewCtrl。在

FWIW您可以将wxGrid::SetSelectionMode()wxGridSelectRows参数一起使用来禁用单元格选择,但是wxGrid显然仍然不是用于此类操作的最佳控件。在

有关不同控件的简要摘要,请参见this slide from my lectures。在

相关问题 更多 >