configure_traits(kind='live') blocks execution

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

configure_traits(kind='live') blocks execution

Martin Gustafsson
Hello,

On my fresh install of the EPD 7.3.2, execution halts when I call object.configure_traits() even with the " kind='live' " argument. Before, when I used Python(x,y) on the same computer, the same code worked as I expected, i.e. the program continued past configure_traits() while the view was still open. In both cases, ETS was at version 2.4.0 and Python at 2.7, running on Windows XP. Do you have any ideas of what is going on?

Best wishes
Martin
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: configure_traits(kind='live') blocks execution

Pietro Berkes
Hi Martin,

in a Python application, configure_traits() is supposed to be blocking, if you need a non-blocking alternative you should use edit_traits().

Now, from your email, I infer that you are running the script from an IPython command line, is that correct? In that case, configure_traits() can be made non-blocking (for the command line) if you are starting IPython with the appropriate GUI thread.

If you are using wx, you need to start IPython with the command:

ipython --gui=wx

for Qt, use

ipython --gui=qt

It's likely that Python(x,y) set one of these as the default options.

Hope this helps,
Pietro


On Thu, Oct 18, 2012 at 12:30 AM, Martin Gustafsson <[hidden email]> wrote:
Hello,

On my fresh install of the EPD 7.3.2, execution halts when I call object.configure_traits() even with the " kind='live' " argument. Before, when I used Python(x,y) on the same computer, the same code worked as I expected, i.e. the program continued past configure_traits() while the view was still open. In both cases, ETS was at version 2.4.0 and Python at 2.7, running on Windows XP. Do you have any ideas of what is going on?

Best wishes
Martin
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



--
Pietro Berkes
Scientific software developer
Enthought UK



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: configure_traits(kind='live') blocks execution

Martin Gustafsson
Hello Pietro,

Thank you for your reply, I will use edit_traits() instead then. An old thread (https://mail.enthought.com/pipermail/enthought-dev/2011-August/029570.html) gave the impression that " kind='live' " should unblock execution. I thought I saw this also under non-I Python, but maybe that wasn't correct.

Best wishes
Martin



18 okt 2012 kl. 09.23 skrev Pietro Berkes:

> Hi Martin,
>
> in a Python application, configure_traits() is supposed to be blocking, if you need a non-blocking alternative you should use edit_traits().
>
> Now, from your email, I infer that you are running the script from an IPython command line, is that correct? In that case, configure_traits() can be made non-blocking (for the command line) if you are starting IPython with the appropriate GUI thread.
>
> If you are using wx, you need to start IPython with the command:
>
> ipython --gui=wx
>
> for Qt, use
>
> ipython --gui=qt
>
> It's likely that Python(x,y) set one of these as the default options.
>
> Hope this helps,
> Pietro
>
>
> On Thu, Oct 18, 2012 at 12:30 AM, Martin Gustafsson <[hidden email]> wrote:
> Hello,
>
> On my fresh install of the EPD 7.3.2, execution halts when I call object.configure_traits() even with the " kind='live' " argument. Before, when I used Python(x,y) on the same computer, the same code worked as I expected, i.e. the program continued past configure_traits() while the view was still open. In both cases, ETS was at version 2.4.0 and Python at 2.7, running on Windows XP. Do you have any ideas of what is going on?
>
> Best wishes
> Martin
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
>
>
> --
> Pietro Berkes
> Scientific software developer
> Enthought UK
>
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: configure_traits(kind='live') blocks execution

Robert Kern
On Thu, Oct 18, 2012 at 1:49 PM, Martin Gustafsson
<[hidden email]> wrote:
> Hello Pietro,
>
> Thank you for your reply, I will use edit_traits() instead then. An old thread (https://mail.enthought.com/pipermail/enthought-dev/2011-August/029570.html) gave the impression that " kind='live' " should unblock execution. I thought I saw this also under non-I Python, but maybe that wasn't correct.

There are two different reasons for things to block, depending on the
context. .configure_traits() is meant to start up the GUI event loop
and shut it down. It's the main entry point into the GUI, so it will
block the rest of the script until the GUI finishes. You should not
use .configure_traits() when the GUI is already running. When you
already have the GUI running, using .edit_traits(kind='modal') or
.edit_traits(kind='livemodal') blocks the current method by raising a
modal dialog and waiting until it closes before returning.
.edit_traits(kind='live') brings up a non-modal dialog and returns
immediately. The respondent in that thread made a mistake and answered
for the latter context rather than the former.

--
Robert Kern
Enthought
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: configure_traits(kind='live') blocks execution

Martin Gustafsson
Thank you Robert, that was helpful. I am not writing a monolithic application so much as a set of tools for acquiring data and scripting measurements in a lab. That means there won't generally be one GUI to rule them all, but various objects may pop up a window now and then as needed. Is there any reason not to use edit_traits() consistently in this case?

Best wishes
Martin Gustafsson


18 okt 2012 kl. 14.57 skrev Robert Kern:

> On Thu, Oct 18, 2012 at 1:49 PM, Martin Gustafsson
> <[hidden email]> wrote:
>> Hello Pietro,
>>
>> Thank you for your reply, I will use edit_traits() instead then. An old thread (https://mail.enthought.com/pipermail/enthought-dev/2011-August/029570.html) gave the impression that " kind='live' " should unblock execution. I thought I saw this also under non-I Python, but maybe that wasn't correct.
>
> There are two different reasons for things to block, depending on the
> context. .configure_traits() is meant to start up the GUI event loop
> and shut it down. It's the main entry point into the GUI, so it will
> block the rest of the script until the GUI finishes. You should not
> use .configure_traits() when the GUI is already running. When you
> already have the GUI running, using .edit_traits(kind='modal') or
> .edit_traits(kind='livemodal') blocks the current method by raising a
> modal dialog and waiting until it closes before returning.
> .edit_traits(kind='live') brings up a non-modal dialog and returns
> immediately. The respondent in that thread made a mistake and answered
> for the latter context rather than the former.
>
> --
> Robert Kern
> Enthought
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: configure_traits(kind='live') blocks execution

Robert Kern
On Mon, Oct 22, 2012 at 4:34 PM, Martin Gustafsson
<[hidden email]> wrote:
> Thank you Robert, that was helpful. I am not writing a monolithic application so much as a set of tools for acquiring data and scripting measurements in a lab. That means there won't generally be one GUI to rule them all, but various objects may pop up a window now and then as needed. Is there any reason not to use edit_traits() consistently in this case?

Use .edit_traits() in all of those places. If you have an `if __name__
== '__main__':` clause for an entry point, you should use
.configure_traits() there.

--
Robert Kern
Enthought
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev