Monday, May 31, 2010

gnocl::splashScreen -done!


Well, this is the first screenshot of the new gnocl::splashScreen widget. Its effectively up and running and I only now need to add a little more code to refresh the progress bar. Although it's a test script, the sample layout is the one I use for my own pet project, Jiumoluo, a customised text translation tool.

Here the demo script to show how it works:

# basic Tcl/Gnocl Script
#!/bin/sh \
exec tclsh "$0" "$@"
package require Gnocl

set logo1 [gnocl::pixBuf logo]

set ss [gnocl::splashScreen ]

$ss configure -backgroundColor red
$ss configure -backgroundImage splashScreen.png
$ss configure -onDestroy {
    puts 1
    puts 2
    puts 3
    }

set x 12
set y 50

# cairo prefers colour, range 0 - 1.0
set WHITE {1 1 1}
set RED {1 0 0}
set GREEN {0 1 0}
set BLUE {0 0 1}
set CYAN {0 1 1}
set MAGENTA {1 0 1}
set YELLOW {1 1 0}

$ss add appName "Jiumoluo" \
    -font "Sans 30 Normal Bold" \
    -color $WHITE \
    -position [list $x 70]
$ss add caption "Translator's Text Editor" \
    -font "Sans 18" \
    -color $WHITE \
    -position [list  $x 95 ]
$ss add version "Version: 0.5.0" \
    -font "Sans 14" \
    -color $WHITE \
    -position [list  $x 120 ]
$ss add byLine  "Created by William J Giddings." \
    -font "Sans 14" \
    -color $WHITE \
    -position [list  $x 140 ]
$ss add copyright "Distributed under the terms of the BSD Licence" \
    -font "Sans 12" \
    -color $WHITE \
    -position [list $x 200 ]

for {set i 0} {$i <100} {incr i} {
    $ss push "Loading packages ... package $i"
    
    $ss progress [expr $i / 100]
}

gnocl::window -child [gnocl::button -text "CLOSE SPLASH" -onClicked {catch { $ss delete } } ] -onDestroy {catch { $ss delete } ; exit}
gnocl::mainLoop











No comments: