Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67673
| Date | 2014-03-04 13:19 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Idle thread (Polling) python GUI and saving program state |
| References | <da3d9fc2-91a9-4fd4-a7b9-7c3825e2ca65@googlegroups.com> <mailman.7683.1393898784.18130.python-list@python.org> <4034b33f-0cb6-46fa-931c-450834c98d6e@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7710.1393939197.18130.python-list@python.org> (permalink) |
On 2014-03-04 02:41, Rolando wrote:> On Monday, March 3, 2014 6:06:22 PM UTC-8, MRAB wrote: >> On 2014-03-04 01:33, Rolando wrote: >> > I have a GUI with a bunch of cells which is my "View" in the MVC >> > design. The user enters some information in the view and I pass >> > this on to the model so that using the information entered by >> > the user it(model) can do some processing. >> > >> > I have coded up my model as a state machine. Wherein, once a >> > function is complete it switches to the next state and so on. >> > >> > I want to know how do I save the program state between restarts. >> > Basically, I'm trying to handle a scenario wherein if someone >> > closes the program. The next time someone starts it up, it >> > should start from where it left off (both the view and model) >> > >> When the user closes the window (you don't say what you're using for >> the GUI, but there should be a way of detecting when window closes), >> save the necessary info to a file using, say, the 'json' module. You >> can then reload the info from the file when the program is >< restarted. >> >> > Also, I want to setup a poll method where once in a while I can >> > poll each cell to know the state it is in. How do I do this? I >> > don't want my GUI to hang when I'm doing anything. It will be >> > great if someone could help. Thanks! >> > >> Can the model run continuously? If so, you should run it in its own >> (background) thread and the GUI in the main thread and communicate >> with the model's thread via, say, a queue (for that use the 'queue' >> module). > > I'm using wxPython for my GUI. I have tried running the model thread in the background. But how will I save the state if the whole model is running on a thread? When the program is restarted I want the program to continue from the same state where it left off for each cell. I was thinking of having an idle thread that calls a poll method which polls all the cells and checks what each one is doing. But, I don't know how to do that. I'm confused. > Please read this: https://wiki.python.org/moin/GoogleGroupsPython because Gmail is formatting your email badly, making it harder to read. When the front-end wants to quit, it tells the back-end and then waits for it to terminate before itself quitting. When the back-end receives the message that it should quit, it saves its state and terminates. When the front-end starts up again, it starts the back-end. When the back-end starts, it load the state and runs.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Idle thread (Polling) python GUI and saving program state Rolando <abhishek1899@gmail.com> - 2014-03-03 17:33 -0800
Re: Idle thread (Polling) python GUI and saving program state MRAB <python@mrabarnett.plus.com> - 2014-03-04 02:06 +0000
Re: Idle thread (Polling) python GUI and saving program state Rolando <abhishek1899@gmail.com> - 2014-03-03 18:41 -0800
Re: Idle thread (Polling) python GUI and saving program state MRAB <python@mrabarnett.plus.com> - 2014-03-04 13:19 +0000
csiph-web