dislin interfaced with tkinter

E

eesun

Hi,

I've downloaded the dislin package for the scientific plotting. And I
have already created the application window with Tkinter (menu,
canvas, status bar..). I want to integrate the Dislin plotting into
the Tkinter application. For ex: show the dislin result on the Tkinter
Canvas. Anyone can help?

thx
 
I

Istvan Albert

eesun said:
I've downloaded the dislin package for the scientific plotting. And I
have already created the application window with Tkinter (menu,
canvas, status bar..). I want to integrate the Dislin plotting into
the Tkinter application. For ex: show the dislin result on the Tkinter
Canvas. Anyone can help?

I believe that dislin plots trough its own graphical device
that is independent of Tkinter thus cannot be integrated
with it.

You might want to try matplotlib, it has Tk backend

http://matplotlib.sourceforge.net/

the nice folks there might be able to help you out.

Istvan.
 
C

Christopher T King

I've downloaded the dislin package for the scientific plotting. And I
have already created the application window with Tkinter (menu,
canvas, status bar..). I want to integrate the Dislin plotting into
the Tkinter application. For ex: show the dislin result on the Tkinter
Canvas. Anyone can help?

I don't know anything about dislin; scanning through its web site, it
looks like a commercial C program. The only two ways I can think of to
integrate something like this into a Tkinter (or any toolkit) application
are:

1) If there's a way to pass dislin a window ID in which to draw (it
doesn't look like it; its openwin() function uses internal IDs), you can
create a Frame widget and pass the value returned by its .winfo_id()
method to the library.

2) If you can find no better way, as a last resort you can have dislin
write its output to an image file, and read the file using the Python
Imaging Library (PIL), which is integrated very well into Tkinter (you can
use its ImageTk class to create an image suitable for a Label, Canvas, or
what-have-you).

If your application isn't dependant on dislin and doesn't need 3D
graphing capabilities, consider switching to matplotlib
(http://matplotlib.sf.net/), which provieds the embedability you want.
 
T

Tom B.

eesun said:
Hi,

I've downloaded the dislin package for the scientific plotting. And I
have already created the application window with Tkinter (menu,
canvas, status bar..). I want to integrate the Dislin plotting into
the Tkinter application. For ex: show the dislin result on the Tkinter
Canvas. Anyone can help?

thx

I haven't worked with Dislin/Tkinter but I have worked with Dislin/wxPython
and what you can do is dump the Dislin output into a string buffer.

A shade plot,

def dis_img(self,zmat,m, n, zlo, zhi):
char = ''
max_bytes = 0
xray = range (n)
yray = range (m)
dislin.metafl ('VIRT')
dislin.setpag ('da4l')
#dislin.setfil (self.globdir)
dislin.disini ()
dislin.pagera ()
dislin.hwfont ()
dislin.ax3len (1400, 1400,1400)
dislin.autres(n, m)
dislin.shdmod ('poly', 'contur')
dislin.graf3 (0, n, 0, n/5, 0, m, 0, m/5, zlo, zhi, zlo, (zhi-zlo)/5)
dislin.crvmat (zmat, n, m, 1, 1)
dislin.title ()
char_buff = dislin.rbfpng(max_bytes)
max_bytes = int(char_buff[1])
char_buff = dislin.rbfpng(max_bytes)
char = char_buff[0]
#char now contains a PNG image of the output. I use Python Imaging
Library
#and open like this
self.Imagetest = Image.open(StringIO.StringIO(char))
dislin.disfin ()

Tom
 
C

Christopher T King

I haven't worked with Dislin/Tkinter but I have worked with Dislin/wxPython
and what you can do is dump the Dislin output into a string buffer.

Code:
[/QUOTE]

Building on that, the only change needed to use that with Tkinter would be 
to convert the Image object into a PhotoImage object using 
ImageTk.PhotoImage:

    self.Imagetest = ImageTk.PhotoImage(Image.open(StringIO.StringIO(char)))
 
P

Patrick Ellis

eesun said:
I've downloaded the dislin package for the scientific plotting. And I
have already created the application window with Tkinter (menu,
canvas, status bar..). I want to integrate the Dislin plotting into
the Tkinter application. For ex: show the dislin result on the Tkinter
Canvas. Anyone can help?

There is a package called disipyl which provides a more object oriented
interface to dislin. It includes interfaces to wxPython and Tkinter. It
hasn't been updated in a couple of years, but dislin hasn't changed much in
that time either.

http://kim.bio.upenn.edu/~pmagwene/disipyl.html
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top