Documentation‎ > ‎Containers‎ > ‎

gnocl::iconView

A widget that allow a collection of graphics items to be displayed as a grid of icons within a scrollable container.

Synopsis

gnocl::iconView [-option value...]

Screenshot 

Options

-baseFont string  (type: FONT)

Set default font for the text widget.The value passed to the option is a list of attributes in the following format:

typeface  size attributes: either bold | italic

-baseColor string

type: color

Set default colour for the text widget.
-columnSpacing integer  (default: 1)

Specifies the space which is inserted between the columns of the icon view.

-columns integer  (default: 1)

The number of the columns in which the items should be displayed. If it is -1, the number of columns will be chosen automatically to fill the available area.

-iconSize  integer  (default: 1)

Description to be added.

-itemPadding integer  (default: 1)

The padding around each of the icon view's item.

-itemWidth integer  (default: 1)

The width to use for each item. If it is set to -1, the icon view will automatically determine a suitable item size.

-margin integer  (default: 1)

The space which is inserted at the edges of the icon view.

-orientation string  (default: vertical)

Options: horizontal or vertical. Specifies how the cells (i.e. the icon and the text) of the item are positioned relative to each other.

-reorderable integer  (default: 1)

Specifies if the items can be reordered by DND.

-rowSpacing integer  (default: 1)

Specifies the space which is inserted between the rows of the icon view.

-selectionMode string  (default: single)

Specifies the selection mode of icon view. If the mode is multiple then rubberband selection is enabled, for the other modes, only keyboard selection is possible.

-spacing integer  (default: 1)

Specifies the space which is inserted between the icon and the text of an item.


Signals

-onActivated string  (default: "")
Tcl script which is executed if the button is clicked. Before evaluation the following percent strings are substituted:

%w    widget name
%d widget data
%P path of activated item
-onSelectionChanged string  (default: "")
Tcl script which is executed if the button is clicked. Before evaluation the following percent strings are substituted:

%w  widget id
%d  widget data
%s  selection. A list of selected icon paths.
-onSetScrollAdjustments string  (default: "")
Tcl script which is executed if the button is clicked. Before evaluation the following percent strings are substituted:

%w    widget name

Description

This widget provides an alternative view on a list model. It displays the model as a grid of icons with labels. An iconview widget allows the selection of one or multiple items. In addition to selection with the arrow keys, this widget supports rubberband selection, which is controlled by dragging the pointer.

Commands

id delete
Deletes the widget and the associated Tcl command.
id add string  [-option value...]
Adds the graphics named by string to the display.

Options

    -label string  (default: "")

Text to be displayed alongside the item added.

id class

Returns the class of this object, i.e. "iconview".

id cget option

Returns the value for one option. The option may have any of the values accepted by configure.

id configure [-option value...]
Configures the widget. Option may have any of the values accepted on creation of the widget.

Example

#---------------
# Author: William J Giddings
# Date: 30/01/11
#---------------
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
#---------------

package require Gnocl

set iv [gnocl::iconView \
-columnSpacing 0 \
-margin 1 \
-spacing 0 \
-columns 4 \
-rowSpacing 1 \
-textColumn 1 \
-onActivated {puts WHEEE} \
-itemPadding 0 \
-itemWidth 50 \
-iconWidth 75 ]


set pb1 [gnocl::pixBuf load -file ./georgie.png"]

puts $pb1

for {set i 0 } {$i < 4} {incr i} {
$iv add "%/./georgie.png" -label "GiGi $i"
$iv add "%/./wjg.png" -label "WiGi $i"
$iv add "%/./gnocl.png" -label "NEW $i"
}

gnocl::window \
-child $iv \
-title gnocl::iconView \
-widthRequest 200 \
-heightRequest 200


gnocl::mainLoop


Comments