basegui - combobox - dgw - drawcanvas - hyperhelp - sbuttonbar - seditor - sfilebrowser - sfinddialog - sqlview - statusbar - tablelist - tlistbox - tvmixins

dgw::tvmixins 0.2

Detlef Groth, Schwielowsee, Germany

2020-04-10

NAME

dgw::tvmixins - implementations of various extensions for the ttk::treeview* widget which can be added dynamically using chaining of commands at widget creation.

TABLE OF CONTENTS

SYNOPSIS

package require Tk
package require snit
package require dgw::tvmixins
::dgv::tvband [ttk::treeview pathName ?options?] ?options?
::dgv::tvfilebrowser [ttk::treeview pathName ?options?] ?options?
::dgv::tvksearch [ttk::treeview pathName ?options?] ?options?
::dgv::tvsortable [ttk::treeview pathName ?options?] ?options?
::dgv::tvtooltip [ttk::treeview pathName ?options?] ?options?
::dgv::tvfilebrowser [dgw::tvband [dgw::tvsortable [dgw::tvsearch \
     [ttk::treeview pathName ?options?] ?options?] ?options?] ?options?]

DESCRIPTION

The package dgw::tvmixins implements several snit::widgetadaptors which extend the standard ttk::treeview widget with different functionalities. Different adaptors can be chained together to add the required functionalities.

WIDGET COMMANDS

dgw::tvband [ttk::treeview pathName] ?-option value ...?

Creates and configures the dgw::tvband widget using the Tk window id pathName and the given options. Please note that this adaptor might have performace issues and that the ttk::treeview widget of Tk 8.7 probably will have a configure option -striped and -stripedbackgroundcolor which can replace this adaptor.

The following option is available:

Example:

