I basically need to make the repeat button work.

I've tried several approaches but i've hit a brick wall and there doesn't seem to be a function I can find to get the values of the selected item and repeat them.

self.listctrl.GetItemString() will only get the string from item in the first column, and ideally I need to also be able to pick which column I would like the string from.

Does anyone either know how I can repeat the entire item or a GetString(row, column)type function because im straight out of ideas now.


import wx
from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin
import sys

class AutoWidthListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin):
    def __init__(self, parent):
        wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT)

class MyFrame(wx.Frame):

    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Quick Silver', size = (330, 500))

        panel = wx.Panel(self)

        self.listctrl = AutoWidthListCtrl(panel)
        self.listctrl.InsertColumn(0, "Item", width = 230)
        self.listctrl.InsertColumn(1, "Price")

        for x in range(1,15):

            index = self.listctrl.InsertStringItem(sys.maxint, str(x))
            self.listctrl.SetStringItem(index, 1, str(x))

        self.repbtn = wx.Button(panel, label = "Repeat Item")
        self.Bind(wx.EVT_BUTTON, self.RepeatItem, self.repbtn)
        self.delbtn = wx.Button(panel, label = "Delete Item")
        self.Bind(wx.EVT_BUTTON, self.RemoveItem, self.delbtn)

        specbtns = wx.BoxSizer()
        specbtns.Add(self.repbtn, 1, wx.EXPAND)
        specbtns.Add(self.delbtn, 1, wx.EXPAND)

        holder = wx.BoxSizer(wx.VERTICAL)
        holder.Add(self.listctrl, 7, flag = wx.EXPAND)
        holder.Add(specbtns, 1, flag = wx.EXPAND)

    def RemoveItem(self, event):


    def RepeatItem(self, event):


app = wx.App(redirect = False)
frame = MyFrame(parent = None, id = -1)

print self.listctrl.GetItem(6,2)


<wx._controls.ListItem; proxy of <Swig Object of type 'wxListItem *' at 0x2f0e3b0> >

am I using it wrong?

the answer is apparently to use .GetItem() then GetItemText so for example

x = self.listctrl.GetItem(6,2)
text = x.GetText()

but it just prints a blank line into the editor for me.