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


Groups > comp.lang.python > #25795 > unrolled thread

Re: A thread import problem

Started byDieter Maurer <dieter@handshake.de>
First post2012-07-22 08:04 +0200
Last post2012-07-22 08:04 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: A thread import problem Dieter Maurer <dieter@handshake.de> - 2012-07-22 08:04 +0200

#25795 — Re: A thread import problem

FromDieter Maurer <dieter@handshake.de>
Date2012-07-22 08:04 +0200
SubjectRe: A thread import problem
Message-ID<mailman.2417.1342937096.4697.python-list@python.org>
Bruce Sherwood <bruce.sherwood@gmail.com> writes:

> Thanks much for this suggestion. I'm not sure I've correctly
> understood the operation "start_new_thread(lambda: __import__(<your
> module>), ())". By "your module" do you mean the user program which
> imported the module that will execute start_new_thread?

By "your_module", I meant what you have called "user.py" elsewhere
in this thread -- the thing that does the animation.

Of course, my suggestion implies that "visual.py" is somewhat changed.
It is supposed to no longer set up the GUI environment automatically
but do so only when its "setup_gui" function is called, and starting
the GUI main loop, too, is no longer automatic but explicite.

> It hadn't
> occurred to me to have A import B and B import A, though now that you
> describe this (if that's indeed what you mean) it makes sense.

I do not propose to do that -- it can lead to problems.

In my proposal, you have two modules: one the "main" module which
sets up the GUI environment, starts the animation in a separate thread
and then activate the GUI main loop. The second module contains
the code you have shown in a previous message.

Of course, the second module can be eliminated by putting its content
into a function and then calling this function in the "start_new_thread"
(instead of "lambda: __import__(...)").

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web