情報を含むテーブルを表示する wxListCtrl があります (行と列のフィールドを含む)。通常、行はマウス ボタンでクリックした場合にのみ強調表示されます。しかし、クリックせずにハイライトしたいと思います。つまり、マウスを別の行に移動すると、マウスをクリックしなくても行が強調表示されます。これは可能ですか?
########################################################################
インポート wx
インポート システム、グロブ
class MyForm(wx.Frame):
    #----------------------------------------------------------------------
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "List Control Tutorial")
        # Add a panel so it looks the correct on all platforms
        panel = wx.Panel(self, wx.ID_ANY)
        self.index = 0
    self.list_ctrl = wx.ListCtrl(panel, size=(-1,100),
                     style=wx.LC_REPORT
                     |wx.BORDER_SUNKEN
                     )
    self.list_ctrl.InsertColumn(0, 'Subject')
    self.list_ctrl.InsertColumn(1, 'Due')
    self.list_ctrl.InsertColumn(2, 'Location', width=125)
    self.list_ctrl.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
    self.list_ctrl.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)
    btn = wx.Button(panel, label="Add Line")
    btn.Bind(wx.EVT_BUTTON, self.add_line)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(self.list_ctrl, 0, wx.ALL|wx.EXPAND, 5)
    sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
    panel.SetSizer(sizer)   
    bmp = wx.Image("icon.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
    il = wx.ImageList(16,16)
    il.Add(bmp)
    self.list_ctrl.AssignImageList(il,wx.IMAGE_LIST_SMALL)      
    line = "Line %s" % self.index
    self.list_ctrl.InsertStringItem(self.index, line,-1)  
    self.list_ctrl.SetStringItem(self.index, 1, "01/19/2010")
    self.list_ctrl.SetStringItem(self.index, 2, "USA")
    self.index += 1     
    self.list_ctrl.InsertStringItem(self.index, line,-1)  
    self.list_ctrl.SetStringItem(self.index, 1, "01/19/2010")
    self.list_ctrl.SetStringItem(self.index, 2, "USA")
    #self.list_ctrl.SetItemBackgroundColour(self.index,wx.LIGHT_GREY)
    self.index += 1 
    self.list_ctrl.InsertStringItem(self.index, line,-1)  
    self.list_ctrl.SetStringItem(self.index, 1, "01/19/2010")
    self.list_ctrl.SetStringItem(self.index, 2, "USA")
    self.index += 1             
#----------------------------------------------------------------------
def add_line(self, event):
    if self.index > 0:
        image = 1
    else:
        image = -1    
    line = "Line %s" % self.index
    self.list_ctrl.InsertStringItem(self.index, line,image)
    self.list_ctrl.SetStringItem(self.index, 1, "01/19/2010")
    self.list_ctrl.SetStringItem(self.index, 2, "USA")
    self.index += 1
def onMouseOver(self, event):
    print "mouse over"
    for item in range(self.list_ctrl.GetItemCount()):
         self.list_ctrl.SetItemBackgroundColour(item,wx.NullColor)
    x = event.GetX()
    y = event.GetY()
    item, flags = self.list_ctrl.HitTest((x, y))
    self.list_ctrl.SetItemBackgroundColour(item,wx.RED)
    #self.list_ctrl.RefreshItems(0,2)
    event.Skip()
def onMouseLeave(self, event):
    print "mouse leave"
    for item in range(self.list_ctrl.GetItemCount()):
         self.list_ctrl.SetItemBackgroundColour(item,wx.NullColor)
    #self.list_ctrl.RefreshItems(0,2)
    event.Skip()
'''         
def onMouseOver(self, event):    #USED to display tooltip on items that cannot be selected
    x = event.GetX()
    y = event.GetY()
    item, flags = self.list_ctrl.HitTest((x, y))
    color = self.list_ctrl.GetItemBackgroundColour(item) 
    if color == wx.NullColor:
        self.list_ctrl.SetItemBackgroundColour(item,wx.RED)
    elif color == wx.RED:
        item = item - 1
        color = self.list_ctrl.GetItemBackgroundColour(item) 
        self.list_ctrl.SetItemBackgroundColour(item,wx.Nu)
'''       
#----------------------------------------------------------------------
# Run the program
if __name__ == "__main__":
    app = wx.App(False)
    frame = MyForm()
    frame.Show()
    app.MainLoop()