added eugtk examples
This commit is contained in:
45
eugtk/examples/test107.ex
Normal file
45
eugtk/examples/test107.ex
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
--# Passing formatting data attached to buttons
|
||||
|
||||
include GtkEngine.e
|
||||
|
||||
constant docs = `<b><u>Sending Formatting data</u></b>
|
||||
We can attach formatting data to controls and
|
||||
it will be sent to our user-written routine.`
|
||||
|
||||
constant win = create(GtkWindow,"size=300x100,position=1,border_width=10,$destroy=Quit")
|
||||
|
||||
constant panel = create(GtkBox,"orientation=VERTICAL")
|
||||
add(win,panel)
|
||||
|
||||
constant lbl1 = create(GtkLabel)
|
||||
set(lbl1,"markup",docs)
|
||||
add(panel,lbl1)
|
||||
|
||||
constant sep = add(panel,create(GtkSeparator,"margin_top=5,margin_bottom=5"))
|
||||
|
||||
constant n = 12.345
|
||||
|
||||
constant lbl2 = create(GtkLabel,"12.345")
|
||||
add(panel,lbl2)
|
||||
|
||||
integer x = _("X")
|
||||
|
||||
constant box = create(GtkButtonBox)
|
||||
pack(panel,-box)
|
||||
add(box,
|
||||
{create(GtkButton,"Dollar",x,"$%2.2f"),
|
||||
create(GtkButton,"Integer",x,"%d"),
|
||||
create(GtkButton,"Hex",x,"#%06x"),
|
||||
create(GtkButton,"gtk-revert-to-saved",x,"%g")})
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
|
||||
------------------------------------------------------------------------
|
||||
function X(atom ctl, object fmt)
|
||||
------------------------------------------------------------------------
|
||||
fmt = unpack(fmt)
|
||||
set(lbl2,"markup",sprintf(fmt,{n}))
|
||||
return 1
|
||||
end function
|
||||
Reference in New Issue
Block a user