TkinterTreectrl
The TkTreectrl module wraps the treectrl tk extension for use with
Python/Tkinter.
I built the module on top of treectrl-2.1, so compatibility with older
version of the treectrl widget cannot be guaranteed.
The treectrl widget allows to create fancy things like sortable multi
column listboxes and hierarchical tree views. An impressive set of
screenshots of things you can do with treectrl can be found at the
treectrl web page.
Installation
Unpack the zip-archive and run:
# python setup.py install
or simply copy the TkTreectrl folder into your Python installation's site-packages directory.
Of course you will also have to install
the Tcl/Tk treectrl package
to be able to use the TkTreectrl module.
On windows systems simply download the tktreectrl-2.x.x-Tk8.x-win32.zip archive
suitable for the Tk version in use and copy the contents of the archive into
your Python installation's tcl folder.
On unix systems you will probably have to compile the treectrl package from the sources.
To do so, download and unpack the latest tktreectrl-2.x.x.tar.gz archive, cd into
the tktreectrl-2.x.x directory and type (as root)
# ./configure && make && make install
If this fails it is most likely because
configure cannot find the Tcl
installation. In this case (or if you have multiple versions of Tcl/Tk installed)
you have to pass the paths to the tclConfig.sh and tkConfig.sh
to
configure , as for example:
# ./configure --with-tcl=/usr/lib/tcl8.4 --with-tk=/usr/lib/tk8.4
# make
# make install
Documentation
There's a html
reference manual
included in the download. For more detailed information please refer to the
treectrl man
page (included in the treectrl distribution).
Bugs
Please report any bugs to <klappnase (at) freakmail (dot) de>.
Usage
Once the TkTreectrl package is installed it is safe to do:
from TkTreectrl import *
This adds the widget classes: Treectrl, MultiListbox, ScrolledTreectrl,
ScrolledMultiListbox and ScrolledWidget into the current namespace.
Consult the scripts in the demo directory for a few usage examples.
News
Nov. 30 2006: TkinterTreectrl-0.6
The major change in this release is the introduction of a few new widget
classes:
MultiListbox is a Treectrl widget set up to work as a (more or less)
full-featured and very flexible multi column listbox widget.
The
ScrolledTreectrl and
ScrolledMultiListbox classes use
ideas shamelessly stolen from
Pmw.ScrolledListbox to add one or two
static or automatic scrollbars to the widgets. They both inherit from the
ScrolledWidget class that is supposed to make it easy to add
scrollbars to any other Listbox or Canvas alike Tkinter widget.
Changes to the Treectrl widget:
I added the second (optional)
last argument to
column_delete(), which is new in treectrl-2.1.1 .
A bug in
item_sort() was fixed: it is now possible to use the
command and
mode options together, which may be useful if
you want to use the same command in
increasing and
decreasing mode. To enable this,
mode now defaults to
None instead of
ascii.
Caution: this change may be backwards incompatible in some cases!
It is also possible now to specify a sequence of strings as
mode,
like
mode=("integer", "decreasing").
The class variables
TreectrlVersion, _last_element and
_last_style were accidentally handled as instance variables, this
has been fixed.
Jan. 22 2007: TkinterTreectrl-0.7
Added new features from treectrl-2.2 :
new methods:
bbox(), column_tag_add(), column_tag_expr(), column_tag_names(),
column_tag_remove(), item_tag_add(), item_tag_expr(), item_tag_names(),
item_tag_remove(), item_descendants(), item_enabled().
methods accepting new (optional) arguments:
selection_get(), column_count(), item_count()
Bug fixes:
item_id() was broken if no matching item exists; item_dump() tried to convert
textual strings into integers
Interface changes:
item_id() now returns a tuple of matching ids instead of an integer; this is
necessary, so the new feature of multiple items matching the same tag can be
used.
CAUTION: this is backwards incompatible!
Nov. 10 2007: TkinterTreectrl-0.8
In previous versions "package require treectrl" was only called when creating
the first Treectrl widget which seemed to fail in some situations; now on
every widget creation "package require treectrl" is called.
A __version__ attribute was added to __init__.py .
Besides this I replaced the happydoc html docs with those generated by a
hacked standard pydoc which makes the docs somewhat easier to handle.
Aug. 08 2010: TkinterTreectrl-1.0
I updated the Treectrl class and the documentation to reflect the changes and new
features since treectrl-2.2 to treectrl-2.2.10 .
A bug in Treectrl.selection_get() that caused a TypeError to be raised
when selection_get() was called with "first" and/or "last" arguments and a
single item was currently selected is now fixed.
MultiListbox.insert() now returns the item id of the newly created item.
Besides this I finally updated the version to 1.0 ; I've been using the TkTreectrl
modules for years now without any problems, so I believe it deserves it.
Nov. 20 2012: TkinterTreectrl-2.0
This release brings a couple of major improvements:
- Python-3 compatibility!
The same module code now works with Python2
and Python3 (tested on debian squeeze with Python-2.6.6 and Python-3.1.3).
- Themed scrolled widgets
The ScrolledWidget class now automagically uses
themed widgets if ttk is present.
In order to keep backwards compatibility intact, ttk-incompatible
configuration options that are passed to the scrolled widget's subwidgets, as "bd"
or "troughcolor" will be silently ignored if ttk widgets are in use.
- New methods and options
The Treectrl widget now includes the new methods up to treectrl version 2.3.2 .
May 06 2013: TkinterTreectrl-2.0.1
I fixed a bug in the MultiListbox class that prevented lists from being accepted as argument for the
columns option (thanks to Василий Молостов).
Feb. 19 2018: TkinterTreectrl-2.0.2
Fixed a small but serious bug that stopped the Treectrl widget from working properly
with Python versions >= 3.5 . With Python-3.5 a modified _getints() function was
introduced in tkinter which caused exceptions to be raised with Treectrl.
As a workaround Treectrl._getints() is now overridden with the same code Python2 uses.
Download
TkinterTreectrl is available on its
sourceforge site
Contact
Any comments, bug reports and suggestions are highly welcome.
Please mailto:
Michael Lange <klappnase (at) users (dot) sourceforge (dot) net>
or open a ticket at TkinterTreectrl's
bug tracker.
License
TkinterTreectrl is released in the public domain.
Hosted by: