I would like to know how to save a programs current settings so that it remains the same, unless specified otherwise, on program restart or computer restart. For example, windows default program sticky notes, where it saves the text, so that it can be used even after the computer is shut down.
Is there some sort of module that you can import? My program is basically a task list program, where you can add stuff to a list, and tick it off using wxPython check boxes. Is there any possible way to keep it's state even after program exit?
It would be appreciated if someone could show me an example with my code, and don't worry, I won't just simply copy it and be done with it. It will be considered a learning experience for me, so that I may use it in the future. Thanks.
Here is my program:
import wx, sys,os
mylist = []
class test(wx.Frame):
def __init__(self, parent, id):
self.count = 1
#Frame
wx.Frame.__init__(self,parent,id,'List',size = (200,500))
#Panel
self.panel = wx.Panel(self)
item = wx.TextEntryDialog(None, "List Title")
if item.ShowModal() == wx.ID_OK:
print 'here'
answer = item.GetValue()
mylist.append(answer)
print mylist
windtitle = wx.StaticText(self.panel, -1, answer, (10,10))
windtitle.SetForegroundColour("blue")
addButton = wx.Button(self.panel, label = "+ Add", pos=(40,450), size = (60,-1))
finishButton = wx.Button(self.panel, label = "Finish", pos=(110,450), size = (60,-1))
self.Bind(wx.EVT_BUTTON, self.addtomenu, addButton)
self.Bind(wx.EVT_BUTTON, self.finish, finishButton)
def finish(self, event):
self.Destroy()
sys.exit()
def addtomenu(self,event):
newitem = wx.TextEntryDialog(None, "New Item")
if newitem.ShowModal() == wx.ID_OK:
count = len(mylist)+1
print count
yaxis = 20*count
if count == 21:
wx.StaticText(self.panel, -1, "List To Full", (10, yaxis))
else:
answer = newitem.GetValue()
mylist.append(answer)
print mylist
self.Bind(wx.EVT_CLOSE, self.closewindow)
wx.CheckBox(self.panel, -1, answer, (10,yaxis), size = (200,-1))
def closewindow(self, event):
self.Destroy()
if __name__ == "__main__":
app=wx.PySimpleApp() #Blood
frame = test(parent=None, id = -1) #Skin
frame.Show()
app.MainLoop() #Heart