WxHolaMundo
De ErlangAr
Ejemplo de como mostrar un hola mundo usando WxErlang
creado por AlejandroPeralta
al programita lo pueden correr con escript helloworld.erl.
-module(helloworld).
-compile(export_all).
-export([main/1]).
-include_lib("wx/include/wx.hrl").
-define(ABOUT, ?wxID_ABOUT).
-define(EXIT, ?wxID_EXIT).
-define(OK, 131).
-define(QUIT, 132).
%% Top-level function: create the wx-server, the graphical objects,
%% show the application, process and clena up on termination.
main(_Args) ->
wx:new(),
Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Hello, World!"),
setup(Frame),
wxFrame:show(Frame),
loop(Frame),
wx:destroy().
%% Top-level frame: create a menu bar, two menus, two menu items
%% and a status bar. Connect the frame to handle events.
setup(Frame) ->
MenuBar = wxMenuBar:new(),
File = wxMenu:new(),
wxMenu:append(File, ?ABOUT, "Hello, World!"),
wxMenu:appendSeparator(File),
wxMenu:append(File, ?EXIT, "Quit"),
wxMenuBar:append(MenuBar, File, "&File"),
wxFrame:setMenuBar(Frame, MenuBar),
wxFrame:createStatusBar(Frame),
wxFrame:setStatusText(Frame, "Welcome To wxErlang"),
wxFrame:connect(Frame, command_menu_selected),
wxFrame:connect(Frame, close_window).
loop(Frame) ->
receive
#wx{id=?ABOUT, event=#wxCommand{}} ->
Str = "Hello, world! From and wxErlang App!",
MD = wxMessageDialog:new(Frame, Str,
[{style, ?wxOK bor ?wxICON_INFORMATION},
{caption, "Hello, World!"}]),
wxDialog:showModal(MD),
wxDialog:destroy(MD),
loop(Frame);
#wx{id=?EXIT, event=#wxCommand{type=command_menu_selected}} ->
wxWindow:close(Frame, [])
end.