Re: 2d graphics - what module to use?

2008-07-26 Thread sturlamolden
On Jul 26, 6:47 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:

> If you're using wx, there is also wx.lib.plot, which I found to be
> _much_ faster than matplotlib in my application, especially when resizing.

Yes. Matplotlib creates beautiful graphics, but are terribly slow on
large data sets.


--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - what module to use?

2008-07-25 Thread Carl Banks
On Jul 25, 4:10 am, King <[EMAIL PROTECTED]> wrote:
> Use python's default GUI tkinter's drawing functions or you can use
> wxPython GUI kit or you can use pyopengl.
> If you are only interested to draw sin waves or math functions that
> you should give try to matlab atwww.mathworks.com

If you're only interested in sine waves you most certainly should not
give Matlab a try; even with student pricing it's going to be way
expensive for something that simple.

For just popping up a window and drawing on it I recommend PyGame.


Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - what module to use?

2008-07-25 Thread Matthew Fitzgibbons

sturlamolden wrote:

On Jul 25, 8:13 am, Pierre Dagenais <[EMAIL PROTECTED]> wrote:

What is the easiest way to draw to a window? I'd like to draw something
  like sine waves from a mathematical equation.
Newbie to python.


For mathematica equations, NumPy and matplotlib is probably the best
option. I prefer to embed matplotlib in wxPython. wxAgg is an
excellent backend.

For more general 2D graphics, there are several options, including:

- pygame (uses SDL)
- aggdraw module
- pycairo
- pyopengl
- wxPython's device context (ditto for other GUI libraries)





--
http://mail.python.org/mailman/listinfo/python-list



If you're using wx, there is also wx.lib.plot, which I found to be 
_much_ faster than matplotlib in my application, especially when resizing.


-Matt
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - what module to use?

2008-07-25 Thread sturlamolden
On Jul 25, 8:13 am, Pierre Dagenais <[EMAIL PROTECTED]> wrote:
> What is the easiest way to draw to a window? I'd like to draw something
>   like sine waves from a mathematical equation.
> Newbie to python.

For mathematica equations, NumPy and matplotlib is probably the best
option. I prefer to embed matplotlib in wxPython. wxAgg is an
excellent backend.

For more general 2D graphics, there are several options, including:

- pygame (uses SDL)
- aggdraw module
- pycairo
- pyopengl
- wxPython's device context (ditto for other GUI libraries)





--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - what module to use?

2008-07-25 Thread Boris Borcic

Pierre Dagenais wrote:
What is the easiest way to draw to a window? I'd like to draw something 
 like sine waves from a mathematical equation.

Newbie to python.
--
http://mail.python.org/mailman/listinfo/python-list



For very simple things, the standard module turtle might be your best bet.

BB

--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - what module to use?

2008-07-25 Thread arsyed
On Fri, Jul 25, 2008 at 2:13 AM, Pierre Dagenais <[EMAIL PROTECTED]> wrote:
> What is the easiest way to draw to a window? I'd like to draw something
>  like sine waves from a mathematical equation.
> Newbie to python.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

I'd recommend matplotlib:

http://matplotlib.sourceforge.net/

Also see the "GUI" and "Plotting" sections on this page:

http://wiki.python.org/moin/UsefulModules
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - what module to use?

2008-07-25 Thread Guilhem Faure
You can try R cran also. Very powerfull and free. And with R you can use
Rpy, a library R for python and can access to R function and R graph in a
python script.
Other mathematic library  exist in python : Matplotlib for exemple.
Summary :
to draw graph easely in python : Rpy lib or Matplotlib. If you don't know R
language (vectorial language) use Matplotlib.

Adress :
R site : http://cran.r-project.org/
Rpy lib for python : http://rpy.sourceforge.net/
Matplotlib for python : http://matplotlib.sourceforge.net/




On 7/25/08, King <[EMAIL PROTECTED]> wrote:
>
> Use python's default GUI tkinter's drawing functions or you can use
> wxPython GUI kit or you can use pyopengl.
> If you are only interested to draw sin waves or math functions that
> you should give try to matlab at www.mathworks.com
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: 2d graphics - what module to use?

2008-07-25 Thread Lorenzo Gatti
On 25 Lug, 08:13, Pierre Dagenais <[EMAIL PROTECTED]> wrote:
> What is the easiest way to draw to a window? I'd like to draw something
>   like sine waves from a mathematical equation.
> Newbie to python.

What you are really asking for is what GUI library you should use;
every one allows you to draw freely. What do you need to do besides
drawing sine waves? You should look at your full range of options;
http://wiki.python.org/moin/GuiProgramming is a good starting point.

