import wx
DATA = [("0", "Zero"), ("1", "One"), ("2", "Two")]
class MainWindow(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.panel = wx.Panel(self)
self.list = wx.ListCtrl(self.panel, style=wx.LC_REPORT)
self.list.InsertColumn(0, "#")
self.list.InsertColumn(1, "Number")
for data in DATA:
self.list.Append((data[0], data[1]))
self.button = wx.Button(self.panel, label="Delete index 0")
self.button.Bind(wx.EVT_BUTTON, self.OnButton)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.list, 1, wx.ALL | wx.EXPAND, 5)
self.sizer.Add(self.button, 0, wx.ALL | wx.EXPAND, 5)
self.panel.SetSizerAndFit(self.sizer)
self.Show()
def OnButton(self, e):
self.list.DeleteItem(0)
if __name__ == "__main__":
app = wx.App(False)
win = MainWindow(None)
app.MainLoop()