Created
April 15, 2015 16:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module('helloworld'). | |
-export([start/0]). | |
-include_lib("wx/include/wx.hrl"). | |
start() -> | |
_WX = wx:new(), | |
Frame = makeFrame("Hello World", [{pos, {50,60}}, {size, {450, 340}}]), | |
wxFrame:connect(Frame, close_window), | |
wxFrame:show(Frame), | |
loop(Frame), | |
wx:destroy(). | |
makeFrame(Title, Options) -> | |
Frame = wxFrame:new(wx:null(), ?wxID_ANY, Title, Options), | |
MenuFile = wxMenu:new(), | |
wxMenu:append(MenuFile, 1, "&About..."), | |
wxMenu:appendSeparator(MenuFile), | |
wxMenu:append(MenuFile, 2,"E&xit"), | |
MenuBar = wxMenuBar:new(), | |
wxMenuBar:append(MenuBar,MenuFile,"&File"), | |
wxFrame:setMenuBar(Frame,MenuBar), | |
wxFrame:createStatusBar(Frame), | |
wxFrame:setStatusText(Frame,"Welcome to wxErlang"), | |
wxFrame:connect(Frame, command_menu_selected), | |
Frame. | |
loop(Frame) -> | |
receive | |
#wx{id=1, event=#wxCommand{}} -> | |
MD = wxMessageDialog:new(Frame, "This is a wxErlang Hello world sample.", | |
[{style, ?wxOK bor ?wxICON_INFORMATION}, | |
{caption, "About Hello World"}]), | |
wxDialog:showModal(MD), | |
wxDialog:destroy(MD), | |
loop(Frame); | |
#wx{id=2, event=#wxCommand{type=command_menu_selected}} -> | |
wxWindow:close(Frame,[]), | |
loop(Frame); % Fix -- drain Close event. | |
#wx{event=#wxClose{type=close_window}} -> | |
ok % NOT wxWindow:close(Frame,[]) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment