【问题标题】:Word wrapping in a ListCtrl (or ObjectListView)ListCtrl(或 ObjectListView)中的自动换行
【发布时间】:2011-01-19 09:24:55
【问题描述】:

我有一个 wxListCtrl(实际上是一个ObjectListView),用 LC_REPORT 设置了两列。

是否可以在第一列文本到达列尾时自动换行?

【问题讨论】:

    标签: python wxpython wxwidgets word-wrap objectlistview


    【解决方案1】:

    使用 ObjectListView 是不可能的(请参阅他们的 FAQ),因为 ListCtrl 不支持多行条目。

    但是,可以使用 UltimateListCtrl

    import wx
    from wx.lib.wordwrap import wordwrap
    import wx.lib.agw.ultimatelistctrl as ULC   
    
    class Frame(wx.Frame):
        def __init__(self, *args, **kw):
            wx.Frame.__init__(self, *args, **kw)
    
            self.list = ULC.UltimateListCtrl(self, agwStyle=ULC.ULC_REPORT|ULC.ULC_HAS_VARIABLE_ROW_HEIGHT)
            items = ['A', 'b', 'a really really long line that if would be nice if it could word-wrap']
            colWidth = 100
            self.list.InsertColumn(0, "AA", width=colWidth)
            for item in items:
                item = wordwrap(item, colWidth, wx.ClientDC(self))
                self.list.InsertStringItem(0, item)
    
    app = wx.App(False)
    frm = Frame(None, title="ULC wordwrap test")
    frm.Show()
    app.MainLoop()
    

    【讨论】:

      【解决方案2】:

      wxListCtrl 的功能相当有限。为了做比基本更多的事情,您应该考虑“升级”到具有丰富功能的 wxGrid。

      【讨论】:

      • 我目前正在使用 ObjectListView,它是一个 ListCtrl,并且已经实现。所以我需要包装这个对象。如果我“升级”到 wxGrid,它将如何转换? wxGrid 的行为方式是否与 OLV 相同? (获取对象列表)
      • 什么是'ObjectListView"?这个名字看起来不像wxWidgets中的东西。
      • 我的问题中有一个链接。它包装了 wxListView。
      猜你喜欢
      • 1970-01-01
      • 2013-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-18
      • 1970-01-01
      相关资源
      最近更新 更多