Content
This tko package implements oo class widgets. It provides the following commands:
- ::tko procedure to create oo widgets and deal with options.
- _tko class method to deal with options.
- ::tko::toplevel oo class version of ::toplevel widget.
- ::tko::frame oo class version of ::frame widget.
- ::tko::labelframe oo class version of ::labelframe widget.
- ::tko::graph oo class version of rbc graph widget.
- ::tko::vector vector command used in graph.
- ::tko::path oo class version of tkpath widget.
- ::tko::matrix matrix transformations in path
- ::tko::style styles in path
- ::tko::gradient gradients in path
- ::tko::surface surface drawing in path
The package was developed with data from tip 556. It can be build with tcl/tk 8.7. Currently it is using tcl/tk internals!
Download
Sources
The tko repository is hosted at: http://chiselapp.com/user/rene/repository/tko/
Binaries
Ready to run binaries can be found inside: https://sourceforge.net/projects/kbskit/files/zipkit
Documentation
Documentation is available in md-Format in the .../doc/ directory.
tko.3.md
tko C interfacetko.n.md
tko Tcl interfacetko_graph.n.md
tko graph widgettko_vector.n.md
tko vector commandtko_path.n.md
tko path widget
Examples
# # Configurable object # oo::class create A { ::tko initclass } A create a1 a1 configure ==> # Add class option ::tko optiondef A -o1 {o1 O1 v1 {}} {set tko(-o1) x} A create a2 a2 configure ==> {-o1 o1 O1 v1 v1} # Add object option oo::define A method mycmd {args} {my {*}$args} a2 mycmd _tko optionadd -o2 {o2 O2 v2 {}} {variable tko; set tko(-o2) x} a2 configure ==> {-o1 o1 O1 v1 v1} {-o2 o2 O2 v2 x} # # Wrap an existing widget # oo::class create B { ::tko initwrap frame {-class -container -colormap -visual} {} } B .b lindex [.b configure] 0 ==> {-background background Background SystemButtonFace SystemButtonFace} # # Create a new widget class. # oo::class create C { ::tko initfrom ::tko::frame constructor {args} {next {*}$args} destructor {next} method mycmd {args} {my {*}$args} } # Hide all inherited frame options ::tko optionhide C {*}[::tko optionhide C] ::tko optionshow C ==> -class -visual -colormap -container -borderwidth ... C .c .c configure ==> # Add a new option oo::define C method -o1 {} {puts $tko(-o1)} ::tko optiondef C -o1 {o1 O1 v1 {}} ::tko optionhide C ==> -o1 # Add another option ::tko optiondef C -o2 {o2 O2 v2 {}} {puts $tko(-o2)} ::tko optionhide C ==> -o1 -o2 # Add options at object level: C .c1 .c1 mycmd _tko optionadd -o3 {o3 O3 v3 {}} {my variable tko; puts $tko(-o3)} .c1 configure ==> {-o1 o1 O1 v1 v1} {-o2 o2 O2 v2 v2} {-o3 o3 O3 v3 v3} # Show all frame options again .c1 mycmd _tko optionshow {*}[.c1 mycmd _tko optionshow] llength [.c1 configure] ==> 24 # Intercept options oo::define C method -width {} { puts "[my cget -width]->$tko(-width)->[set tko(-width) 100]" } .c1 configure -width 1 ==> 0->1->100 # Use option database for styles: option add *background red grid [tko::frame .f] -sticky nesw grid [label .f.l -text abc] grid columnconfigure . 1 -weight 1 option add *background blue tko eventoption
License & support
This work is under BSD license.
Acknowledgements
rbc aka Refactored BLT Components, includes data vectors and graph widgets for developing line and bar graph applications in Tcl/Tk. Original sources are from https://sourceforge.net/projects/rbctoolkit/.
tkpath is a 2D drawing widget for tcl/tk modelled after its SVG counterpart at http://www.w3.org/TR/SVG11/. Original sources are from http://hg.code.sf.net/p/tclbitprint/hg and changes from http://androwish.org.