TIP 510: Add Rbc and Tkpath widgets to Tk

Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.
Author:         René Zaumseil <r.zaumseil@freenet.de>
State:          Draft
Type:           Project
Vote:           Done
Created:        5-Jun-2018
Keywords:       Tk
Tcl-Version:    8.7
Tk-Branch:      tip-510
Vote-Summary:   Rejected 1/3/1
Votes-For:      DKF
Votes-Against:  KBK, JN, FV
Votes-Present:  BG
Vote-Comments:  code not yet ready, needs porting to macOS; alternate
                might be to just co-distribute, just as TDBC is with Tcl


oo::class like widgets

The new widgets are implemented in C as oo::classes. The base class is tko::widget. These class create and handles the internal Tk_Window and provide cget and configure methods. The configure method has additional functionality to add or delete options. The new widget functionality is documented in the tkoWidget.n.md file.

The new widgets graph and path are implemented as oo::class. This will make it easy to extent the functionality. As an example see the file .../library/graph.tcl in which the method binding of the graph widget is implemented.

Enhanced configure functionality

configure args


If args is empty the method will return a sorted list of all configuration options.

configure -option

If we have one element in args starting with a minus sign ("-") then the method return the configuration list including the current value of the given -option.

configure -option value ..

If we have an even number list in args and the first element starts with a minus sign ("-") then the method does configure all the given option-value pairs. If an error occurs the the corresponding element is not set and the method gives an error. Alrready successfull set options remain.

configure init

This is an internal function used in constructing new widgets. It is used in the unknown method to initialize all options.

configure optionadd -synonym -option

Add a -synonym for a given -option. The -option needs not to be defined at this time.

configure optionadd -synonym dbnam dbclass ?default? ?flags?

Add a new option. If ?flags? is equal "1" then the option is readonly and can only be set in this call. Before adding a new option a -option method must created. The method will be called without any arguments. The method can access the new value using the tko(-option) array variable. If the method throws a n error the array variable will be reset to the old value.

configure optiondel -option

Delete the given option and unset the entry in the tko array variable. The created -option method's are not deleted. This is the task of the caller.

configure optionvar

The method return the global varname of the tko array variable holding all option values.

New widgets

Rbc aka "Refactored BLT Components" have graph widgets and Tk commands which are missing in Tk.

Tkpath is a 2D-canvas like widget modelled after SVG.

Tk has already frame, labelframe and toplevel widgets. These widgets have class like behaviour but are no real classes. It is p.e. not possible to add functionality to these widgets.

This TIP intends to add the following commands to Tk:

rbc::graph, rbc::stripchart and rbc::barchart as graph

To get the original functionality a -style option will be added. This option can only be set on creation time.

rbc::vector as graph::vector

The vector is currently only used inside the graph widget. The namespace hidden version leaves room for a first class command with the same name.

rbc::winop snap as tk snap

Only the snap functionality is needed here. The busy command already exists as "tk busy" :)

tkp::canvas as path

The new path widget will contain the SVG like items and an additional window item to include other windows. Support functions will be placed in the ::path namespace.

tko::frame tko::labelframe and tko::toplevel

These widgets have the same functionality like the normal tk widgets. They are implemented as oo::classes and it is possible to add/delete options.


Rbc commands

Tk has already adopted some of BLT/Rbc commands. Still missing are the above mentioned commands.

Rbc is available on sourceforge and github, but the development is stalled.

BLT, the orignal source, is at sourceforge. The author G. Howlett makes sporadic changes. Then there are large times without activity. It is not possible to estimate when a new version will be ready.

Modernizing Rbc and including it in Tk will give some great new widgets. There is also less risk because Rbc is already used in different projects.


The original developer of Tkpath passed away. There are some mirrors, but with no real development. More information could be found on https://wiki.tcl-lang.org/page/tkpath.

The intent of Tkpath was to substitute the Tk canvas. This leads to problems with advanced features (matrix transformations). Therefore the new path widget will only contain SVG like items. The only exception is the window item. This item is necessary to embed other widgets.


A patch implementing these changes is available in the fossil repository in the tip-510 branch.


Documentation is in markdown syntax understood by fossil and can therefore accessed online. The files will be put in the directory .../doc/.

C interface

Alle new functionality is in the following header files:

No functionality is currently exported. The new files are added to the makefiles.

The initialization function Tko_Init is added to the tkInt.h file and will be called in tkWindow.c.

C sources

C-source code will be put in the directory .../generic/tko/

Tcl source

Tcl-source code will be put in the directory .../library/


Test files will be put in the directory .../tests/tko/


Add options at class level:

oo::class create myWidget {
  superclass ::tko::frame
  variable tko
  method -myoption {} {puts $tko(-myoption)}
  method -myreadonly {} {puts $tko(-myreadonly)}
  constructor {optionlist arglist} {
    next [concat {
      {-myoption myOption MyOption value}
      {-myreadonly myReadonly MyReadonly value 1}
    } $optionlist] $arglist

Deal with optons at object level. This is the raw part. May be we should add some sugar to it.

myWidget .w
oo::objdefine .w method -o1 {} {puts $tko(-o1)}
oo::objdefine .w method -o2 {} {puts $tko(-o2)}
.w configure optionadd -o1 o1 O1 v1 1
.w configure optionadd -o2 o2 O2 v2
.w optiondel -o1

Widget option values are saved in an option array. The option name is the field name in the array. Additionally is an field "." containing the tk widget path name of the widget. The name of the option array variable can be retrieved using the following code: set myVar [.w configure optionvar] parray $myVar


See also discussion at the wiki.

A first voting was rejected, mostly because of the missing Mac implementation. See:


and with some analysis from Donal:


Open issues

Any help especially with the Mac implementation would be great!

And could please look someone with configure foo at the Makefile's



This document has been placed in the public domain.