Concepts

Percent String

Some widget options expect a percent string as value. A percent string is a string which starts with a percent sign (%). The second character determines the type of percent string. The following types are defined:

Types of Percentstring

!

Simple string which is not further parsed.

%

Simple string which starts with a percent string and which is not further parsed.

_ (underline)

The next underline is removed and the following character is underlined and used as keyboard accelerator.

#

The following string is used as name of a stock item. Dependent on the widget the name, accelerator and/or image of the stock item is used.

Not every stock item is valid in every context. The following example shows all items which are valid as text option of the button widget.

set table [gnocl::table -borderWidth 0 -rowSpacing 0 -columnSpacing 0]
set items ""
foreach el [lsort [gnocl::info allStockItems]] {
   if { [catch {set but [gnocl::button -text "%#$el"]} ] == 0 } {
      lappend items $but
      if { [llength $items] == 6 } {
         $table addRow $items -fill 1
         set items ""
      }
   }
}
if { [llength $items] > 0 } {
   $table addRow $items -fill 1
}
gnocl::window -title "Stock Buttons" -child $table

<

The following string is parsed as markup string. Additional the next underline is removed and the following character is underlined and used as keyboard accelerator.

/

The following string is interpreted as file name.

Example:

set box [gnocl::box -orientation vertical]
$box add [gnocl::button -text "Simple String"]
$box add [gnocl::button -text "%!Another Simple String"]
$box add [gnocl::button -text "%%Simple String which starts with %"]
$box add [gnocl::button -text "%_Underlined _String"]
$box add [gnocl::button -text "%#Quit"]
$box add [gnocl::button -text "%<n_ormal <b>bold</b> <big>big</big>"]
$box add [gnocl::button -icon "%/./three.png" -text "%__Three"]
gnocl::window -title "Percent String Example" -child $box

Markup String

A markup string contains not only the text but also its formatting, which has huge advantages for internationalization of applications.

Copyright notice: the following two tables are copies of the Pango gtk documentation.

The most general markup tag is <span>, then there are some convenience tags. <span> has the following attributes:

<span> attributes

font_desc

A font description string, such as "Sans Italic 12"; note that any other span attributes will override this description. So if you have "Sans Italic" and also a style="normal" attribute, you will get Sans normal, not italic.

font_family

A font family name

face

Synonym for font_family

size

Font size in 1000ths of a point, one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'.

style

One of 'normal', 'oblique', 'italic'

weight

One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight

variant

'normal' or 'smallcaps'

stretch

One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'

foreground

An RGB color specification such as '#00FF00' or a color name such as 'red'

background

An RGB color specification such as '#00FF00' or a color name such as 'red'

underline

One of 'single', 'double', 'low', 'none'

rise

Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.

strikethrough

'true' or 'false' whether to strike through the text

lang

A language code, indicating the text language

The following convenience tags are provided:

Convenience tags

b

Bold

big

Makes font relatively larger, equivalent to <span size="larger">

i

Italic

s

Strikethrough

sub

Subscript

sup

Superscript

small

Makes font relatively smaller, equivalent to <span size="smaller">

tt

Monospace font

u

Underline