Skip to content

Instantly share code, notes, and snippets.

@rusted
Created February 19, 2015 12:29
Show Gist options
  • Save rusted/e1b51ec7d4fba431edc0 to your computer and use it in GitHub Desktop.
Save rusted/e1b51ec7d4fba431edc0 to your computer and use it in GitHub Desktop.
eugenkiss/7guis Erlang with wxErlang
-module(counter).
-include_lib("wx/include/wx.hrl").
-export([start/0]).
itl(Int) ->
erlang:integer_to_list(Int).
lti(L) ->
erlang:list_to_integer(L).
increment(Text) ->
wxStaticText:setLabel(Text, itl((lti(wxStaticText:getLabel(Text)) + 1))).
start() ->
Wx = wx:new(),
Frame = wxFrame:new(Wx, 1, "Counter",[{size, {150,50}}]),
Text = wxStaticText:new(Frame, 2, "0", [{pos, {10,5}}]),
Button = wxButton:new(Frame, 3, [{label, "Click"},{pos,{50,0}}]),
CB = [{callback, fun(_,_) -> increment(Text) end}],
wxFrame:connect(Button, command_button_clicked, CB),
wxFrame:show(Frame).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment