How to create graphs an embed them in GUI?

H

Heiko Niedermeyer

Sorry for the fuzzy subject...

Currently I'm writing a little programm to extract some chemical
information out of a text file, and then present it in a pleasant way.
The Extraction works so far, so now the presentation will be next.

As I'm learning Python from scratch, I don't care wether to use (=learn)
TKinter or PyQt or whatever, I just need some advice, which suits my
needs best.
It would be nice to have the programm working under win and linux
(shouldn't be a big Problem) and my requirements concerning the standard
elements should be met by almost every framework.
My problem is, that I want to add graph (simple, line connected X,Y-
scatter plots) and if possible the 3D representation of atoms in a
molecule (-> coloured spheres in space).
I think it would take me years to program those by myself, so I would ne
ready to use packages, if available.
Long story short: Are there packages that could do this, and does it
matter which GUI I want to embed them in?

best wishes
 
A

A.T.Hofkamp

As I'm learning Python from scratch, I don't care wether to use (=learn)
TKinter or PyQt or whatever, I just need some advice, which suits my
needs best.
It would be nice to have the programm working under win and linux
(shouldn't be a big Problem) and my requirements concerning the standard

PyGTK is a 3rd option, and wxWindows + Python is a 4th option.

TKinter is supplied with Python, which means everybody with Python also has
TKinter. Main draw-backs are that it is quite old. Also, it has a peculiar way
of getting stuff drawn at a canvas.

PyQt is available free with some additional restriction (plz read the
license) for the Linux system, I don't know whether you can also get a Win
version under the same conditions (you couldn't when I looked the last time).
PyGTK is said to be usable for both platforms. I know it works with Linux, and
there exists a PyGTK installer for Win, but I hacve never used it.

No recent experience with wxWindows.
My problem is, that I want to add graph (simple, line connected X,Y-
scatter plots) and if possible the 3D representation of atoms in a
molecule (-> coloured spheres in space).

You should probably seperate both problems, in particular if you want to have
the program do the layout for you. For 2D layout, Graphviz is one of the better
known packages, run it as a child process. There are several graphviv/dot
Python libraries available, search PyPI for them.

For 3D, I don't know any programs.
I think it would take me years to program those by myself, so I would ne
ready to use packages, if available.
Long story short: Are there packages that could do this, and does it
matter which GUI I want to embed them in?

If you want a GUI that understands how to layout chemical structures, you won't
have many options (on the other hand, you never know, have you tried searching
PyPI already?).

On the other hand, once you have the coordinates, drawing them is kind of
trivial in just about any GUI toolkit.

(An alternative may be to have the user lay them out by dragging them with the
mouse. Programming that is however probably a lot more work.)


Sincerely,
Albert
 
S

Stef Mientki

Heiko said:
Sorry for the fuzzy subject...

Currently I'm writing a little programm to extract some chemical
information out of a text file, and then present it in a pleasant way.
The Extraction works so far, so now the presentation will be next.

As I'm learning Python from scratch, I don't care wether to use (=learn)
TKinter or PyQt or whatever, I just need some advice, which suits my
needs best.
It would be nice to have the programm working under win and linux
(shouldn't be a big Problem) and my requirements concerning the standard
elements should be met by almost every framework.
My problem is, that I want to add graph (simple, line connected X,Y-
scatter plots) and if possible the 3D representation of atoms in a
molecule (-> coloured spheres in space).
I think it would take me years to program those by myself, so I would ne
ready to use packages, if available.
Long story short: Are there packages that could do this, and does it
matter which GUI I want to embed them in?

I think "Vision" (formerly Viper)is exactly what you are looking for.
If not look at VTK.

cheers,
Stef
 
Y

Yu-Xi Lim

Heiko said:
Sorry for the fuzzy subject...

Currently I'm writing a little programm to extract some chemical
information out of a text file, and then present it in a pleasant way.
The Extraction works so far, so now the presentation will be next.


If the GUI is only for the graph, try matplotlib. It should do the
graphs/charts you require.

If necessary, you can combine matplotlib with another GUI toolkit for a
full GUI. This might be useful if you want to display menus and dialogs
to load the text files, etc.

3D is a different matter. I'd personally go with Python bindings for
VTK, but be warned that the learning curve is very steep and the online
docs are quite sparse (you're encouraged to buy the book, which is
probably the main source of income for the VTK devs).
 
Y

Yu-Xi Lim

Heiko said:
Sorry for the fuzzy subject...

Currently I'm writing a little programm to extract some chemical
information out of a text file, and then present it in a pleasant way.
The Extraction works so far, so now the presentation will be next.


If the GUI is only for the graph, try matplotlib. It should do the
graphs/charts you require.

If necessary, you can combine matplotlib with another GUI toolkit for a
full GUI. This might be useful if you want to display menus and dialogs
to load the text files, etc.

3D is a different matter. I'd personally go with Python bindings for
VTK, but be warned that the learning curve is very steep and the online
docs are quite sparse (you're encouraged to buy the book, which is
probably the main source of income for the VTK devs).
 
S

sturlamolden

My problem is, that I want to add graph (simple, line connected X,Y-
scatter plots) and if possible the 3D representation of atoms in a
molecule (-> coloured spheres in space).
I think it would take me years to program those by myself, so I would ne
ready to use packages, if available.

I would recommend using NumPy and SciPy together with Matplotlib.

For GUI, you can embed Matplotlib in e number of toolkits. wxPython,
PyGTK or PyQt are good options.

For 3D plots, there are e.g. an extension to Matplotlib (Mplot3D),
OpenGL, Direct3D (i.e. DirectPython), or VTK.


Sturla Molden
 
B

Benjamin

PyGTK is a 3rd option, and wxWindows + Python is a 4th option.

TKinter is supplied with Python, which means everybody with Python also has
TKinter. Main draw-backs are that it is quite old. Also, it has a peculiar way
of getting stuff drawn at a canvas.

PyQt is available free with some additional restriction (plz read the
license) for the Linux system, I don't know whether you can also get a Win
version under the same conditions (you couldn't when I looked the last time).
PyGTK is said to be usable for both platforms. I know it works with Linux, and
there exists a PyGTK installer for Win, but I hacve never used it.
PyQt 4+ is now available for MacOS, Windows, and X under GPL. I tried
Tkinter and wxPython before settling on PyQt. It's more powerful than
Tkinter and has a cleaner API than wxPython.
No recent experience with wxWindows.
Qwt (Q Widgets for Technical Applications) provides graphs widgets
that plug into Qt. There are, of course, Python bindings (pyqwt).
 
H

Heiko Niedermeyer

This is just a brief summary, how I'm trying to do it now. In case somone
ever encouters a problem like this...

For the 2D part, I'm going with matplotlib, which seems to do, what I want.
The 3D is currently donw be vpython, which is not great, but sufficient...
Maybe I will switch when I find something better... ;)

Thanks anyway.
 

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,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top