eumandy/eugtk/examples/test29.ex
2016-11-25 00:33:18 -07:00

40 lines
1.2 KiB
Elixir

-------------------------------------------------------------------------------
--# GtkCalendar
-- Calendar automatically loads to current date unless told otherwise.
-- Calendar date i/o formats are same as std/datetime.e formats
-------------------------------------------------------------------------------
include GtkEngine.e
include std/datetime.e -- requires use of gtk: namespace
constant win = gtk:create(GtkWindow,
"size=300x300,border_width=10,position=1,$destroy=Quit")
constant pan = gtk:add(win,create(GtkBox,"orientation=VERTICAL"))
constant cal = gtk:add(pan,create(GtkCalendar,"$day selected double click=ShowDate"))
constant lbl = gtk:add(pan,create(GtkLabel,"margin_top=10"))
constant box = gtk:create(GtkButtonBox)
gtk:pack(pan,-box)
gtk:add(box,
{gtk:create(GtkButton,"gtk-quit","Quit"),
gtk:create(GtkButton,"gtk-ok","ShowDate")})
gtk:show_all(win)
gtk:main()
--------------------------
global function ShowDate()
--------------------------
object clicktime = get(cal,"datetime")
gtk:set(cal,"mark day",get(cal,"day"))
gtk:set(lbl,"markup",
datetime:format(clicktime,`
____________<b>Date selected:</b> %A, %b %d
<b>Time clicked:</b> %l:%M %p`))
return 1
end function