The "easiest" way to draw might be with those toolkits that offer
primarily a canvas to draw on rather than composable widgets. For
example, Pyglet (http://pyglet.org/) offers OpenGL contexts with
sensible defaults and unobtrusive automation:

from pyglet import *
from pyglet.gl import *
import math
win = window.Window(width=700, height=700, caption="sine wave demo",
resizable=True)
frequency,phase,amplitude=0.1,0.0,0.9
@win.event
def on_draw():
half_height=win.height*0.5
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(0.9, 1.0, 0.8)
glBegin(GL_LINE_STRIP)
for x in xrange(0,win.width):
y=half_height*(1.0+amplitude*math.sin(x*frequency+phase))
glVertex2f(x,y)
glEnd()
app.run()



Regards,

Lorenzo Gatti
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - what module to use?

2008-07-25 Thread King
Use python's default GUI tkinter's drawing functions or you can use
wxPython GUI kit or you can use pyopengl.
If you are only interested to draw sin waves or math functions that
you should give try to matlab at www.mathworks.com

--
http://mail.python.org/mailman/listinfo/python-list


2d graphics - what module to use?

2008-07-24 Thread Pierre Dagenais
What is the easiest way to draw to a window? I'd like to draw something 
 like sine waves from a mathematical equation.

Newbie to python.
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - drawing a vescica piscis in Python

2008-06-18 Thread Terrence Brannon
On Jun 17, 3:45 pm, Terrence Brannon <[EMAIL PROTECTED]> wrote:
> Hello, I have written a program to draw a vescica piscis  en.wikipedia.org/wiki/Vesica_piscis>

actually, I mis-spelled the term. It should be vesica piscis or vesica
pisces. I put a "c" after the "s" -- vescica --- and that is wrong and
made it hard for me to find this post the next day.

now others will be able to search the archives and find it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Lie
On Jun 18, 2:45 am, Terrence Brannon <[EMAIL PROTECTED]> wrote:
> Hello, I have written a program to draw a vescica piscis  en.wikipedia.org/wiki/Vesica_piscis>
>
> from turtle import *
>
> def main():
>     setup(width=400, height=400)
>
>     r = 50
>     color("black")
>     circle(r)
>     color("white")
>     forward(r)
>     color("black")
>     circle(r)
>     x = raw_input('please enter a string:')
>
> if __name__ == '__main__':
>     main()
>
> ... but I would like the following:
>
> 1 - I dont like how the bottom of the first circle is not complete
> 2 - I would like for the left circle to be filled with verticle lines
> and the right circle to be filled with horizontal lines, so that the
> vescica piscis is cross-hatched.
>
> And finally, is turtle the "best" option for what I'm doing? pyCairo
> looked a bit hard to get going with, but very powerful. sping looked a
> bit alpha/beta.

For an alternative to turtle, you might want to see PIL (Python
Imaging Library) or perhaps pygame.
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Matimus
On Jun 17, 12:45 pm, Terrence Brannon <[EMAIL PROTECTED]> wrote:
> Hello, I have written a program to draw a vescica piscis  en.wikipedia.org/wiki/Vesica_piscis>
>
> from turtle import *
>
> def main():
>     setup(width=400, height=400)
>
>     r = 50
>     color("black")
>     circle(r)
>     color("white")
>     forward(r)
>     color("black")
>     circle(r)
>     x = raw_input('please enter a string:')
>
> if __name__ == '__main__':
>     main()
>
> ... but I would like the following:
>
> 1 - I dont like how the bottom of the first circle is not complete
> 2 - I would like for the left circle to be filled with verticle lines
> and the right circle to be filled with horizontal lines, so that the
> vescica piscis is cross-hatched.
>
> And finally, is turtle the "best" option for what I'm doing? pyCairo
> looked a bit hard to get going with, but very powerful. sping looked a
> bit alpha/beta.

I would just draw on the tk canvas:

>>> import Tkinter as tk
>>> can = tk.Canvas()
>>> can.pack(fill=tk.BOTH, expand=True)
>>> c1 = can.create_oval(10,10,110,110)
>>> c2 = can.create_oval(60,10,170,110)

You can draw cross hatching using can.create_line(...).

Have fun,

Matt
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Mensanator
On Jun 17, 2:45 pm, Terrence Brannon <[EMAIL PROTECTED]> wrote:
> Hello, I have written a program to draw a vescica piscis  en.wikipedia.org/wiki/Vesica_piscis>
>
> from turtle import *
>
> def main():
>     setup(width=400, height=400)
>
>     r = 50
>     color("black")
>     circle(r)
>     color("white")
>     forward(r)
>     color("black")
>     circle(r)
>     x = raw_input('please enter a string:')
>
> if __name__ == '__main__':
>     main()
>
> ... but I would like the following:
>
> 1 - I dont like how the bottom of the first circle is not complete

Because you overwrote that portion of the circle when
you changed the color to white.

Instead, you should have done up() (which lifts the pen)
and then down() after you've moved to the start of the
second circle. No need to change the pen color.

> 2 - I would like for the left circle to be filled with verticle lines
> and the right circle to be filled with horizontal lines, so that the
> vescica piscis is cross-hatched.

That would be the fill() command, but it's not documented
how to fill with anything other than a solid color.

>
> And finally, is turtle the "best" option for what I'm doing? pyCairo
> looked a bit hard to get going with, but very powerful. sping looked a
> bit alpha/beta.

--
http://mail.python.org/mailman/listinfo/python-list


2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Terrence Brannon
Hello, I have written a program to draw a vescica piscis 

from turtle import *

def main():
setup(width=400, height=400)

r = 50
color("black")
circle(r)
color("white")
forward(r)
color("black")
circle(r)
x = raw_input('please enter a string:')

if __name__ == '__main__':
main()


... but I would like the following:

1 - I dont like how the bottom of the first circle is not complete
2 - I would like for the left circle to be filled with verticle lines
and the right circle to be filled with horizontal lines, so that the
vescica piscis is cross-hatched.

And finally, is turtle the "best" option for what I'm doing? pyCairo
looked a bit hard to get going with, but very powerful. sping looked a
bit alpha/beta.
--
http://mail.python.org/mailman/listinfo/python-list


Re: WebBased Vector 2D Graphics

2007-10-16 Thread crazychrisy54
On Oct 5, 12:41 pm, Robin Becker <[EMAIL PROTECTED]> wrote:
> Diez B. Roggisch wrote:
> >  [EMAIL PROTECTED] wrote:
>
> ...
>
> > You certainly need to get on speed with webdevelopment. Otherwise you will
> > fail miserably.
>
> > There are several options here:
>
> >  - rendering a server-side image, deliver that embedded in a html-page
>
> >  - render using html tags like DIV and the like, which allow for positioned
> > colored rectangles and text, in pixel coordinates
>
> >  - canvas tag, to render 2D-drawing-commands
>
> >  - embedded SVG
>
> > All that can be enriched with AJAX to have that fancy
> > realtime-update-thingy.
>
> > Diez
>
> simple rectangles are pretty easy though. I did a progress bar 
> herehttp://www.jessikat.plus.com/pbar.htmlwith a bit of javascript.
>
> The other side of the information usually involves ajax call backs to 
> determine
> how much of the job has been done etc etc. I seem to remember doing that for a
> project a while back. As I recall we had a cgi script that did
>
> action "start" start off a long running job that detached itself from the web
> server so the response could be made short
>
> action "query" find out from an output file how much of the job has been done.
>
> A javascript timeout periodically performed the query request and used the
> response to update the ticker.
> --
> Robin Becker- Hide quoted text -
>
> - Show quoted text -

That is pretty much exactly what I want! Can I ask how you have
presented the bar on the page i.e. embedded into a canvas? because I
can't get this to work on netscape 7 (which is a requirement) and
wondered if there was a way to get around this?
Cheers

Chris

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WebBased Vector 2D Graphics

2007-10-06 Thread Dorai
On Oct 5, 4:28 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>  [EMAIL PROTECTED] wrote:
> > Hi there
>
> > I currently have a Python program outputing to the command line,
> > durations of 'completed Steps' and 'data items' in relation to time
> > i.e.
>
> > --jfh
> >   -kl//kl started after jfh finished
> > % Ds  //new data arrived at this point in time
> > ---pl (1)  //Details error with finsihed Step
> >*kl  // This step is now outputed but
> > due to error with pl is cancelled (no duration)
>
> > I am new to doing any web based development and don't have a clue
> > where to start! I just wondered what is the best way to output this
> > program to a web page graphically.
>
> > I want to be able to represent these durations "-" as rectangles
> > and as the program runs the page will refresh every 10 seconds, thus
> > the boxes will expand with time until they have finished. New data
> > will also be represented in boxes with a different colour. I believe
> > some kind of script will have to be run which constantly updates the
> > html page after x seconds which then causes the web page to refresh
> > with the updated data.
>
> > Is there any way this web programming can be done in python. Or
> > perhaps I can use soemthing such as ajax?
>
> > As mentioned previously, I have never done any web based development
> > so don't really know what I'm talking about when trying to understand
> > how I can go from this Python program output to producing some
> > graphical output on a web page.
>
> You certainly need to get on speed with webdevelopment. Otherwise you will
> fail miserably.
>
> There are several options here:
>
>  - rendering a server-side image, deliver that embedded in a html-page
>
>  - render using html tags like DIV and the like, which allow for positioned
> colored rectangles and text, in pixel coordinates
>
>  - canvas tag, to render 2D-drawing-commands
>
>  - embedded SVG
>
> All that can be enriched with AJAX to have that fancy
> realtime-update-thingy.
>
> Diez

Great ideas.

Another approach would be to generate some simple metadata (simple
text, json or xml) on the server and use a javascript libraries (like
http://www.openjacob.org/draw2d.html). SVG is a more generic version
of this approach.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WebBased Vector 2D Graphics

2007-10-05 Thread Bjoern Schliessmann
 [EMAIL PROTECTED] wrote:
> On Oct 5, 11:43 am, Bjoern Schliessmann > The above approaches allow you to directly print to the web page.
> 
> Would this mean I wouldn't be able to have any fancy graphics
> outputed such as the rectangles I mentioned before with different
> filled in colours?

No, it wouldn't. I suggest you followed Diez' recommendation.

Regards,


Björn

-- 
BOFH excuse #437:

crop circles in the corn shell

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WebBased Vector 2D Graphics

2007-10-05 Thread Robin Becker
Diez B. Roggisch wrote:
>  [EMAIL PROTECTED] wrote:
> 
...
> 
> You certainly need to get on speed with webdevelopment. Otherwise you will
> fail miserably.
> 
> There are several options here:
> 
>  - rendering a server-side image, deliver that embedded in a html-page
> 
>  - render using html tags like DIV and the like, which allow for positioned
> colored rectangles and text, in pixel coordinates
> 
>  - canvas tag, to render 2D-drawing-commands
> 
>  - embedded SVG
> 
> All that can be enriched with AJAX to have that fancy
> realtime-update-thingy.
> 
> Diez

simple rectangles are pretty easy though. I did a progress bar here
http://www.jessikat.plus.com/pbar.html with a bit of javascript.

The other side of the information usually involves ajax call backs to determine 
how much of the job has been done etc etc. I seem to remember doing that for a 
project a while back. As I recall we had a cgi script that did

action "start" start off a long running job that detached itself from the web 
server so the response could be made short

action "query" find out from an output file how much of the job has been done.

A javascript timeout periodically performed the query request and used the 
response to update the ticker.
-- 
Robin Becker

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WebBased Vector 2D Graphics

2007-10-05 Thread Diez B. Roggisch
 [EMAIL PROTECTED] wrote:

> Hi there
> 
> I currently have a Python program outputing to the command line,
> durations of 'completed Steps' and 'data items' in relation to time
> i.e.
> 
> 
> --jfh
>   -kl//kl started after jfh finished
> % Ds  //new data arrived at this point in time
> ---pl (1)  //Details error with finsihed Step
>*kl  // This step is now outputed but
> due to error with pl is cancelled (no duration)
> 
> I am new to doing any web based development and don't have a clue
> where to start! I just wondered what is the best way to output this
> program to a web page graphically.
> 
> I want to be able to represent these durations "-" as rectangles
> and as the program runs the page will refresh every 10 seconds, thus
> the boxes will expand with time until they have finished. New data
> will also be represented in boxes with a different colour. I believe
> some kind of script will have to be run which constantly updates the
> html page after x seconds which then causes the web page to refresh
> with the updated data.
> 
> Is there any way this web programming can be done in python. Or
> perhaps I can use soemthing such as ajax?
> 
> As mentioned previously, I have never done any web based development
> so don't really know what I'm talking about when trying to understand
> how I can go from this Python program output to producing some
> graphical output on a web page.

You certainly need to get on speed with webdevelopment. Otherwise you will
fail miserably.

There are several options here:

 - rendering a server-side image, deliver that embedded in a html-page

 - render using html tags like DIV and the like, which allow for positioned
colored rectangles and text, in pixel coordinates

 - canvas tag, to render 2D-drawing-commands

 - embedded SVG

All that can be enriched with AJAX to have that fancy
realtime-update-thingy.

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WebBased Vector 2D Graphics

2007-10-05 Thread cjt22
On Oct 5, 11:43 am, Bjoern Schliessmann  wrote:
>  [EMAIL PROTECTED] wrote:
> > Is there any way this web programming can be done in python.
>
> Sure. Minimalistic approaches include using CGI
> (http://docs.python.org/lib/module-cgi.html)
> or using Apache with mod_python directly. There are also web
> frameworks for Python, but I don't know much about them.
>
> > As mentioned previously, I have never done any web based
> > development so don't really know what I'm talking about when
> > trying to understand how I can go from this Python program output
> > to producing some graphical output on a web page.
>
> The above approaches allow you to directly print to the web page.
> I'm not sure how you could display constant progress there. Perhaps
> much simpler with mod_python than with CGI.
>
> Regards,
>
> Björn
>
> --
> BOFH excuse #369:
>
> Virus transmitted from computer to sysadmins.

Thanks Bjorn

> The above approaches allow you to directly print to the web page.

Would this mean I wouldn't be able to have any fancy graphics outputed
such as the rectangles I mentioned before with different filled in
colours?

Cheers
Chris

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: WebBased Vector 2D Graphics

2007-10-05 Thread Bjoern Schliessmann
 [EMAIL PROTECTED] wrote:

> Is there any way this web programming can be done in python. 

Sure. Minimalistic approaches include using CGI
(http://docs.python.org/lib/module-cgi.html)
or using Apache with mod_python directly. There are also web
frameworks for Python, but I don't know much about them.

> As mentioned previously, I have never done any web based
> development so don't really know what I'm talking about when
> trying to understand how I can go from this Python program output
> to producing some graphical output on a web page.

The above approaches allow you to directly print to the web page.
I'm not sure how you could display constant progress there. Perhaps
much simpler with mod_python than with CGI. 
 
Regards,


Björn

-- 
BOFH excuse #369:

Virus transmitted from computer to sysadmins.

-- 
http://mail.python.org/mailman/listinfo/python-list


WebBased Vector 2D Graphics

2007-10-05 Thread cjt22
Hi there

I currently have a Python program outputing to the command line,
durations of 'completed Steps' and 'data items' in relation to time
i.e.


--jfh
  -kl//kl started after jfh finished
% Ds  //new data arrived at this point in time
---pl (1)  //Details error with finsihed Step
   *kl  // This step is now outputed but
due to error with pl is cancelled (no duration)

I am new to doing any web based development and don't have a clue
where to start! I just wondered what is the best way to output this
program to a web page graphically.

I want to be able to represent these durations "-" as rectangles
and as the program runs the page will refresh every 10 seconds, thus
the boxes will expand with time until they have finished. New data
will also be represented in boxes with a different colour. I believe
some kind of script will have to be run which constantly updates the
html page after x seconds which then causes the web page to refresh
with the updated data.

Is there any way this web programming can be done in python. Or
perhaps I can use soemthing such as ajax?

As mentioned previously, I have never done any web based development
so don't really know what I'm talking about when trying to understand
how I can go from this Python program output to producing some
graphical output on a web page.

Any help would be much appreciated
Chris

-- 
http://mail.python.org/mailman/listinfo/python-list


2D graphics

2005-10-10 Thread Peres



Dear Fredrik,
Thanks for your answer. yes it means animated on 
the screen.
I downloaded Python2.4, pygame and vision, but the 
animation is slow, and i cannot set a graphic priority to my program. Someone 
suggested PyopenGL.sourceforge, but it seems complicated.
Thanks again
 
Valerie
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: 2D graphics

2005-10-10 Thread Fredrik Lundh
"Peres" wrote:

> As a Python beginner, I feel a bit lost among all possible libraries...
> so I wondered whether soemone could help me find my way... I
> just need to generate animated sequences of 2D primitives (dots
> and lines), as fast as possible, checking the computer clock for
> the time elapsed for each image, and checking the mouse click.

"animated" as in "animated on screen" ?

all Python GUI toolkits can do that.  which one(s) do you have installed
on your machine?





-- 
http://mail.python.org/mailman/listinfo/python-list


2D graphics

2005-10-10 Thread Peres



Hello,
As a Python beginner, I feel a bit lost among all 
possible libraries... so I wondered whether soemone could help me find my way... 
I just need to generate animated sequences of 2D primitives (dots and lines), as 
fast as possible, checking the computer clock for the time elapsed for each 
image, and checking the mouse click. 
Thanks a lot in advance for your help!
 
Valerie, 
a grateful 
Pythonner
-- 
http://mail.python.org/mailman/listinfo/python-list