/tutorial/vision/hello_world/hello.e

http://github.com/tybor/Liberty · Specman e · 38 lines · 22 code · 5 blank · 11 comment · 0 complexity · 6e85e7039083f521485ed75f3f0b54a6 MD5 · raw file

  1. class HELLO
  2. -- This example show:
  3. -- how to create a window, chose title and colors,
  4. -- how to add widgets into the window,
  5. -- how to start and stop the event loop.
  6. inherit
  7. GRAPHIC
  8. -- Give access to constants (vision, colors...)
  9. creation {ANY}
  10. make
  11. feature {}
  12. toplevel_window: TOPLEVEL_WINDOW
  13. make is
  14. local
  15. label: LABEL
  16. do
  17. create toplevel_window.default_create
  18. toplevel_window.set_title("Hello World")
  19. toplevel_window.set_background_color(white_color)
  20. toplevel_window.map
  21. -- put the window on the screen; may be done later
  22. create label.make(U"Hello World !")
  23. -- windows are containers, you add widgets into them
  24. toplevel_window.child_attach(label)
  25. -- register procedure to call on user requests on 'quit'
  26. toplevel_window.when_close_requested(agent vision.loop_stack.break)
  27. -- start the event loop. The event loop executes registred
  28. -- behavior for user actions.
  29. -- It will stop when break is called (vision.loop_stack.break).
  30. vision.start
  31. io.put_string("The end%N")
  32. end
  33. end -- class HELLO