Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wxPython-UltimateListCtrl如何在选中项目时高亮显示行?_Python_Python 3.x_User Interface_Wxpython - Fatal编程技术网

wxPython-UltimateListCtrl如何在选中项目时高亮显示行?

wxPython-UltimateListCtrl如何在选中项目时高亮显示行?,python,python-3.x,user-interface,wxpython,Python,Python 3.x,User Interface,Wxpython,我在UltimateListCtrl中使用不同类型的小部件。我在某些情况下遇到的问题是,我需要用它们来填充列表中的大部分内容。这使得高亮显示一行非常烦人,因为如果单击小部件,该行不会高亮显示,因为焦点在小部件上 如何防止这种情况发生或将焦点传递到行/列表 以下是要使用的示例代码: import wx from wx.lib.agw import ultimatelistctrl as ULC class TestUltimateListCtrlPanel(wx.Panel): def

我在UltimateListCtrl中使用不同类型的小部件。我在某些情况下遇到的问题是,我需要用它们来填充列表中的大部分内容。这使得高亮显示一行非常烦人,因为如果单击小部件,该行不会高亮显示,因为焦点在小部件上

如何防止这种情况发生或将焦点传递到行/列表

以下是要使用的示例代码:

import wx
from wx.lib.agw import ultimatelistctrl as ULC

class TestUltimateListCtrlPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS, size=(640,300))

        self.list_ctrl = ULC.UltimateListCtrl(self, -1, agwStyle=ULC.ULC_REPORT|ULC.ULC_HAS_VARIABLE_ROW_HEIGHT)
        self.list_ctrl.InsertColumn(0, "Make")
        self.list_ctrl.InsertColumn(1, "Model")
        self.list_ctrl.InsertColumn(2, "Year")
        self.list_ctrl.InsertColumn(3, "Color")

        rows = [("Ford", "Taurus", "1996", "Blue"),
                ("Nissan", "370Z", "2010", "Green"),
                ("Porche", "911", "2009", "Red")
                ]

        for rowIndex, data in enumerate(rows):
            for colIndex, coldata in enumerate(data):
                if colIndex == 0:
                    self.list_ctrl.InsertStringItem(rowIndex, coldata)
                else:
                     self.tab_st = wx.StaticText(self.list_ctrl, label=coldata)            
                     self.list_ctrl.SetItemWindow(rowIndex, colIndex, self.tab_st, expand=True)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.list_ctrl, 1, wx.ALL|wx.EXPAND, 5)
        self.SetSizer(sizer)


class MyForm(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,wx.ID_ANY,size=(640,300),style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)
        panel = TestUltimateListCtrlPanel(self)

if __name__ == "__main__":
    app = wx.App(False)
    frame = MyForm()
    frame.Show()
    app.MainLoop()