【问题标题】:wxPython: how to correcly select ListCtrl item?wxPython:如何正确选择 ListCtrl 项?
【发布时间】:2012-12-26 17:54:27
【问题描述】:

我的 Windows 8 上安装了带有 wxWidgets 2.8.11.0 的 python 2.7。如果我执行以下代码:

import wx

app = wx.App( redirect = False )
wnd = wx.Frame( parent = None )
widget = wx.ListCtrl( parent = wnd, style = wx.LC_REPORT )
widget.InsertColumn( 0, "items" )
widget.InsertStringItem( 0, "foo" )
widget.InsertStringItem( 1, "bar" )
widget.InsertStringItem( 2, "baz" )
widget.Select( 1 )
wnd.Show()
app.MainLoop()

我看到一个窗口,其中包含 3 个项目的列表,第二个被选中。但是如果我按下“向下”键 - first 项目被选中!是否可以选择项目,所以按“向上”和“向下”键将移动现有选择并且不会跳转到第一个项目?

【问题讨论】:

    标签: python wxpython wxwidgets


    【解决方案1】:

    同时使用Select(突出显示)和Focus(使该行成为当前行):

    ........
    widget.Focus(1)
    widget.Select(1)
    ..........
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-09
      • 1970-01-01
      • 1970-01-01
      • 2011-09-25
      • 1970-01-01
      • 1970-01-01
      • 2019-09-11
      • 1970-01-01
      相关资源
      最近更新 更多