[erlang-questions] wxSizer

Peter J Etheridge petergi@REDACTED
Wed Dec 7 08:57:13 CET 2016


Dear List,
As mentioned in recent postings, learning wxErlang is challenging.
Any improvement to the documentation will be gratefully received.
In his wxErlang work-up Doug Edmunds states, 'the order of Sizers
determines appearance'.
I have set '9' for W & H, and '5' for spacers as these are not yet
working.
I will appreciate any suggestion for Spacer ordering and any links to
other tutorials or examples.
Thank you in advance.

-module(text_in_box).
-include_lib("wx/include/wx.hrl").
-compile([export_all]).
-export([make_window/0]).

make_window() ->
  S = wx:new(),
  F = wxFrame:new(S, 1, "text_in_box", [{size, {300, 300}}]),
  P = wxPanel:new(F),
  B = wxStaticBox:new(P, 2, "&Static box"),

  wxPanel:setBackgroundColour(P, ?wxLIGHT_GREY),
  wxStaticBox:setBackgroundColour(B, ?wxBLUE),
  wxStaticBox:setLabel(B, "Static box"),

  T = wxStaticText:new(P, 3, "Static text", []),
  wxStaticText:setLabel(T, "Vertical static text"),

  Bs = wxStaticBoxSizer:new(?wxHORIZONTAL, P, [{label, "Horizontal
static box sizer"}]),
  Ts = wxBoxSizer:new(?wxVERTICAL),

  wxSizer:add(Bs, B, []),
  wxSizer:add(Bs, 9, 9, []),
  wxSizer:add(Bs, 9, 9, []),
  wxSizer:add(Ts, T, []),
  wxSizer:add(Ts, 9, 9, []),
  wxSizer:addSpacer(Ts, 5),
  wxSizer:addSpacer(Bs, 5),
  wxSizer:add(Bs, Ts, []),
  wxPanel:setSizer(P, Bs),
  wxFrame:show(F),
  % create two listeners
  wxFrame:connect(F, close_window),
  wxPanel:connect(P, command_button_clicked),
  loop(F),
  {F, Bs, Ts, self()}.

loop(S) ->
  receive
    #wx{event = #wxCommand{type = command_event}} ->
      wxWindow:close(S, []),
      loop(S);
    #wx{event = #wxClose{type = close_window}} ->
      ok
  end.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161207/b4f463bb/attachment.htm>


More information about the erlang-questions mailing list