[erlang-questions] wxErlang question 4

Frank Muller frank.muller.erl@REDACTED
Sat Jul 8 11:44:07 CEST 2017


Joe, why not:

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


Where you hide the W and Frame inside the Panel.
They're used only once/twice in your code!!!

/Frank


Le sam. 8 juil. 2017 à 11:01, Joe Armstrong <erlang@REDACTED> a écrit :

> 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
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170708/1e82fd3a/attachment.htm>


More information about the erlang-questions mailing list