Version 7 of Bwise combined with Maxima

Updated 2004-07-23 12:38:28 by TV

by Theo Verelst

Bwise is a sort of interactive visual graph based programming environment (written in Tcl/Tk), and Maxima is a pretty strong and extensive Math package capable of most average and more than a few more than average mathematical manipulations and computations, with a Tk (and tcl) user interface.

I'm convinced a combination is a very fruitful idea, so without all too much prior knowledge about Maxima I started to combine the two, to begin with simply in the same wish, which needs to come from Maxima, because it is an application (on windows) which has tcl/tk 8.4.1 built in, but compiled in.

See the maxima page for examples on its use. I only used it as yet on windows (XP) which works fine, not on an X based system (yet) though that should work, too, apart from that libraries seem to be needed. There are various pages on bwise and its use and ideas, simple and complicated, see bwise applications and examples.

It appears, after starting up Maxima, and opening its tcl console, that mainly the application has about 5 toplevel widgets, of which we are mainly interested in .maxima and .browser . The latter one, and it's buttons are not really needed to begin with, so we can pack forget it, and we leave the top menu in place.

Using the console again, we can source in bwise, for instance the 0.34 version, which will open the main window in the same toplevel as the Maxima interpreter window is open, and a new window for the procedure list will open, too. Now we have the two applications running together, which works fine, the bwise popup menus seem to work, and its normal operations and data windows, too.

Now let's look at how maxima can be interacted with, after packing the bwise window with -side top -expand y -fill both, setting the size of .maxima window to conf -width 0 -height 0, and the same for its children as far as needed, so that the bwise and maxima windows can be enlarged at the expense of the other under control of the maxima sliding horizontal control line.

(Listing an existing applications widget hierarchy is easy with ilist which is in bwise.)

Looking in the sources of maxima, the tcl files are under maxima-5.9.0/interfaces/xmaxima/Tkmaxima , where looking at 'bindings.tcl' it appears there are some top level bindings into the maxima interpreter which take the line with the current cursor of the tk text widget, and interpret and normally process the line as the user presses return.

Checking in the bwise procs_window, it appears the function and argument

   CMeval .maxima.text

Will do this, and we can treat the main maxima interpreter window as a Tk text widget (it appears simply to be one), where input can be entered in through a script like this:

 .maxima.text insert end 1+2\;
 CMeval .maxima.text

Which leads to the expacted answer.

Now we already could start to use bwise with it.

I've made a small example bwise network with two blocks following a terminal block (which doesn't yet get saved right, mind you !) of which the first inserts its input data at the end of the maxima text widget, and the second calls CMeval, which already works:

http://82.168.209.239/Bwise/maxima1.jpg

Since version 8.4.1 is used, it appears this Tk also has the slider problem...

The returning of the answer should be possible by setting the window to the bwise canvas subwidget text window, which might be an interesting trick for multiple integrated computations, but I'd like to know about non-pretty-printed representations, too, for nested or fed-through computations.

(A little comment on the .jpg images, in progressive not too small form they don't bother me enough, png's aren't perfect in all forms either, though possibly nicer for certain applications, but I have seen browsers which don't load them well)


TV (jul 23 '04) I've used the preliminary 'domax' function from Calling Maxima from Tcl in the bwise+maxima application I made basically by sourcing bwise into maxima over it's tcl console, and pack forget .browser, which makes the bwise window appear.

Apart from error problems, the setup works, like examplified in the network below

http://82.168.209.239/Bwise/maxbwise1.jpg

Where the changed block functions are:

 set term0.out {cos(x)^2+SIN(x)^2}

 set Proc1.bfunc { set Proc1.out [domax ${Proc1.in} ]}
 set Proc2.bfunc { set Proc2.out [domax "integrate( ${Proc2.in},x)" ]}

The block fed back to the interactive terminal block, which fires a (non-looping) net_funprop functional propagate when return is pressed in it's entry, evaluates it's input in maxima, and shows the result back in the terminal block.

It is followed by a block which tells maxima to integrate it's input formula, and of which the outcome is fed to a text monitor block.

And the setup works ! Which is highly fun and relevant, expecially after some more work...