Documentation‎ > ‎Toolbars‎ > ‎

    gnocl::toolBar

    A toolbar container widget.

    Synopsis

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

    Screenshot

    Options

    -borderWidth integer (default: )
    Space in pixel between the children and the border of the widget. Select either small, normal, big or specify in pixels.
    -data string (default: "")
    User defined data which can be retrieved via the cget subcommand.
    -iconSize int (default: 3)
    The size of the icons in a toolbar is normally determined by the toolbar -iconSizeSet option. When this option is set, it overrides the setting. This should only be used for special-purpose toolbars, normal application toolbars should respect the user preferences for the size of icons.
    -iconSizeSet boolean (default: 0)
    Specify whether an icon size has been defined.
    -name  string (default: "")
    Name of the widget, can be used to set options in an rc file.
    -orientation string  (default: horizontal)
    Orientation of the toolbar.Select either vertical or horizontal
    -sensitive boolean (default: 1)
    Whether or not the item is sensitive to user input.
    -showArrow boolean (default: 0)
    If an arrow should be shown if the toolbar doesn't fit.
    -style string (default: both)
    Whether to show the icons of the items, their text or both. Select either icons, text or both.
    -tooltips boolean (default: 1)
    If the tooltips of the toolbar should be active or not
    -visible boolean (default: 1)
    Whether or not the item is visible.

    Description

    A toolbar is a container widget normally placed at the top of the main window, directly below the menubar. It can contain special toolbar items or even normal widgets.

    Commands


    id add type [-option value...]
    Add an item to the toolbar. Select from button (item), toggleButton (checkItem), radioButton (radioItem), space (separator) or widget.
    id addBegin type [-option value...]
    Synonym for add.
    id addEnd type [-option value...]
    Add widgets at the end of the toolbar.
    id configure [-option value...]
    Configures the widget. Option may have any of the values accepted on creation of the widget.
    id delete
    Deletes the widget and the associated tcl command.
    id insert type pos [-option value...]
    Add item at specified position. If pos = 0, then the item will be added at the beginning of the bar, if -1 then at the end

    NOTE: This feature is still under-development.
    id nItems
    Returns the number of items contained within the toolbar

    Example

    #---------------
    # test-toolbar.tcl
    #---------------
    # Author: William J Giddings
    # Date: 15/04/11
    #---------------
    #!/bin/sh
    # the next line restarts using tclsh \
    exec tclsh "$0" "$@"
    #---------------

    package require Gnocl

    set toolBar [gnocl::toolBar]

    $toolBar add button \
    -icon "%#New" \
    -text "New" \
    -tooltip "New File"

    set menu [gnocl::menu \
    -title "menu" \
    -tearoff 0]

    $menu add [gnocl::menuItem \
    -text "1) item3" \
    -onClicked {puts "load item 1"}]

    $menu add [gnocl::menuItem \
    -text "2) item3" \
    -onClicked {puts "load item 2"}]

    $menu add [gnocl::menuItem \
    -text "3) item3" \
    -onClicked {puts "load item 3"}]

    $toolBar add menuButton \
    -icon %#Open \
    -text Open \
    -menu $menu \
    -tooltip "Open File" \
    -arrowTooltip "Open Recent" \
    -onClicked {gnocl::fileChooserDialog}

    $toolBar add separator

    foreach item {Bold Italic Underline} {
    $toolBar add toggleButton \
    -icon "%#$item" \
    -text $item \
    -variable $item \
    -onToggled "showVal $item" \
    -tooltip "$item text"
    }

    $toolBar add separator

    foreach {item val} {JustifyLeft left JustifyCenter center JustifyRight right} {

    # variable provdies the group name
    $toolBar add radioButton \
    -icon %#$item \
    -text $item \
    -variable justify \
    -onToggled "showVal $item" \
    -onValue $val \
    -tooltip "$item text"
    }

    set ent [gnocl::entry -secondaryIcon %#Find ]

    $toolBar add widget $ent

    gnocl::window \
    -title "ToolBar" \
    -child $toolBar \
    -width 550

    gnocl::mainLoop

    Comments

    Sections