I have been having this problem for a while (and not thought about it for even longer). However what quickly comes to mind is to thread/idle_add your sleep. I havent tested this as such, but you are getting into threading/execution problems on different program layers (the dialog is C++ code and the script is the python layer - run from C++ - and usually only one of this runs; it's tricky). So maybe try somethign along the lines:

import gobject
def idle_func():
        sleep(10)
gobject.idle_add(idle_func)

(Python scripting option verendus est)

In python script, it appears that show_select_map_dialog simply shows
the dialog and quits.  I am trying to set up a method that would do
certain things depending on the choice of map.  So I use
show_select_map_dialog, but it appears that it does not wait until user
makes a choice there.  I tried to put a sleep cycle for 10 seconds that
would keep checking if map selection changed, but the dialog does not
show until the cycle is over.  Is there any way to show the dialog and
then wait for user to make selection?

Here is the version of the code that shows the dialog but then proceeds
further without waiting for selection

---
     show_select_map_dialog()
     imodel = (imol_refinement_map() - shknum)/2
     highlight_model(imodel)
---

Her is the code with sleep-cycle.  This one only shows the map selection
dialog after 10 seconds (something equivalent to yield function in wx is
needed)

---
     from time import sleep
     imap = imol_refinement_map()
     show_select_map_dialog()
     for i in range(10):
         if imap != imol_refinement_map():
             break
         sleep(1)
     imodel = (imol_refinement_map() - shknum)/2
     highlight_model(imodel)

---



--
***************************************************

Dr. Bernhard Lohkamp
Assistant Professor
Div. Molecular Structural Biology
Dept. of Medical Biochemistry and Biophysics (MBB)
Karolinska Institutet
S-17177 Stockholm
Sweden

phone: (+46) 08-52487651
fax:   (+46) 08-327626
email: bernhard.lohk...@ki.se

Reply via email to