如何在wxpythonlistbox中以编程方式更改突出显示的文本

2024-10-04 11:34:41 发布

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

我不能真正解释我的意思,所以我要用html来显示它

var c = 0; function getSong() { if (c>=3) { c=0 } c++; if (c==1) { document.getElementById("3").style.backgroundColor = "white"; } document.getElementById(""+c-1).style.backgroundColor = "white"; document.getElementById(""+c).style.backgroundColor = "blue"; } window.setInterval(function() {getSong()}, 2000);
<div id="0">Song Change Automatic Change In ListBox</div>
<div style="border: 1px black solid; height: 150px; width: 100px;">
    <p id="1" style="border: 1px black solid; width: 100px;">Song 1</p>
    <p id="2" style="border: 1px black solid; width: 100px;">Song 2</p>
    <p id="3" style="border: 1px black solid; width: 100px;">Song 3</p>
</div>

div表示列表框song 1/song 3表示歌曲更改并在完成后突出显示下一首歌曲。在wxPython这可能吗?你知道吗


Tags: dividifsongstylefunctionwidthdocument
1条回答
网友
1楼 · 发布于 2024-10-04 11:34:41

不是使用ListBox而是可以使用ListCtrl更改项属性。它允许您为列表控件中的项设置wx.ListItemAttr,并且在attr对象中可以设置fg、bg颜色和字体等内容。如果您使用wx.LC_REPORTwx.LC_NO_HEADER样式,那么它看起来和大部分行为都像ListBox。你知道吗

相关问题 更多 >