ulis, 2007-09-20. Un package pour faire un ascenseur paramétrable tout azimuth.

Pourquoi
Faire un package d'ascenseur est le seul moyen de pouvoir adapter son apparence et son comportement.
Comment
Deux frames emboîtés, trois boutons, une foultitude de binds...
Description
C'est une scrollbar.
Usage :
uscrollbar $path ?-option value? uscrollbar create $path ?-option value? uscrollbar get ?-option? uscrollbar set ?-option value?... uscrollbar help $path cget ?-option? $path configure ?-option value?... $path get $path info ?name? $path set ?start stop?
Doc : http://wfr.tcl.tk/fichiers/pub/uscrollbar-doc.txt
Configuration
Installation
Utilisation
package require uscrollbar
Démo
# ================
#
# demo
#
# ================
lappend auto_path [pwd]
package require uscrollbar
. config -padx 2 -pady 2
# type selection
frame .t
label .t.type -text type: -width 10 -justify left
foreach type {classic mac next} \
{
radiobutton .t.$type -width 10 -text $type -value $type \
-command [list setType $type]
}
# text & scroll bars
frame .f -bd 1 -relief groove -padx 1 -pady 1
uscrollbar set -type mac
uscrollbar .f.vs -orient vertical -script {.f.t yview}
uscrollbar .f.hs -orient horizontal -script {.f.t xview}
text .f.t -bd 0 -highlightt 1 -wrap none \
-yscrollc {.f.vs set} -xscrollc {.f.hs set}
set line ""
for {set i 1} {$i < 100} {incr i} \
{
.f.t insert end $i\n
append line $i
}
.f.t insert end $line
.f.t see end
# display
grid .t.type .t.classic .t.mac .t.next -padx 10 -pady 10
grid .t -row 0 -sticky ew
grid .f -row 1 -sticky nsew
grid rowconfig . 1 -weight 1
grid columnconf . 0 -weight 1
# proc
proc setType {type} \
{
switch $type \
{
classic -
mac \
{
grid .f.t -row 0 -column 0 -sticky nsew
grid .f.vs -row 0 -column 1 -sticky nsew
grid .f.hs -row 1 -column 0 -sticky nsew
grid rowconfig .f 0 -weight 1
grid columnconf .f 0 -weight 1
}
next \
{
grid .f.t -row 0 -column 1 -sticky nsew
grid .f.vs -row 0 -column 0 -sticky nsew
grid .f.hs -row 1 -column 1 -sticky nsew
grid rowconfig .f 0 -weight 1
grid columnconf .f 1 -weight 1
}
}
.f.vs config -type $type
.f.hs config -type $type
}
# init
.t.mac invokeVoir Aussi
Discussion
ulis, 2007-09-20. J'ai longtemps cru qu'il n'existait pas de package en pur Tcl jusqu'à ce que je découvre cscrollbar.
Trop tard ! j'avais déjà fait uscrollbar. Dont j'aurai besoin pour compléter le package map (qui comprendra une scrollbar utilisant les maps).
Catégorie Paquet | Catégorie Interface utilisateur