added eugtk examples
This commit is contained in:
53
eugtk/examples/test41.ex
Normal file
53
eugtk/examples/test41.ex
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
--# Attaching data to GtkButtons
|
||||
-- Can pass integers or atoms which can be used directly.
|
||||
-- Strings and more complex Euphoria objects are passed via pointer,
|
||||
-- which is created automatically, but must be 'unpacked' before use.
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
include GtkEngine.e
|
||||
|
||||
sequence items = {
|
||||
{"Excesso Gasoline","gallon",3.599}, -- item #1
|
||||
{"Slippery Oil", "quart", 2.49} -- item #2
|
||||
}
|
||||
enum NAME, UNIT, PRICE
|
||||
|
||||
constant pix = create(GdkPixbuf,"thumbnails/gconf-editor.png")
|
||||
|
||||
constant win = create(GtkWindow,
|
||||
"size=200x150,border_width=10,position=1,$destroy=Quit")
|
||||
|
||||
constant panel = create(GtkBox,"orientation=VERTICAL")
|
||||
add(win,panel)
|
||||
|
||||
constant img = create(GtkImage,pix)
|
||||
add(panel,img)
|
||||
|
||||
constant lbl1 = create(GtkLabel,"Lou's Service Station")
|
||||
add(panel,lbl1)
|
||||
|
||||
constant lbl2 = create(GtkLabel,"font=8,text='Associating data with buttons")
|
||||
add(panel,lbl2)
|
||||
|
||||
constant btnbox = create(GtkButtonBox)
|
||||
pack(panel,-btnbox)
|
||||
add(btnbox,{
|
||||
create(GtkButton,"Gas",_("Foo"),1),
|
||||
create(GtkButton,"Oil",_("Foo"),2)})
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
|
||||
------------------------------------------------
|
||||
function Foo(atom ctl, integer n) -- n is item #
|
||||
------------------------------------------------
|
||||
Info(win,"Lou's Gas & Oil",
|
||||
items[n][NAME],
|
||||
sprintf("$%2.2f per %s",{items[n][PRICE],items[n][UNIT]}))
|
||||
return 1
|
||||
end function
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user