Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'read.': 0.03; 'receives': 0.04; 'mrab': 0.05; 'say,': 0.05; 'front-end': 0.07; 'processing.': 0.07; 'back-end': 0.09; 'formatting': 0.09; 'mvc': 0.09; 'restarted': 0.09; 'gui': 0.12; 'background.': 0.14; 'thread': 0.14; '(both': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'module).': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reload': 0.16; 'subject:GUI': 0.16; 'subject:program': 0.16; 'switches': 0.16; 'thread?': 0.16; 'using,': 0.16; 'wherein': 0.16; 'wxpython': 0.16; 'subject:python': 0.16; '(you': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'entered': 0.20; 'starts': 0.20; 'help.': 0.21; 'load': 0.23; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'tells': 0.24; 'url:moin': 0.24; 'this:': 0.26; 'pass': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'subject:) ': 0.29; "i'm": 0.30; 'that.': 0.31; 'url:wiki': 0.31; 'bunch': 0.31; 'cells': 0.31; 'coded': 0.31; 'terminate': 0.31; 'file': 0.32; 'thanks!': 0.32; 'run': 0.32; 'url:python': 0.33; 'running': 0.33; 'monday,': 0.33; 'could': 0.34; 'subject: (': 0.35; 'info': 0.35; 'received:84': 0.35; 'but': 0.35; 'there': 0.35; 'idle': 0.36; 'in.': 0.36; 'machine.': 0.36; 'module.': 0.36; 'doing': 0.36; 'next': 0.36; 'method': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'checks': 0.38; 'gmail': 0.38; 'saves': 0.38; 'window': 0.38; 'handle': 0.38; 'to:addr:python- list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'up,': 0.60; 'march': 0.61; "you're": 0.61; 'save': 0.62; 'complete': 0.62; 'making': 0.63; 'information': 0.63; 'great': 0.65; 'between': 0.67; 'hang': 0.67; 'anything.': 0.68; 'design.': 0.68; 'badly,': 0.84; 'closes': 0.84; 'detecting': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=JLW1sq6b c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=sASEtNAQL0YA:10 a=7Usbitdrwi0A:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=2N-kP4VV5KevtA5nPPkA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett:2500 Date: Tue, 04 Mar 2014 13:19:54 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Idle thread (Polling) python GUI and saving program state References: <4034b33f-0cb6-46fa-931c-450834c98d6e@googlegroups.com> In-Reply-To: <4034b33f-0cb6-46fa-931c-450834c98d6e@googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393939197 news.xs4all.nl 2875 [2001:888:2000:d::a6]:46808 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67673 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.