The basic implementation of the progressBar widget allows the setting of the "fraction" property of the GtkProgressBar but using this options requires more on the Tcl-side than it needs to.
Combination of the new options -range and -steps along with the new sub-commands step, incr and reset help to simplify matters.
For simple lists use the step subcommand along with the the -steps option to indicate the progress of a small, known number of steps where feedback on the completion of each step is required. Setting the -steps option to 10, for example, will set the widget "fraction" property to 0.1 (1/10, i.e. 10%). Following this each time the step sub-command is called, the widget bar will expand in length by 10% until it reaches 100%. The step sub-command accepts an additional argument which will set the text content of the bar.
set modules [list \
apple.tcl \
blackberry.tcl \
cherry.tcl \
damson.tcl \
elderberry.tcl \
fig.tcl \
gooseberry.tcl \
hawthorn.tcl]
proc do_progress { box modules } {
set steps [llength $modules]
set pb [gnocl::progressBar]
$pb configure -steps $steps -showText 1
$box add $pb
$pb reset
for {set i 0} {$i <= $steps} {incr i} {
after 300
$pb step [lindex $modules $i]
}
if ( [$box class] == statusBar ) {
$box unpack $pb
} else {
$box remove $pb
}
}
In the above example, the reset subcommand was used to set the display fraction to 0.0 and text to and empty string.
More complicated operations, such as sifting through a large number of database records, may only need indication of relative progress. In other words, specific feedback on each increment in the batch process is not required. In this case the incr sub-command should be used. As with step above, an optional string can be specified, but if this field is left empty and the widget -showText option set to 1, the percentage completion of the bar will be displayed.
set range [ expr 1000 + round (rand() * 10000) ]
set steps 20
$pb3 configure -steps $steps -range $range -showText 1
for {set i 0 } {$i < $range} {incr i} {
# do something or delay
after 1
$pb3 incr
}
Thursday, August 11, 2016
Saturday, May 28, 2016
gnocl::toolPalette -now implemented
I'm pleased to announce that, after much frustration, the gnocl binding to the GtkToolPalette is now complete. To try it out, download and compile the latest nightly build from Sourceforge.
And here's the test script:
#---------------
# test-toolPalette.tcl
#---------------
# Created by Dr. William J Giddings, 2016
#
#!/bin/sh
#\
exec tclsh "$0" "$@"
package require Gnocl
set tp [gnocl::toolPalette -tooltip TOOL-PALETTE -orientation vertical]
puts >[$tp commands]
puts >[$tp options]
set ig(1) [$tp addGroup -label MyGroup1]
puts >>[$ig(1) commands]
puts >>[$ig(1) options]
$ig(1) addItem -icon %#New -text XXX -tooltip YYY -data £££ -onClicked {puts "Hello from %w %d"}
$ig(1) addItem -icon %#Cut -text ABC -tooltip ZZZ -onClicked {puts "Hello from %w"}
$ig(1) addItem -icon %#Copy -tooltip WWW -onClicked {puts "Hello from %w"}
set pi [$ig(1) addItem -icon %#Paste -tooltip AAA -onClicked {puts pi} ]
puts ....$pi....
puts "class = [$pi class]"
puts >>>[$pi commands]
puts >>>[$pi options]
$pi configure -onClicked { puts "BOING! BOINGG!" } -icon %#Stop
if 1 {
set ig(2) [$tp addGroup -label MyGroup2 -collapsed 1 -sensitive 0]
$ig(2) addItem -icon %#New -text XXX -tooltip YYY -onClicked {puts "Hello from %w"}
$ig(2) addItem -icon %#Cut -text ABC
$ig(2) addItem -icon %#Copy
$ig(2) addItem -icon %#Paste
}
parray ig
gnocl::window -child $tp -width 200 -height 400
And here's the test script:
#---------------
# test-toolPalette.tcl
#---------------
# Created by Dr. William J Giddings, 2016
#
#!/bin/sh
#\
exec tclsh "$0" "$@"
package require Gnocl
set tp [gnocl::toolPalette -tooltip TOOL-PALETTE -orientation vertical]
puts >[$tp commands]
puts >[$tp options]
set ig(1) [$tp addGroup -label MyGroup1]
puts >>[$ig(1) commands]
puts >>[$ig(1) options]
$ig(1) addItem -icon %#New -text XXX -tooltip YYY -data £££ -onClicked {puts "Hello from %w %d"}
$ig(1) addItem -icon %#Cut -text ABC -tooltip ZZZ -onClicked {puts "Hello from %w"}
$ig(1) addItem -icon %#Copy -tooltip WWW -onClicked {puts "Hello from %w"}
set pi [$ig(1) addItem -icon %#Paste -tooltip AAA -onClicked {puts pi} ]
puts ....$pi....
puts "class = [$pi class]"
puts >>>[$pi commands]
puts >>>[$pi options]
$pi configure -onClicked { puts "BOING! BOINGG!" } -icon %#Stop
if 1 {
set ig(2) [$tp addGroup -label MyGroup2 -collapsed 1 -sensitive 0]
$ig(2) addItem -icon %#New -text XXX -tooltip YYY -onClicked {puts "Hello from %w"}
$ig(2) addItem -icon %#Cut -text ABC
$ig(2) addItem -icon %#Copy
$ig(2) addItem -icon %#Paste
}
parray ig
gnocl::window -child $tp -width 200 -height 400
Tuesday, May 17, 2016
Gnocl for Raspberry PI
After a couple of hours work this evening (largely fixing errors in the distribution makefile) I successfully compiled Gnocl to run on my newly acquired Raspberry PI3. It was much, much easier than expected. No changes to the source code whatsoever.
I now need to create a download page from Sourceforge. Currently running Ubuntu Mate on my Pi. Very nice, very pleased. Much faster than my sturdy old 32-bit workhorse.
Here's a snippet from a screenshot.
I now need to create a download page from Sourceforge. Currently running Ubuntu Mate on my Pi. Very nice, very pleased. Much faster than my sturdy old 32-bit workhorse.
Here's a snippet from a screenshot.
Sunday, March 27, 2016
A Few Recent Enhancements...
Time has flown very quickly over the past few months, with much of my coding time dedicated to working on other projects. These have identified a the need for a few modifications to the Gnocl code which make GUI composition easier such as explicit order placement of child widgets in boxes and the harmonization of value extraction for text entry widgets.
Here is a summary of changes since the previous blog posting.
2016-03:
gnocl::box, gnocl::hBox, gnocl::vBox
o added -position option to the "add" subcommand.
2015-12:
gnocl::entry
o added commands: 'selectionBounds', 'insert', and 'erase' (remove specified range of characters from entry buffer).
gnocl::button
o fixed problems arising from using the "delete" command.
gnocl::text
o added -nomarkup switch to the "get" command to override return of formatting markup.
2015-11:
gnocl::progressBar
o problem with very slow internal update of the GTK 'text' property worked around, value set explicitly in widget configure function.
gnocl::entry
o added 'select' as synonym for 'selectRegion', harmonizes with text commands.
o added 'start' and 'end' keywords to the 'select'/'selectRegion' commands.
Here is a summary of changes since the previous blog posting.
2016-03:
gnocl::box, gnocl::hBox, gnocl::vBox
o added -position option to the "add" subcommand.
2015-12:
gnocl::entry
o added commands: 'selectionBounds', 'insert', and 'erase' (remove specified range of characters from entry buffer).
gnocl::button
o fixed problems arising from using the "delete" command.
gnocl::text
o added -nomarkup switch to the "get" command to override return of formatting markup.
2015-11:
gnocl::progressBar
o problem with very slow internal update of the GTK 'text' property worked around, value set explicitly in widget configure function.
gnocl::entry
o added 'select' as synonym for 'selectRegion', harmonizes with text commands.
o added 'start' and 'end' keywords to the 'select'/'selectRegion' commands.
Thursday, November 26, 2015
Recent Changes
The past couple of months have seen some inprovements to the core code, including an number of notable fixes. The most signfiicant, to my mind, is the a reliable implementation of text widget pango markup.
2015-11:
gnocl::dialog
o fixed problems with closing and deleting the dialog.
gnocl::text
o fixed problems with inserting pango markup strings containing non ASCII characters.
o new options
-balanceQuotes, handles matching double and single quotes along with apostrophe-s
-swap, swap keyboard string sequences for items in a matched list (e.g --> swapped for right arrow graphic U+2192)
o enhanced 'get' command to respond to the setting of the -useMarkup option, command getMarkup deprecated.
2015-10:
gnocl::text
o getMarkup subcommand now retrieves stable pango markup strings.
o new option: -show
o added: -rolloverMode, one of: non, foreground, background or both.
o use of -rollOverFgColor and rollOverBgColor reinstated
o resolved need to set -onMotion handler in order to engage rollover effect rendering.
gnocl::entry
o problems with getSelection fixed.
o new sub-command: selectRegion.
New widget, gnocl::acceleratorGroup
One of the major tasks ahead for me now is updating the documentation, and issuing an incremental release. At ths point plans need to be made regarding the migration to Gtk3+. Whilst the transition will certainly offer new resources to the Gnocl coder, a major overall of the sourcecode is anticipated, perhaps alongside the retirement of some widgets due to core deprecation.
2015-11:
gnocl::dialog
o fixed problems with closing and deleting the dialog.
gnocl::text
o fixed problems with inserting pango markup strings containing non ASCII characters.
o new options
-balanceQuotes, handles matching double and single quotes along with apostrophe-s
-swap, swap keyboard string sequences for items in a matched list (e.g --> swapped for right arrow graphic U+2192)
o enhanced 'get' command to respond to the setting of the -useMarkup option, command getMarkup deprecated.
2015-10:
gnocl::text
o getMarkup subcommand now retrieves stable pango markup strings.
o new option: -show
o added: -rolloverMode, one of: non, foreground, background or both.
o use of -rollOverFgColor and rollOverBgColor reinstated
o resolved need to set -onMotion handler in order to engage rollover effect rendering.
gnocl::entry
o problems with getSelection fixed.
o new sub-command: selectRegion.
New widget, gnocl::acceleratorGroup
One of the major tasks ahead for me now is updating the documentation, and issuing an incremental release. At ths point plans need to be made regarding the migration to Gtk3+. Whilst the transition will certainly offer new resources to the Gnocl coder, a major overall of the sourcecode is anticipated, perhaps alongside the retirement of some widgets due to core deprecation.
Saturday, September 12, 2015
Summary of Changes for the Past Couple of Months
Haven't posted much to the Blog for the past couple of months but there has been a steady stream of enhancements put into the sources. Here's a brief summary of the changes over the past few weeks. Download the latest nightly build from Sourceforge.
2015-09:
gnocl::box, gnocl::hBox, gnocl::vBox
o added commands: show, hide
gnocl::notebook
o added commands hidePage, showPage
o added options -tabAlign, -tabWidthChars, -tabUseMarkup
2015-08:
new command, gnocl::keyName
2015-07:
gnocl::accelarator module completely re-written.
A further area of development that I've been working on recently is providing a realiable framework for creating gnocl driven widgets and megawidgets. By widgets, the idea is the use of the drawing area object to create unique items, using internal scripting in order to drive cairo. To keep the Tcl side of the scripting to a minimum, a small number of utiltiy commands currently being tested will find their way into the main package module. More about this in the next posting.
Saturday, July 25, 2015
Reworked the gnocl::dialog soucecode
With a few notable changes, the dialog.c module was legacy code which tried to do too much. In attempting to add stock icons and embedded buttons so many irreversible bugs had crept into the code which made it almost impossible to prevent an application crashing. A quick glance at the gtk style guide makes no mention to of the use of Stock icons in dialog buttons so, the best way forward was to retire the inclusion of icons and predefined buttons in favour of something much simpler and far less prone to crashing. The following extract from the development documentation highlights the changes made.
For more complex display strings the use of an associate value makes response parsing simpler.
Use underscore ("'_") to indicate accelerators, e.g.
Method 3) Default.
If the -buttons option is not specified then a single "Ok" button will be added to the dialog. This would be equivalent to using:
To add previously created button widgets, use the -actionButtons option.
- -buttons
- type: list (default: Ok)
- List of buttons to be displayed consisting of a list of display strings with optional values.
Method 2) String and Value.
- Method 1) Simple Strings.
- In this case the text string will be used as the basis of the returned value stripped of any percent string underscore markup.
Clicking the "Yes" button will return "Yes" from the [gnocl::dialog] command or by substitution of the %v parameter in the -onResponse callback script..-buttons "%__Yes %__No"
For more complex display strings the use of an associate value makes response parsing simpler.
Use underscore ("'_") to indicate accelerators, e.g.
-buttons [list [list {%_P_ortable Document Format} pdf] [list {%_O_pen Document Text ODT} odt]
As with method 1), clicking the "Portable Document Format
" button will return "pdf" from the [gnocl::dialog] command or by
substitution of the %v parameter in the -onResponse callback
script.. Method 3) Default.
If the -buttons option is not specified then a single "Ok" button will be added to the dialog. This would be equivalent to using:
Note: The use of the %_ prefix is optional and retained for legacy.-buttons "%__Ok"
To add previously created button widgets, use the -actionButtons option.
Subscribe to:
Posts (Atom)
-
Given this module some attention today. Added some of the more package wide options to the module and created customised handler for settin...
-
Over the past few programming sessions I've been working on producing a central point, a dashboard, around which it's possible to se...
-
Spent some time today creating some simple howto-tutorials on creating standalone Tcl/Gnocl applications using freewrap. The process is almo...

