Skip to main content

Posts

Showing posts from October, 2019

Serialize/Deserialize a Gnocl Tree Widget

The options and command set of the gnocl::tree widget allow for easy creation and editing of data arranged and displayed in a tree structure. What is lacking in the Gtk api is an equivalent of the GtkTreeView serialize and deserialize functionality. Creating a similar offering for the gnocl::tree is not altogether difficult to implement because it is possible to sequentially extract data from a tree which can then be saved for later use (serialize). When the data is next needed for use, it can be sequentially added to a new tree widget (deserialize). The sampe code below will produce the following,  the tree on the left is created through the direct addtion of data, whereas the tree on the right (with treelines) is created by deserializing the data set of the first tree. When data contained in a tree was serialzed the following list was returned and save to disk. Each line of list represents a row in the tree where the first item is the node path, and the second item, the

Cloning a Gnocl Widget Made Simple

A while ago I saw a StackoverFlow request about cloning widgets. Ok, the request was about cloning Gtk widgets in C, but here's the solution in Tcl using the Gnocl package. For a some time now its been possible to query the Gnocl package about the various options and commands available to each widget and its this ability combined with the cget (configuration get) command that allows property and data values to be extracted from a widget. Here's a very simple example based upon a button.  #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" if { [catch { package present Gnocl } ] } { package require Gnocl } ## clone specified widget #/param    wid the widget to clone #/returns   wid of newly created clone object # proc gnocl::clone { wid } {                         foreach item [split [string trim [gnocl::[$wid class] options]] \n] {                 # get list of options from internal help,                 # trim away option i

Recent Changes. September 2019.

 Just a few enhancements to the code this month.    gnocl::application         o new option -title   gnocl::labelEntry, gnocl::labelText, gnocl::labelWidget         o new option -orientation   gnocl::window         o -geometry, list of four integers x, y, width, height.         o cget -geometry returns same values as command geometry   gnocl::label         o cget -baseColor now returns correct value.