added eugtk examples
This commit is contained in:
67
eugtk/examples/test7.ex
Normal file
67
eugtk/examples/test7.ex
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
--# GTK Entry for getting small amounts of text
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
include GtkEngine.e
|
||||
|
||||
constant docs = `Type the name of the animal
|
||||
in the entry box below,
|
||||
then click OK
|
||||
`
|
||||
constant win = create(GtkWindow,"border=10,position=1,$destroy=Quit")
|
||||
|
||||
constant panel = add(win,create(GtkBox,"orientation=VERTICAL"))
|
||||
|
||||
constant lbl = add(panel,create(GtkLabel,{{"markup",docs}}))
|
||||
|
||||
constant fox = create(GdkPixbuf,"thumbnails/fox.png",20,20)
|
||||
|
||||
constant edt = create(GtkEntry,{
|
||||
{"margin top",10},
|
||||
{"margin_bottom",10},
|
||||
{"icon from pixbuf",1,fox},
|
||||
{"icon activatable",1,TRUE},
|
||||
{"icon tooltip markup",1,"Click <i>me</i> to show the entered text"},
|
||||
{"placeholder text","Name this animal"}})
|
||||
connect(edt,"activate",_("ShowEntry")) -- on <enter>
|
||||
connect(edt,"icon-press",_("ShowEntry")) -- on icon clicked
|
||||
add(panel,edt)
|
||||
|
||||
constant btn1 = create(GtkButton,"gtk-quit","Quit")
|
||||
set(btn1,"tooltip markup","Press to <b>quit</b>")
|
||||
|
||||
constant btn2 = create(GtkButton,"gtk-ok",_("ShowEntry"))
|
||||
set(btn2,"tooltip markup","Press to display the entered text")
|
||||
|
||||
constant btnbox = create(GtkButtonBox,"spacing=5")
|
||||
add(btnbox,{btn1,btn2})
|
||||
pack(panel,-btnbox)
|
||||
set(btn2,"grab focus") -- workaround for a bug in 'placeholder text' - see GtnEntry GTK docs
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
|
||||
-----------------------------------------------------------
|
||||
function ShowEntry()
|
||||
-----------------------------------------------------------
|
||||
object guess = get(edt,"text")
|
||||
|
||||
if length(guess) = 0 then guess = "nothing" end if
|
||||
|
||||
if equal(lower(guess),"fox") then
|
||||
Info(win,"Answer","<u>Correct!</u>",
|
||||
sprintf("It <i>is</i> a <b>%s</b>",{guess}))
|
||||
else
|
||||
if Question(win,"Sorry!",
|
||||
sprintf("<span underline='error' color='red'>%s</span> is not correct",{guess}),
|
||||
"Want to try again?") = MB_NO then Quit()
|
||||
end if
|
||||
set(edt,"text","")
|
||||
end if
|
||||
|
||||
return 1
|
||||
end function
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user