gnocl::dial

WJG (18/03/18) The gnocl::dial widget is not a binding to any of the core Gtk widgets or, for that matter, a custom widget derived from Gtk classes along the lines of the gnocl::tickerTape widget. From the Tcl side of things, there is no difference between the scripting interface, they work seamlessly together. Creating custom widgets like the dial using the GtkDrawingArea as the base object and making Cairo calls to make the direct drawing has its advantages: less to learn, no extra C modules and less prone to the downstream effects of any changes to the Gtk API. This widget could, of course, have been implemented in Tcl/Gnocl too, there so much choice in life...

WikiDBImage GnoclDial

#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

set val1 50

gnocl::dial -name dial1 -variable val1 -value 75.0 -digits 2 -tooltip "gnocl::dial" -description Oranges
gnocl::dial -name dial2 -variable val1 -value 75.0 -digits 5 -tooltip "gnocl::dial" -description Apples
gnocl::dial -name dial3 -variable val1 -value 75.0 -digits 2 -tooltip "gnocl::dial" -description Banannas

gnocl::label -name label -textVariable val1
set ent [gnocl::entry -name entry -onActivate { set val1 [format "%.2f" %t] ; #dial set %t}]
gnocl::scale -name scale -orientation horizontal -variable val1 -valuePos right -digits 2
gnocl::button -name button -icon %#Yes -onClicked { demo }

gnocl::vBox -name box -padding 15 

#box add [scale] 
box add [dial1] -expand 1 -fill {1 1}
box add [dial2] -expand 1 -fill {1 1}
box add [dial3] -expand 1 -fill {1 1}
box add [label]
box add [entry]
box add [scale]
box add [button]

set win [gnocl::window -name window -child [box] ] ;#-setSize 0.125

dial1 configure -variable val1
dial1 configure -value 50.00


proc demo {} {
for {set i 0} {$i<=100} {incr i} {
        #set val1 [expr 100 * rand()]
        set ::val1 $i.00
        entry set $::val1
        after 25
        gnocl::update
}
after 25
for {set i 0} {$i<=100} {incr i} {
        #set val1 [expr 100 * rand()]
        set ::val1 [expr 100.00-$i]
        entry set $::val1
        after 25
        gnocl::update
}
}


dial1 configure -scaleColor #FFFFFF -pointerColor #000000 -showValue yes -textColor white
dial2 configure -scaleColor #F6F6C5 -pointerColor blue -tickColor black -showValue yes -active 0
dial3 configure -sensitive 0 -pointerColor blue -tickColor black -textColor green -showValue yes


gnocl::update

dial3 configure -sensitive 1 -onValueChanged {puts %v}