【问题标题】:Highlight Row wxgrid突出显示行 wxgrid
【发布时间】:2013-03-01 23:38:31
【问题描述】:

我一直在寻找一些解决方案,但我没有得到它。

当日期结束时,我想突出显示 wx.Grid 中的行。

有什么功能可以做到吗?

<i>        
def load_grid_fare (self, fares):
   for i, j, k in fares :
      self.grid_fare.SetCellValue(count_rows,0,str(i.fare_id))
        self.grid_fare.SetCellValue(count_rows,1,str(j.service_name).encode('utf8'))
        self.grid_fare.SetCellValue(count_rows,2,str(k.vehicle_type_name).encode('utf8'))
        self.grid_fare.SetCellValue(count_rows,3,str(i.fare_cash))
        self.grid_fare.SetCellValue(count_rows,4,str(i.fare_startdate.strftime("%d/%m/%Y")))
        self.grid_fare.SetCellValue(count_rows,5,str(i.fare_enddate.strftime("%d/%m/%Y")))
        count_rows += 1

【问题讨论】:

    标签: python model-view-controller grid wxpython


    【解决方案1】:

    您需要查看 wxPython 演示,它可以从 wxPython 网站下载。其中有几个示例展示了如何更改单元格、行或列的颜色。在演示中,它显示您需要创建一个 GridCellAttr() 对象并执行以下操作:

    attr = wx.grid.Grid.GridCellAttr()
    attr.SetBackgroundColour(wx.RED)
    self.SetRowAttr(5, attr)
    

    其中“self”指的是 wx.grid.Grid。上面的代码会将第 6 行的背景颜色设置为红色。

    【讨论】:

    • 谢谢,我在demo文件夹中搜索了一些代码,找到了解决办法
    猜你喜欢
    • 2017-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2012-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多