added eugtk examples
This commit is contained in:
66
eugtk/examples/test14.ex
Normal file
66
eugtk/examples/test14.ex
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
--# GTK Radio Buttons
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
include GtkEngine.e
|
||||
|
||||
constant
|
||||
docs = `<b><u>RadioButtons</u></b>
|
||||
Choose a beverage
|
||||
(only 1 to a customer)`,
|
||||
fmt = "<span size='x-large' weight='heavy' underline='double' underline_color='red' >%s</span>",
|
||||
bob = create(GdkPixbuf,"thumbnails/user_icon.gif")
|
||||
|
||||
constant win = create(GtkWindow,
|
||||
"title=`Bob's Diner`,size=250x-1,border=10,position=1,icon=face-raspberry,$destroy=Quit")
|
||||
|
||||
constant panel = add(win,create(GtkBox,VERTICAL))
|
||||
|
||||
constant lbl = add(panel,create(GtkLabel,{
|
||||
{"markup",docs},
|
||||
{"margin bottom",5}}))
|
||||
|
||||
sequence rb = repeat(0,4) -- each radio button in a group is parented to the previous button,
|
||||
rb[1] = create(GtkRadioButton,0,"#_Coke") -- except for the first, where parent = null;
|
||||
rb[2] = create(GtkRadioButton,rb[1],"#_Pepsi")
|
||||
rb[3] = create(GtkRadioButton,rb[2],"#_Mountain Dew")
|
||||
rb[4] = create(GtkRadioButton,rb[3],"#Iced _Tea")
|
||||
add(panel,rb)
|
||||
|
||||
constant box = add(panel,create(GtkButtonBox)),
|
||||
btn1 = create(GtkButton,"gtk-quit","Quit"),
|
||||
btn2 = create(GtkButton,"gtk-ok",_("ShowBeverageChoice"))
|
||||
|
||||
set(btn2,"can default",TRUE) -- set up btn2 to be activated on <enter>
|
||||
set(win,"default",btn2)
|
||||
|
||||
add(box,{btn1,btn2})
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
|
||||
--------------------------------------------------------------
|
||||
function ShowBeverageChoice()
|
||||
--------------------------------------------------------------
|
||||
object drink
|
||||
for i = 1 to length(rb) do
|
||||
if get(rb[i],"active") then --(1)
|
||||
drink = remove_all('_',get(rb[i],"label")) --(2)
|
||||
exit --(3)
|
||||
end if
|
||||
end for
|
||||
Info(win,"Bob's Diner","Your Beverage Choice",
|
||||
sprintf(fmt,{drink}),,bob,"face-raspberry")
|
||||
return 1
|
||||
end function
|
||||
|
||||
--[1] check for selected button,
|
||||
--[2] remove leading underscore for neat display,
|
||||
--[3] since there can only be one active, we're done!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user