decided that I wanted a better calculator than the built in version.
There are lots of command line tools around, many of which do some
interesting things (such as symbolic mathematics) and so I decided that
I'd just write a front end for one of these (yacas).
requirements were that I should not need to use the infernal pop-up
keyboard (infernal because it pops up and down at will, which is
annoying as it alters the screen layout), so that means I need to have
a working numeric and alphanumeric keypad. I decided that it ought to
have some more keys for useful mathematical functions (powers, trig
Anyway, I decided that this would be a good
opportunity to learn Python, so I bought Python in a nutshell,
downloaded the pygtk documentation (would prefer a paper book) and
started looking for some code that did something similar so I could
avoid the tedious process of writing skeleton code.
I found a
piece of code called pyRPN (http://toykeeper.net/programs/pyrpn/) and
decided that it looked about right, so set about ripping out its
innards and replacing them with mine.
I started I decided that I wanted to write a generic frontend for any
command line backend. The one I'm focussing on at the moment is Yacas,
but you could use lots of other things (mathomatic, octave, giac, etc.).
this end I wrote the code as a load of modules - modules to interface
with the backend (so you can use pipes, tcp-ip, whatever your heart
desires, and the backend allows), modules for the user interface
(modules for the alpha keypad, for the numeric keypad, for the shortcut
This means that if you add a new backend, you can keep
the standard alpha and numeric keypads if you want to, or replace them
with your own. The shortcut keypads probably need to be replaced or at
least tweaked to make sure they output the correct names (e.g. is it
sqrt() or sqr() in your backend?).
DownloadLink to tarball
Link to yacas .deb and to Yacas description page (http://yacas.sourceforge.net/homepage.html)
Nothing much to do with this, but here's Octave and Gnuplot (not sure whether these work).
ToDoThere are still lots of things I'd like to get this code to do:
like to display the equations and results on the screen in a pretty
(e.g. like TeX) form. There are some pieces of code to use TeX for this
purpose. I'm not sure how much space TeX would require to install, but
this seems like overkill.
There are also MathML tools, and a
GTK+ widget to display MathML. Two problems here, I'd need to convert
my equations and results into MathML (though it's probably not a bad
idea to use a fixed format to send to the renderer - this will help as
and when other backends are added. The second problem is that I'd need
to wrap this C widget and turn it into a Python widget. Not impossible,
but will require some reading and some work.
If I choose to go
the route of using some fixed format to feed to a renderer, the
question is which format? TeX is pretty widespread and well supported
(yacas can output in TeX format). Yacas also does output in OpenMath
format. I don't know much about this, but it's another option.
final option is just to write my own renderer in Python. I think this
would be the most interesting, I'll have to see if I can build up
enough motivation to do it ;)
whole point of the module system is to allow different backends to be
added in with as little hassle as possible. Equally the use of modules
allows different interfaces to the calculator - so you can add a new
page/replace a current page to show different shortcut keys, or alter
the layout of the numeric keys or the alpha keys, etc.
would be interesting to provide tooltips for some of the more complex
functions (e.g. differentiation, where are the limits placed, or the
variable to differentiate with respect to, etc.?)
Improved text box
Currently the text box just takes input, I'd like to make it a bit more intelligent:
Different taps to select different parts of the current string. E.g.:
single tap for insert cursor (or if the tap is beyond the current string, cursor to the end),
double tap to select a word (or if the tap is beyond the current string, select all),
triple tap to select between brackets.
Bracket highlighting to aid input/editing.
Add more functionality