Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #67625

Re: Idle thread (Polling) python GUI and saving program state

Date 2014-03-04 02:06 +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>
Newsgroups comp.lang.python
Message-ID <mailman.7683.1393898784.18130.python-list@python.org> (permalink)

Show all headers | View raw


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).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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