added eugtk examples
This commit is contained in:
51
eugtk/examples/test181.ex
Normal file
51
eugtk/examples/test181.ex
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
--# Passing key/value pairs, accessed by key;
|
||||
|
||||
include GtkEngine.e
|
||||
|
||||
constant docs = `<u><b>Passing Key/Value pairs</b></u>
|
||||
|
||||
Another way to attach data to controls,
|
||||
and retrieve data by<i><b> field name</b></i>,
|
||||
rather than by position.
|
||||
Therefore, field order can be random.
|
||||
|
||||
`
|
||||
constant sam = {"name=Sam Smith","bal=6.45","city=Buffalo","phone=000-555-1212"}
|
||||
constant joe = {"bal=44.22", "name=Joe Jones","phone=123-456-7890","city=Reno"}
|
||||
|
||||
constant win = create(GtkWindow,{
|
||||
{"border width",10},
|
||||
{"default size",300,100},
|
||||
{"position",GTK_WIN_POS_CENTER},
|
||||
{"signal","destroy","Quit"}})
|
||||
|
||||
constant panel = create(GtkBox,VERTICAL)
|
||||
add(win,panel)
|
||||
|
||||
constant lbl = create(GtkLabel)
|
||||
set(lbl,"markup",docs)
|
||||
add(panel,lbl)
|
||||
|
||||
constant
|
||||
btn1 = create(GtkButton,"gtk-quit","Quit"),
|
||||
btn2 = create(GtkButton,"gtk-ok#_Sam","Foo",sam),
|
||||
btn3 = create(GtkButton,"gtk-ok#_Joe","Foo",joe),
|
||||
box = create(GtkButtonBox)
|
||||
add(box,{btn1,btn2,btn3})
|
||||
pack(panel,-box)
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
|
||||
------------------------------------------
|
||||
global function Foo(atom ctl, object data)
|
||||
------------------------------------------
|
||||
data = unpack(data) -- convert back to named k/v sequence
|
||||
Info(win,"Data",
|
||||
format("[{name}]",data),
|
||||
format("[{phone}] <b>$[{bal}]</b>",data))
|
||||
return 1
|
||||
end function
|
||||
|
||||
|
||||
Reference in New Issue
Block a user