Hello everyone. My question is how can we save the items on listctrl so everytime someone opens the application, the items previously added are there.

I'm trying to accomplish this with wx.Config, but I can't seem to find a good way to read the config so it accomplishes what I need.

So my question is how to write/read the wx.Config so everytime someone launches the app, it will appear the items previously added by the user.

Note: I know the basics of reading/writing in wx.Config but I can't seem to get this thing right.

Any help is appreciated, thanks.

7 Years
Discussion Span
Last Post by Paul Thompson

I have no experience with wx.Config so i can't help you there, but there is a way you could do this without that and just using a file.

#... inside your frame/panel class

    def LoadCtrl(self):
        #Assuming listctrl is called listOne
        #and the file is fileOne

        f = open(fileOne)
        for item in fileOne:

    def SaveCtrl(self):
        f = open(fileOne, "w")

        #Loop through and save each item on its own line
        for itemIndex in listOne.GetItemCount():
            f.write(str(listOne.GetItemText(itemIndex) + "\n"))

That demonstrates my idea, if you want to implement that it shouldn't be too hard :)

hope that helps :)

Edited by Paul Thompson: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.