I thought maybe the list would benefit from hearing about how I chose to wrap the bwidget family of widgets for my pybwidget package.
On Fri, Jan 21, 2005 at 10:40:54AM +0000, Martin Franklin wrote: > First thing to note is that tablelist is pure Tcl package and can be > either installed in the standard tcl package location or you can tell > Tcl where it is (I choose the later since I don't always have permission > to install) [...] > To use the package from this location Tcl I need to execute this:- > > root.tk.call("lappend", "auto_path", "/home/martin/tablelist3.7") [...] > Next you have to register the package so that Tkinter can use/find it > > root.tk.call("package", "require", "tablelist") in pybwidget, setup.py installs the .tcl files (and a few other files) in a known location relative to the Python installation. (The downside of this is that the package is not available in "wish", the tk interactive shell) That path is defined as _datadir = os.path.join(sys.prefix, "share", "pybwidget") The files are installed by the 'data_files=' parameter to setup() When a bwidget is created, the _datadir is added to auto_path if it wasn't already present, and then the package is require'd: def _require(self, master): auto_path = master.tk.call("set", "auto_path") if not _datadir in auto_path: master.tk.call("lappend", "auto_path", _datadir) master.tk.call("package", "require", "BWidget") > class TableList(Widget): > def __init__(self, master=None, cnf={}, **kw): > Widget.__init__(self, master, 'tablelist::tablelist', cnf, kw) > > Worth a mention is the tablelist::tablelist - it took me 20 minutes to > work this out... tablelist the Tcl widget is in a Tcl namespace called > tablelist hence the :: notation I guess In bwidget, the class names and the tcl commands to create the widgets were generally identical, so I put a __init__ in a base class: def __init__(self, master, cnf={}, **kw): self._require(master) Tkinter.Widget.__init__(self, master, self.__class__.__name__, cnf, kw) Jeff
pgpWPoQXWrOjO.pgp
Description: PGP signature
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss