Frequently Asked Questions about Rivet

The latest update of this document can be found at http://www.veritas.com/~brianw/rivet/rivetfaq.html .

Questions:


How do I write a new Rivet widget?

There are two ways you might wish to make a widget. One is the widget that is complete built in Python. The reference documentation describes a technique for wrapping Rivet objects in python classes, and the Rivet table widget is an example of this method.

The other way of writing a widget will put hair on your chest. You can create the widget in C, following the methods suggested by Ousterhout and demonstrated in his tkSquare example. For this method, follow Ousterhout's rules to create the basic widget. Then you need to provide access from python (this is the hair growing part) you need to add code to the rivetmodule.c code, or create a new module of your own, using Python's C extension mechanism.


Can BLT or Tix work with Rivet?

Not without alot of work.

If you must port an existing Tcl/Tk extension, then the general approach is to port all the tcl code in that package to either Python or C (C is harder). Then you might have to modify the C code in that package so that it avoids functions that aren't in Rivet, such as Tcl_GlobalEval. Then you have to add C code to bind it to python (ala rivetmodule.c). This can be lots of work. If it's too complicated, it might take less time to just write it from scratch in Python. From experience, this ain't too bad. Right now, there is a close approximation of the blt table in rivettable.py, and the outline list example should prove it's pretty easy to build "widgets" in Python.


What languages has Rivet been ported to?

Besides the obvious C and Python, none. Someone has done a preliminary port to Glish, but that will probably not be released.


Why do I get a core dump in TkTextGetIndex()?

This happens because Tk modifies the string passed in, and the string is located in a read only memory segment. If you compiled with gcc, be sure to compile with the -fwritable-strings flag.


Is there a way to get a wish like enviroment with Python and Rivet?

Yes. If you configure python with --with-readline=path_to_your_copy_of_gnu_readline and recompile, rivet will update the display and allow you to type in python code simultaneously. The disadvantage of this method is that the code loops, chewing up cpu as it does. (This is the same problem that Tkinter has when it is setup to use gnu readline.)

There are several alternatives to readline. One possibility is to type in rivet.update() occasionally. This will allow your application to update its display and handle events, although in an awkward manner.

It is also possible to run rivet.mainloop() from another python thread. (Assuming you have threads compiled into python.) This allows X event processing to happen in another thread while you type into the python prompt. This works and we have used it in this mode, but since Rivet is not completely thread safe, this is to be considered experimental.


Unanswered questions? Send them to Brian Warkentine, brianw@veritas.com .