added eugtk examples
This commit is contained in:
50
eugtk/examples/test20.ex
Normal file
50
eugtk/examples/test20.ex
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
------------------------------------------------------------------------
|
||||
--# Setting background colors - links don't work on Windows.
|
||||
------------------------------------------------------------------------
|
||||
|
||||
include GtkEngine.e
|
||||
include std/net/url.e
|
||||
|
||||
constant helpfile = canonical_path("~/demos/documentation/HowItWorks.html#colors")
|
||||
|
||||
constant docs = sprintf(`<u><b>Random Colors</b></u>
|
||||
Click the button to choose
|
||||
a new color. See <a href='%s'>%s</a>
|
||||
for more info.`,
|
||||
{helpfile,"Colors"})
|
||||
|
||||
constant win = create(GtkWindow,
|
||||
"title=`Random Colors`,size=200x120,border=10,position=1,$destroy=Quit")
|
||||
|
||||
constant panel = create(GtkBox,VERTICAL)
|
||||
add(win,panel)
|
||||
|
||||
constant lbl = create(GtkLabel)
|
||||
set(lbl,"markup",docs)
|
||||
add(panel,lbl)
|
||||
|
||||
atom img = create(GtkImage,"thumbnails/tiphat1.gif")
|
||||
add(panel,img)
|
||||
|
||||
constant btn = create(GtkButton,"gtk-refresh",_("RandomColor"))
|
||||
set(btn,"tooltip text","Click for random color")
|
||||
pack(panel,-btn)
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
|
||||
------------------------------------------------------------------------
|
||||
function RandomColor()
|
||||
------------------------------------------------------------------------
|
||||
object randy = rand(#ffffff)
|
||||
set(win,"background",randy)
|
||||
set(win,"title",sprintf("#%06x",randy))
|
||||
return 1
|
||||
end function
|
||||
|
||||
-- In this demo, we set the color in numeric (hex) form,
|
||||
-- because rand() can do this for us very easily.
|
||||
-- then we convert it to string form to display on titlebar
|
||||
|
||||
|
||||
Reference in New Issue
Block a user