GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 11:27 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Tcl bindings to the Gtk+ Abiwidget
PostPosted: Sat Sep 18, 2010 10:56 pm 
Offline
GTK+ Guru

Joined: Sun Jan 17, 2010 6:48 pm
Posts: 102
After spending a rather productive afternoon and evening hammering a Tcl package together I now have a workable binding to the rather nice Gtk+ Abiwidget. Here's snapshot just to show it working. The development code can be downloaded from the Gnocl nightly builds at sourceforge.

Image


[code=]
#---------------
# AbiWidget.tcl
#---------------
# Created by William J Giddings
# 18-Sep-2010
#---------------
# Description:
#
#---------------

#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl
package require GnoclAbiWidget

set aw1 [gnocl::abiwidget]

set toolBar1 [gnocl::toolBar]

$toolBar1 add item \
-text "%#New" \
-onClicked exit

$toolBar1 add item \
-text "%#Open" \
-onClicked {
$aw1 load [pwd]/test.abw
}

$toolBar1 add item \
-text "Save As" \
-onClicked {
$aw1 save
}

$toolBar1 add item \
-text "%#Save" \
-onClicked {
$aw1 save [pwd]/test.abw
}

$toolBar1 add space

$toolBar1 add item \
-text "%#Undo" \
-onClicked {$aw1 undo}

$toolBar1 add item \
-text "%#Redo" \
-onClicked {$aw1 redo}

$toolBar1 add space

$toolBar1 add item \
-text "%#Cut" \
-onClicked {$aw1 cut}

$toolBar1 add item \
-text "%#Copy" \
-onClicked {$aw1 copy}

$toolBar1 add item \
-text "%#Paste" \
-onClicked {$aw1 paste}

# toolbar 2

set toolBar2 [gnocl::toolBar]

$toolBar2 add item \
-text "%#JustifyLeft" \
-onClicked {$aw1 align left 1}

$toolBar2 add item \
-text "%#JustifyRight" \
-onClicked {$aw1 align right 1}

$toolBar2 add item \
-text "%#JustifyCenter" \
-onClicked {$aw1 align center 1}

$toolBar2 add item \
-text "%#JustifyFill" \
-onClicked {$aw1 align justify 1}

$toolBar2 add space

$toolBar2 add item \
-text "Select All" \
-onClicked {$aw1 select all }

$toolBar2 add space

$toolBar2 add item \
-text "Erase EOL" \
-onClicked {$aw1 erase eol }

$toolBar2 add item \
-text "Ins Data" \
-onClicked {$aw1 insert data "OM GATE GATE PARAGATE PARASAMGATE BODHI SVAHA" }

$toolBar2 add item \
-text "Ins SPACE" \
-onClicked {$aw1 insert space }


# toolbar 3

set toolBar3 [gnocl::toolBar]

$toolBar3 add item \
-text "Header" \
-onClicked {$aw1 edit header}

$toolBar3 add item \
-text "Footer" \
-onClicked {$aw1 edit footer}

$toolBar2 add space

$toolBar3 add item \
-text "Open" \
-onClicked {$aw1 file open}

$toolBar3 add item \
-text "Save" \
-onClicked {$aw1 file save}


# assemble all the elements of the user interface
set container [gnocl::box -orientation vertical]
$container add $toolBar1
$container add $toolBar2
$container add $toolBar3
$container add $aw1 -fill {1 1} -expand 1

# pack int a toplevel window
gnocl::window \
-child $container \
-defaultWidth 480 -defaultHeight 320 \
-onDelete { exit }

gnocl::mainLoop
[/code]


WJG

_________________
"If you don't stand for something, then you'll fall for anything."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group