51 lines
1.4 KiB
Elixir
Raw Permalink Normal View History

2016-11-25 00:33:18 -07:00
------------------------------------------------------------------------
--# 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