给定一个简单的wx.grid.Grid和wx.grid.GridCellChoiceEditor作为默认单元格编辑器。现在尝试在网格中向下滚动并在空单元格上开始编辑。现在,如果单元格有值,一切都会好起来的。但是,当单元格为空时,组合框的textcrlt将绘制在错误的位置。似乎垂直滚动偏移量被减去两次。Source code for sample app。在
def __init__(...):
# ...
self.grid1.Bind(wx.grid.EVT_GRID_EDITOR_CREATED, self.editor_created)
self.grid1.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.editor_shown)
def editor_created(self, event):
self.control = event.GetControl()
event.Skip()
def editor_shown(self, event):
cursor = event.Row, event.Col
value = self.grid1.GetCellValue(*cursor)
if not value:
self.grid1.SetCellValue(cursor[0], cursor[1], ' ')
def unfix():
self.control.SetValue(value)
self.control.Popup()
# @todo should set the cell value back to empty value here,
# but that triggers the bug again.
wx.CallAfter(unfix)
event.Skip()
作为一种解决方法,我现在设置一个非空值,当编辑器即将显示时。使用
wx.CallAfter
我再次将值设置为空,这样用户就不会注意到任何东西。但是,网格中的值将保持非空值(空格),因为在回调中更改它将触发不正确的重新呈现。在以及工作示例的source code。在
相关问题 更多 >
编程相关推荐