Module for graphical python output

A forum for general discussion of the Python programming language.

Module for graphical python output

Postby wmrch » Tue Sep 13, 2016 7:18 am

Hi everybody, i need to build myself a small engineering tool, which basically does some simple calculations and has a graphical output.

(a) simple geometric shapes, for example:
  • a spline defined by some points with specific x,y-coordinates
  • two lines with a specific length and angle between them
  • a rectangle with a defined length and height
(b) simple image manipulations, for example
  • rotating an image by a specific angle
  • moving an image to specific x,y-coordinates on a canvas
(c) I also need to export this output to pdf (preferred) or jpg/png/tiff/svg.

Are there any python libraries which provide these functions or do i have to switch to another language?
Last edited by Yoriz on Tue Sep 13, 2016 8:30 am, edited 1 time in total.
Reason: First post lock.
wmrch
 
Posts: 3
Joined: Tue Sep 13, 2016 7:16 am


Re: Module for graphical python output

Postby wmrch » Tue Sep 13, 2016 12:47 pm



Hi Larz, thanks for pointing this out.
Unfortunately the results of a quick google search can not answer my question.

Pypdf seems to be merely for the manipulation of pdf files and not for exporting graphics created by another module. I will have a closer look at turtles. I can't see the relevance of a rfid reader for arduino here.

Please correct me if i'm wrong and thanks for your answer.
wmrch
 
Posts: 3
Joined: Tue Sep 13, 2016 7:16 am

Re: Module for graphical python output

Postby sparkz_alot » Tue Sep 13, 2016 1:50 pm

Python has several (to put it mildly) image manipulation library's, depending on what you want to do. It may even require more than one library to actually achieve the results your looking for. Some of the more popular ones are :
Pillow, Matplotlib and scikit-image. You might also want to check out a program called "Blender", which I believe integrates with Python, but I'll be honest, there is a steep learning curve involved.

You could also 'search' Pypi https://pypi.python.org/pypi for "graphical imaging" or "image manipulation" for example. IMHO, I would start with Matplotlib, it's fairly easy to learn and should cover most of the requirements you listed, except the save as pdf. I believe by default, it is saved as a jpeg, though I'm not 100% certain about that.
THIS FORUM WILL BE CLOSING OCT 1, 2016. PLEASE STOP BY AND REGISTER AT THE NEW LOCATION
http://python-forum.io
User avatar
sparkz_alot
 
Posts: 269
Joined: Sat Dec 06, 2014 2:55 pm
Location: US

Re: Module for graphical python output

Postby Ofnuts » Tue Sep 13, 2016 2:50 pm

wmrch wrote:Hi everybody, i need to build myself a small engineering tool, which basically does some simple calculations and has a graphical output.

(a) simple geometric shapes, for example:
  • a spline defined by some points with specific x,y-coordinates
  • two lines with a specific length and angle between them
  • a rectangle with a defined length and height
(b) simple image manipulations, for example
  • rotating an image by a specific angle
  • moving an image to specific x,y-coordinates on a canvas
(c) I also need to export this output to pdf (preferred) or jpg/png/tiff/svg.

Are there any python libraries which provide these functions or do i have to switch to another language?


Look like you want Inkscape (which can be augmented with Python scripts).

In the bitmap graphics world, I have added a bunch of functions (in Python) to create/compute geometric shapes in Gimp, but this is for people with some skills in Gimp.
This forum has been moved to http://python-forum.io/. See you there.
User avatar
Ofnuts
 
Posts: 2659
Joined: Thu May 14, 2015 9:46 am
Location: Paris, France, EU, Earth, Solar system, Milky Way, Local Cluster, Universe #32987440940987

Re: Module for graphical python output

Postby wavic » Tue Sep 13, 2016 6:52 pm

Hello!
(a) Pyglet has some drawing capabilities as far as Iemember.

(b) For an image manipulation see Pillow

(c) Export to PDF... I think ReportLab will do it in no time. When I've started with Python two days after that I came across this library. I was afraid 5 minutes after opening the documentation. :lol:
wavic
 
Posts: 165
Joined: Wed May 25, 2016 8:51 pm

Re: Module for graphical python output

Postby wmrch » Wed Sep 14, 2016 10:09 am

Thank you all for your replies. I will check the documentation of all these modules to get to know their abilities.

In the meantime someone gave me a hint to check out pygame which also looks promising.

I guess i have to use multiple modules but that's ok.
wmrch
 
Posts: 3
Joined: Tue Sep 13, 2016 7:16 am

Re: Module for graphical python output

Postby Marbelous » Wed Sep 14, 2016 4:22 pm

wmrch wrote:Hi everybody, i need to build myself a small engineering tool, which basically does some simple calculations and has a graphical output.
...
Are there any python libraries which provide these functions or do i have to switch to another language?


What you're asking for is not so much a programming language or module but a complete drawing tool. Of course such things exist:
https://www.google.com/webhp?sourceid=c ... ng+program

If you want to have the complete control writing your own software provides then I really can't think of another language that could beat python. All you need is python + matplotlib + numpy ( and maybe scipy). Take a look here for a simple example:
https://nickcharlton.net/posts/drawing- ... otlib.html
All these modules and much more are included in Continuum's free package Anaconda: https://www.continuum.io/downloads

One thing you didn't mention is whether you want just 2D, 3D or both. 3d bring in a whole new world of issues since you really need hardware acceleration through OpenGL, DirectX, etc.

As powerful as these combined tools can be you need to prepare for a few steep learning curves. The application you've described seems simple but it actually has a lot going on under the hood. Once you decide what you want to do, install some appropriate modules, then play around, read some tutorials and see what you can come up with. Post back and let us know how you're doing and we'll help out wherever we can...

EDIT: BTW, matplotlib can output to pdf as well as jpg, gif, png, mp4 (yes even video animation).
User avatar
Marbelous
 
Posts: 401
Joined: Fri May 31, 2013 8:12 pm

Re: Module for graphical python output

Postby wavic » Wed Sep 14, 2016 6:32 pm

The links I have post are to the submodules and functions you may find useful for your purpose. Except for ReportLab. All of it is to generate documents
wavic
 
Posts: 165
Joined: Wed May 25, 2016 8:51 pm


Return to General Discussions

Who is online

Users browsing this forum: Google [Bot] and 4 guests