Should I use Python for these programs?

Grant Edwards grante at visi.com
Tue Jul 10 05:26:27 CEST 2007


On 2007-07-10, CC <crobc at BOGUS.sbcglobal.net> wrote:

> I wish to accomplish a few PC programming tasks, and am
> considering to learn Python:
>
> 1. Develop a simple GUI program to run on Linux and Windows
>    which can send parameters and small blocks of data to an
>    embedded microcontroller device via RS-232 or USB.  Also
>    display simple data (probably single numbers) sent from the
>    device.
>
>    Note, if it is USB, then the client will be implemented by
>    me using FTDI chips that appear to the PC as a serial port.

I do a lot of that sort of thing using Python.  I'd probably
recommend using pyserial and wxWidgets.  Both are
cross-platform.

http://pyserial.sourceforge.net/
http://www.wxpython.org/

In any case, both "normal" PC serial ports and USB-serial ports
looks the same to a Linux app.  Windows support for stuff like
that wasn't so good last time I tried, but it's supposed to work.

> 2. Develop a simple vector drawing program that will allow one
>    to freehand draw a sketch composed of a few lines, or
>    perhaps render text in a vector form.  Then sample the
>    lines with a certain (user configurable) spacing, and use
>    the mouse to move the sample points along the lines to
>    tweak the sample locations if desired.  Then output a file
>    of X,Y coordinates for the samples.
>
>    What is this crazy thing for?  It's to develop simple
>    lasershow vector frames.  I am also designing a DSP-based
>    lasershow output device, so the same capabilities of
>    delivering a data payload over serial/USB to a target
>    device will be needed here as well.

Most of the graphics I do with Python is with Gnuplot (not
really appropriate for what you want to do.
wxWidgets/Floatcanvas might be worth looking into.

> I would prefer to be able to write a program that is cross-platform 
> between Linux and Windows.  I realize this might be especially 
> problematic with the serial comms.

Not at all.  Cross-platform serial stuff is easy.

> I am also confused by the plethora of Python GUI extensions,
> though Tkinter seems like a likely candidate.  I am uncertain
> if I will have difficulty learning how to use this if I don't
> know Tcl/Tk.


Tk's canvas widget is pretty powerful, and you don't need to
know Tcl -- it's all hidden behind a veneer of Python.

> Do you think Python is the right language for these projects?

It's what I use for stuff like that.

-- 
Grant Edwards                   grante             Yow!  MERYL STREEP is my
                                  at               obstetrician!
                               visi.com            



More information about the Python-list mailing list