Arrow buttons

Keith Vetter 2003-03-12 : after seeing some tcl code on wiki pages that tried to use the "^" and "V" as arrow symbols on buttons[1 ] , I thought I'd make available simple bitmap images of the four arrows that can be used instead. Remember, you can use Bitmap Editor to tailor the images to exactly how you'd like them.

KPV 2010-07-02 : added diagonal arrows


RS wonders if such arrows should not be added to Tk's built-in bitmaps...

RLH I tried it. Nice little arrows, it would be nice if they could be added.

peterc 2010-07-09: Another avenue worth looking at is trawling through UTF tables like this [3 ] and [2 ] for a text code (eg: \u25BC). Most platforms have good support for extended UTF characters now.

WJG 13/07/10 Gnocl has gnocl::arrowButton


KPV 2010-07-13 : These have been added to ActiveState's distribution:


package require Tk
package require widget::arrowbutton
set row -1
set col 9999
foreach orient {upleft up upright left star right downleft down downright} {
    if {[incr col] > 2} {
        incr row
        set col 0
    }
    grid [widget::arrowbutton .$orient -orientation $orient -command [list puts $orient]] -row $row -column $col
}
return

AK: To be precise, these were packaged up as the widget::arrowbutton package and put into Tklib, and through that are now in ActiveState's teapot as well.


uniquename 2013aug17

Here is an image of the little window of arrows (and 'star') that are created by the code below --- so that those readers, who never have the time/opportunity/facitlities/whatever to setup and run the code below, can see what the discussion above is about.

vetter_ArrowButtons_wiki8554_screenshot_110x106.jpg


##+##########################################################################
#
# arrows.tcl -- bitmaps for eight directional arrows
# by Keith Vetter, Mar 12, 2003
# by Keith Vetter, July 2, 2010  added diagonal arrows
#

image create bitmap ::bit::up -data {
    #define up_width 11
    #define up_height 11
    static char up_bits = {
        0x00, 0x00, 0x20, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xfe,
        0x03, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00
    }
}
image create bitmap ::bit::down -data {
    #define down_width 11
    #define down_height 11
    static char down_bits = {
        0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0xfe,
        0x03, 0xfc, 0x01, 0xf8, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00
    }
}
image create bitmap ::bit::left -data {
    #define left_width 11
    #define left_height 11
    static char left_bits = {
        0x00, 0x00, 0x20, 0x00, 0x30, 0x00, 0x38, 0x00, 0xfc, 0x01, 0xfe,
        0x01, 0xfc, 0x01, 0x38, 0x00, 0x30, 0x00, 0x20, 0x00, 0x00, 0x00
    }
}
image create bitmap ::bit::right -data {
    #define right_width 11
    #define right_height 11
    static char right_bits = {
        0x00, 0x00, 0x20, 0x00, 0x60, 0x00, 0xe0, 0x00, 0xfc, 0x01, 0xfc,
        0x03, 0xfc, 0x01, 0xe0, 0x00, 0x60, 0x00, 0x20, 0x00, 0x00, 0x00
    }
}
image create bitmap ::bit::upleft -data {
    #define upleft_width 11
    #define upleft_height 11
    static char upleft_bits = {
        0x00, 0x00, 0x7e, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x7e, 0x00, 0xfe,
        0x00, 0xf2, 0x01, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
    }    
}
image create bitmap ::bit::upright -data {
    #define upright_width 11
    #define upright_height 11
    static char upright_bits = {
        0x00, 0x00, 0xf0, 0x03, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x03, 0xf8,
        0x03, 0x7c, 0x02, 0x38, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00
    }
}
image create bitmap ::bit::downleft -data {
    #define downleft_width 11
    #define downleft_height 11
    static char downleft_bits = {
        0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xe0, 0x00, 0xf2, 0x01, 0xfe,
        0x00, 0x7e, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00
    }
}
image create bitmap ::bit::downright -data {
    #define downright_width 11
    #define downright_height 11
    static char downright_bits = {
        0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x38, 0x00, 0x7c, 0x02, 0xf8,
        0x03, 0xf0, 0x03, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x03, 0x00, 0x00
    }
}
image create bitmap ::bit::star -data {
    #define plus_width 11
    #define plus_height 11
    static char plus_bits = {
        0x00, 0x00, 0x22, 0x02, 0x24, 0x01, 0xa8, 0x00, 0x70, 0x00, 0xfe,
        0x03, 0x70, 0x00, 0xa8, 0x00, 0x24, 0x01, 0x22, 0x02, 0x00, 0x00
    }
}

# Now for a simple demo
package require Tk

frame .buttons
foreach dir {up upright right downright down downleft left upleft} {
    button .$dir -image ::bit::$dir -command [list set S(msg) "$dir arrow"]
}
button .star -image ::bit::star -command [list set S(msg) star]
label .lbl -textvariable S(msg) -bd 2 -relief sunken
set S(msg) "press a button"

grid .buttons -row 0 -pady .05i
grid .lbl -sticky ew
grid columnconfigure . 0 -weight 1
grid .upleft .up .upright  -in .buttons -row 0
grid .left .star .right -in .buttons
grid .downleft .down .downright  -in .buttons

return

See also: create triangle image