【问题标题】:wxGrid bind a single cell to eventwxGrid 将单个单元格绑定到事件
【发布时间】:2011-09-03 16:02:05
【问题描述】:

我正在尝试执行以下操作:

cell = self.grid.SetCellValue(0, 0, "test")  # Where grid is the instance of wx.grid
                                             # and self is a wx.panel instance
self.grid.Bind(EVT_GRID_CELL_LEFT_CLICK, self.on_left_click, cell)

这是我尝试将单击单元格 (0, 0) 的事件绑定到 self.on_left_click()。

但是在左键单击的情况下,此方法将所有单元格绑定到此事件。 有没有办法只绑定单元格 (0, 0) 而没有其他单元格?

【问题讨论】:

    标签: events binding grid wxpython


    【解决方案1】:

    更简单的解决方案可能是在事件处理程序中检查事件的行和列,并仅在事件来自单元格 (0,0) 时执行您的操作:

    def on_left_click(self, evt):
        if evt.GetRow() == 0 and evt.GetCol() == 0:
            #do stuff
        evt.Skip()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      相关资源
      最近更新 更多