[Tutor] Input to python executable code and design question

Jacob S. keridee at jayco.net
Mon Jan 10 04:35:54 CET 2005


I have grown to like VPython as the curve attribute really seems to do the
trick. If you get it working on a Tkinter canvas, I would like to see the
code as I haven't quite found a way to plot points on to one of those.  A
simple graph function in VPython... (it isn't the whole thing, believe
me...)  It already is more powerful than most graphing calculators--see
except comment.

def graphit(function):
    m = curve(color=color.blue)
    x = -15
    while -15<=x<=15:
        try:
            m.append(pos=(x,eval(function),0))
        except:
            m = curve(color=color.red)  # This is to catch domain errors and
keep the curve from connecting points across asymptotes
        x = x+0.05  # Yes it might be too high a precision, but I usually
use 0.005

I would like to see the executable. I don't know anything about Qbasic 4.5,
so I don't know if I could view the source, etc...
Tell me if you want cut and paste or attachment to see the program. By the
way, I don't want to give the impression that I'm anything much better
than a newbie myself. I just have a big mouth....
It might help setting it up. It supports x functions and polar graphs as
well. Perhaps for the future I will try 3d graphs, since VPython supports
3d.
Hah! There's something I don't remember Tkinter Canvas being able to do.

Jacob

> Jacob S. wrote:
>
> >eval() is good and it can be done using it.
> >I wrote a -- IMHO -- really great functiongraphing program using vpython.
> >If you would like to see it, just reply and say so.
> >
> >
> Out of curiosity, I would like to see your program. There's always
> something to learn (and even more so for me, being a newbie)
>
> >Please tell me what you are using to plot the points. (big grin) Vpython,
> >wxpython, what?
> >I'm curious--it's just someone else is working on a project that I'm
working
> >on...
> >
> >
> At the moment, nothing :-s
> I'm learning Phyton, and I thought that this would be an interesting
> challenge. For what I've seen, Tkinter's Canvas 'could possibly' do the
> job. I still have to try it out. In case that didn't work, I was
> thinking in looking through wxpython.
>
>
> >To help you out.
> >You need some sort of error checking to be sure that within your given
range
> >you
> >won't get something like a math domain error.
> >
> >
> Yes, I thought that:
> try:
>     #function
> exception:
>     pass
>
>
> >If you want more suggestions, ask....
> >Please, tell me how you're doing. It sounds interesting.
> >
> >
> At the moment, I have almost nothing. After John Fouhy's replies I have
> rewritten the few lines I had at least three times :o)
> It will be simple, I intend to support viewing specific parts of the
> function (instead of a fixed view), multiple graphs, perhaps an option
> to save/load functions. I first made a program like this in Qbasic 4.5,
> and thought doing it again in Python with an interface and more advanced
> options may be very entretaining. :-) I can send you the source/exe if
> you want (sadly you can't choose what you want to see in the exe
> version, the function must be hard-coded).
>
> Thanks
> Ismael
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



More information about the Tutor mailing list