continuous plotting with Tkinter

M

Martin Blume

I have a number-crunching application that spits out
a lot of numbers. Now I'd like to pipe this into a python
app and plot them using Tkinter, such as:
$ number_cruncher | myplot.py
But with Tkinter once I call Tkinter's mainloop() I
give up my control of the app and I can't continue to
read in data from stdin. Or can I? If so, how?

Regards
Martin
 
D

David Douard

Martin said:
I have a number-crunching application that spits out
a lot of numbers. Now I'd like to pipe this into a python
app and plot them using Tkinter, such as:
$ number_cruncher | myplot.py
But with Tkinter once I call Tkinter's mainloop() I
give up my control of the app and I can't continue to
read in data from stdin. Or can I? If so, how?

Regards
Martin

Maybe the simpler is to run the Tk mainloop in a separate thread.
You may have a look a candygram which gives a very simple to use
multi-thread semantics (ala Haskell) and is simpler to use than the
threading module.
 
R

Russell E. Owen

"Martin Blume said:
I have a number-crunching application that spits out
a lot of numbers. Now I'd like to pipe this into a python
app and plot them using Tkinter, such as:
$ number_cruncher | myplot.py
But with Tkinter once I call Tkinter's mainloop() I
give up my control of the app and I can't continue to
read in data from stdin. Or can I? If so, how?

One way is to use a thread to read the numbers, then make them available
to the main thread via a Queue object, which you poll for new values.

Another option is to use a Tk-compatible file or socket of some kind
which triggers a callback when data comes in. See
<http://www.astro.washington.edu/rowen/TkinterSummary.html#FileHandlers>
some ideas on this.

-- Russell
 
M

Martin Blume

One way is to use a thread to read the numbers, then
make them available to the main thread via a Queue
object, which you poll for new values.
I already tinkered with threads, yet it didn't work.
I'll try again.
Another option is to use a Tk-compatible file or socket
of some kind which triggers a callback when data comes
in. See

htttp://www.astro.washington.edu/rowen/TkinterSummary.html#FileHand lers>

some ideas on this.
Thanks, I'll look.

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top