acm
2014-03-11 01:47:34 UTC
I'm designing a GUI application using wxPython and a sample version looks
like:
[image: Inline image 1]
*Note: A cell in my case is a collection of the cellnumber (the integer on
top left), variable 1 and variable 2*
I have designed this with MVC in mind. I have coded up the model as a state
machine. The user enters the cellnumber and the variable 1. This is passed
on to the model via an idle thread and that kicks off the state machine
which does the processing and returns the result.
*The following is a snippet of the model:*
class Infoaboutcell(): #This has all the information about each cell like
(cell number, variable 1 , variable 2 etc)
def __init__(self, cellNumber):
self.cellNo = cellNumber
self.variable1 = ""
....
def poll()
statemachine[state](cellnumber, variable1) #statemachine is a
dictionary with a state to function mapping and the functions are
#independent (do not belong to any
class)
class Model(): #this creates a list of all the cells
listofcells = []
for i in some range:
listofcells.append(infoaboutcell(i))
def function1(cellnumber, variable1):...
def function2(cellnumber, variable1): ...
*In the controller I have the following:*
class controller(Thread):
def __init__(self):
Thread.__init__(self)
self.start()
def run(self):
for i in Model.listofcells:
i.poll()
My question is how do I save the state and recover. For example, some
processes take a long time to get over and if accidentally someone closes
the app, when someone turns the app back up again, I want to start from
where I left off. In the sense, the state machine should resume the state
and the display should also go back to what it was before the exit and
continue from there. I tried checking the return value of the function and
based on that I pickled the class model (class Model()).
Can someone let me know how to do this? How do I save program state and
restore?
like:
[image: Inline image 1]
*Note: A cell in my case is a collection of the cellnumber (the integer on
top left), variable 1 and variable 2*
I have designed this with MVC in mind. I have coded up the model as a state
machine. The user enters the cellnumber and the variable 1. This is passed
on to the model via an idle thread and that kicks off the state machine
which does the processing and returns the result.
*The following is a snippet of the model:*
class Infoaboutcell(): #This has all the information about each cell like
(cell number, variable 1 , variable 2 etc)
def __init__(self, cellNumber):
self.cellNo = cellNumber
self.variable1 = ""
....
def poll()
statemachine[state](cellnumber, variable1) #statemachine is a
dictionary with a state to function mapping and the functions are
#independent (do not belong to any
class)
class Model(): #this creates a list of all the cells
listofcells = []
for i in some range:
listofcells.append(infoaboutcell(i))
def function1(cellnumber, variable1):...
def function2(cellnumber, variable1): ...
*In the controller I have the following:*
class controller(Thread):
def __init__(self):
Thread.__init__(self)
self.start()
def run(self):
for i in Model.listofcells:
i.poll()
My question is how do I save the state and recover. For example, some
processes take a long time to get over and if accidentally someone closes
the app, when someone turns the app back up again, I want to start from
where I left off. In the sense, the state machine should resume the state
and the display should also go back to what it was before the exit and
continue from there. I tried checking the return value of the function and
based on that I pickled the class model (class Model()).
Can someone let me know how to do this? How do I save program state and
restore?
--
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.