[erlang-questions] wxErlang question 4

Joe Armstrong erlang@REDACTED
Sat Jul 8 11:01:00 CEST 2017


This is my attempt at a minimal program which creates a button

start() ->
    W = wx:new(),
    Frame = wxFrame:new(W, -1, "Hello"),
    Panel = wxScrolledWindow:new(Frame),
    Vbox = wxBoxSizer:new(?wxVERTICAL),
    wxWindow:setSizer(Panel, Vbox),
    Button = wxButton:new(Panel, 10, [{label,"Click"}]),
    wxSizer:add(Vbox, Button, [{flag, ?wxALL}]),
    wxFrame:show(Frame).

It
   1) gets a reference to the wxWindows Server
   2) creates a Frame (which wxWindows calls a window)
   3) adds a Panel to the frame
       a Panel is a thing you can add controls to
   4) creates a Vbox (a box to whose children are arranged  vertically)
   5) tells the panel to use the Vbox as it's top level sizer
   6) makes a button
   7) adds the button to the Vbox
   8) displays the frame

Questions

1) Is my understanding of the steps you have to do be make a
    minimal window with a button correct?

    Could the code be clearer (how?)

    (actually shorter code might be possible but I want something that is
     extensible - so I've used a vbox to which I assume I can add more later)

 2)  What are the alternatives to wxScrolledWindow and to wxBoxSizer?

Cheers

/Joe



More information about the erlang-questions mailing list