GUI programming, embedding, real time plots, etc.

  • Thread starter Madhusudan Singh
  • Start date
M

Madhusudan Singh

Hi

I am still a rookie at python (can do some basic programming with the
language), and have been using python gpib and matplotlib to control my
instruments and do real time plots. Since I have more than one instrument
to control, I was thinking of writing a GUI using Tkinter (looked at Page,
but it not have a debian package and I saw quite a few bugs listed -
Tkinter seems mature). I have some questions :

1. In using matplotlib (my code essentially involved creating a plot and
show()'ing it inside a loop), the color of the plot changed. Is there a way
to tell matplotlib to not treat each new invocation as a new plot, but to
really overwrite the old one ?

2. Is it possible to embed the matplotlib o/p in the o/p GUI ?

3. Are there some other caveats that I should be aware of in using
matplotlib ?
 
N

nephish

apt-get install python-pwm
this will get you python mega widgets
one of the dependencies that apt will take care of for you is the
python2.whatever-tk.
depending on which version of debian you are using.
i run sarge with python 2.3
 
M

Madhusudan Singh

apt-get install python-pwm
this will get you python mega widgets
one of the dependencies that apt will take care of for you is the
python2.whatever-tk.
depending on which version of debian you are using.
i run sarge with python 2.3

Thanks for the help.

I tried to write a piece of code to plot some simulated data from a
measurement :

from Tkinter import *
import Pmw

steps=(0,)
voltages=(0,)

master=Tk()
plot=Pmw.Blt.Graph(master)
plot.pack(expand=1,fill='both')

for i in range(1,10):
steps=steps+(i,)
setvolt=1.0*i/100
voltages=voltages+(setvolt,)
plot.line_create("Plot",xdata=steps,ydata=voltages)


master.mainloop()

This quits with :

Traceback (most recent call last):
File "<stdin>", line 15, in ?
File "/usr/lib/python2.3/site-packages/Pmw/Pmw_1_2/lib/PmwBlt.py", line
266, in line_create
self.tk.call((self._w, 'line', 'create', name) + self._options(kw))
_tkinter.TclError: element "Plot" already exists in ".-1222950836"

Now, if I try to plot from outside the loop (move the last statement in the
loop out of it), it plots ok. I need to plot this in realtime. So, what
would be the best approach ?
 
L

Lou Pecora

Madhusudan Singh said:
1. In using matplotlib (my code essentially involved creating a plot and
show()'ing it inside a loop), the color of the plot changed. Is there a way
to tell matplotlib to not treat each new invocation as a new plot, but to
really overwrite the old one ?

You were able to get matplotlib to open a new plot each time (assuming
you closed the old one, too)? Can you show a simple example of this?

Thanks.

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top