ttk::tvband [ttk::treeview .fb -columns [list A B C] -show heading
foreach col [list A B C] { .fb header $col -text $col }
for {set i 0} {$i < 20} {incr i 1} {
   .fb insert {} end -values [list  [expr {int(rand()*100)}] \
                  [expr {int(rand()*1000)}] [expr {int(rand()*1000)}]]
}
pack .fb -side top -fill both -expand yes

dgw::tvfilebrowser [ttk::treeview pathName] ?-option value ...?

Creates and configures the dgw::tvfilebrowser widget using the Tk window id pathName and the given options.

The following option is available:

The following method(s) is(are) available:

Example:

dgv::tvfilebrowser [dgw::tvsortable [dgw::tvsearch [dgw::tvband \
         [ttk::treeview .fb]]] \
        -sorttypes [list Name directory Size real Modified dictionary]]
pack .fb -side top -fill both -expand yes

dgw::tvksearch [ttk::treeview pathName] ?-option value ...?

Creates and configures the dgw::tvksearch widget using the Tk window id pathName and the given options. With this widget you can use the Home and End keys for navigation and further letter typing starts searching in the first column shifting focus and display to the current matching entry.

There are currenlty no options or methods available for this widget.

Example:

dgv::tvfilebrowser [dgw::tvsearch [ttk::treeview .fb]] \
pack .fb -side top -fill both -expand yes

dgw::tvsortable [ttk::treeview pathName] ?-option value ...?

Creates and configures the dgw::tvsortable widget using the Tk window id pathName and the given options.

The following option is available:

The widget further provides the following event:

Example:

dgw::tvsortable [ttk::tvband [ttk::treeview .fb -columns [list A B C] -show heading] \
        -sorttypes [list A real B real C integer]]
foreach col [list A B C] { .fb header $col -text $col }
for {set i 0} {$i < 20} {incr i 1} {
   .fb insert {} end -values [list  [expr {int(rand()*100)}] \
                  [expr {int(rand()*1000)}] [expr {int(rand()*1000)}]]
}
pack .fb -side top -fill both -expand yes

dgw::tvtooltip [ttk::treeview pathName] ?-option value ...?

Creates and configures the dgw::tvtooltip widget using the Tk window id pathName and the given options.

There are currently no options available.

The widget provides the following events:

Example:

set fb [dgw::tvtooltip [dgw::tvfilebrowser [ttk::treeview .fp2] \
              -directory . -fileimage movie -filepattern {\.(3gp|mp4|avi|mkv|mp3|ogg)$}]
pack $fb -side top -fill both -expand yes
pack [::ttk::label .msg -font "Times 12 bold" -textvariable ::msg -width 20 \
      -background salmon -borderwidth 2 -relief ridge] \
      -side top -fill x -expand false -ipadx 5 -ipady 4
bind $fb <<RowEnter>> { set ::msg "  Entering row %d"}
bind $fb <<RowLeave>> { set ::msg "  Leaving row %d"}

EXAMPLE

In the example below we create a filebrowser widget using all the widget adaptors for demonstration purposes.

# wrapper function 
proc fbrowse {path args} {
     set fb [dgw::tvtooltip [dgw::tvksearch [dgw::tvfilebrowser [dgw::tvband \
        [ttk::treeview $path]] {*}$args]]]
     return $fb
}
set f [ttk::frame .f]
set fb [fbrowse $f.fb]
pack $fb -side left -fill both -expand yes
pack [ttk::scrollbar $f.yscroll -command [list $fb yview]] \
      -side left -fill y -expand false
$fb configure -yscrollcommand [list $f.yscroll set]
pack $f -side top -fill both -expand true
# demo tvtooltip
pack [::ttk::label .msg -font "Times 12 bold" -textvariable ::msg -width 20 \
     -background salmon -borderwidth 2 -relief ridge] \
     -side left -fill x -expand false -ipadx 5 -ipady 4
bind $fb <<RowEnter>> { set ::msg "  Entering row %d"}
bind $fb <<RowLeave>> { set ::msg "  Leaving row %d"}

INSTALLATION

Installation is easy you can install and use the dgw::tvmixins package if you have a working install of:

For installation you copy the complete dgw folder into a path of your auto_path list of Tcl or you append the auto_path list with the parent dir of the dgw directory. Alternatively you can install the package as a Tcl module by creating a file dgw/tvmixins-0.2.tm in your Tcl module path.

DEMO

Example code for this package can be executed by running this file using the following command line:

$ wish tvmixins.tcl --demo

The example code used for this demo can be seen in the terminal by using the following command line:

$ tclsh tvmixins.tcl --code

DOCUMENTATION

The script contains embedded the documentation in Markdown format. To extract the documentation you should use the following command line:

$ tclsh tvmixins.tcl --markdown

This will extract the embedded manual pages in standard Markdown format. You can as well use this markdown output directly to create html pages for the documentation by using the --html flag.

$ tclsh tvmixins.tcl --html

If the tcllib Markdown package is installed, this will directly create a HTML page tvmixins.html which contains the formatted documentation.

Github-Markdown can be extracted by using the --man switch:

$ tclsh tvmixins.tcl --man

The output of this command can be used to feed a Markdown processor for conversion into a html, docx or pdf document. If you have pandoc installed for instance, you could execute the following commands:

tclsh ../tvmixins.tcl --man > tvmixins.md
pandoc -i tvmixins.md -s -o tvmixins.html
pandoc -i tvmixins.md -s -o tvmixins.tex
pdflatex tvmixins.tex

SEE ALSO

CHANGES

TODO

AUTHORS

The dgw::tvmixins widget was written by Detlef Groth, Schwielowsee, Germany.

Copyright

Copyright (c) 2020 Dr. Detlef Groth, E-mail: detlef(at)dgroth(dot)de

LICENSE

dgw::tvmixins package, version 0.2.

Copyright (c) 2019-2020 Dr. Detlef Groth, E-mail: detlef(at)dgroth(dot)de

This library is free software; you can use, modify, and redistribute it for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions.

This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.