wxSizer

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

wxSizer

Peter J Etheridge
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.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: wxSizer

Tobias Schlager-2
Hi Peter,

I don't know much about the Erlang port of wxWidgets. However, I have done some work with native wxWidgets recently. From what I can see, the API seems to be a straight mapping to the C++ code. This would lead to the conclusion that the same rules and documentation can be applied to the Erlang port. To understand layout and spacing I would suggest starting with the 'Sizers Overview' [1]. You could also have a look at the zetcode tutorials [2] which are pretty good and easy to understand.

To address your specific question:
Windows (every UI element is a window in wxWidgets) and sizers appear in the order they are added to their (parent) sizer (not their parent window). The C++ library also has support to insert windows into sizers at a specific index. Usually, you simply add items in the order you want them to appear in the layout. The normal workflow is to create the UI elements, then add them to a sizer in the order you want them. After this you can add this sizer to another sizer or set it as the main sizer of the frame, finally layout the window.

Regards
Tobias

[1] http://docs.wxwidgets.org/stable/overview_sizer.html
[2] http://zetcode.com/gui/wxwidgets/
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: wxSizer

Steve Davis
In reply to this post by Peter J Etheridge
Hi Peter,

I remember struggling with sizers when trying to code up a gs-style interface to wx. This module may contain a few pointers that would be helpful:


/s


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: wxSizer

Dan Gudmundsson-2
And maybe run wx:demo() and look at the sizer examples or the code for wx:demo().
Examples exist but for documentation you will have to look at wxWidgets which docs are not that great either.

On Wed, Dec 7, 2016 at 3:30 PM Steve Davis <[hidden email]> wrote:
Hi Peter,

I remember struggling with sizers when trying to code up a gs-style interface to wx. This module may contain a few pointers that would be helpful:


/s

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: wxSizer

Steve Davis
Also, I remember the wxPy tutorials helping me a lot. https://wiki.wxpython.org/SizerTutorials All examples are in python but easy to read and the concepts are the same.


On Dec 7, 2016, at 8:40 AM, Dan Gudmundsson <[hidden email]> wrote:

And maybe run wx:demo() and look at the sizer examples or the code for wx:demo().
Examples exist but for documentation you will have to look at wxWidgets which docs are not that great either.

On Wed, Dec 7, 2016 at 3:30 PM Steve Davis <[hidden email]> wrote:
Hi Peter,

I remember struggling with sizers when trying to code up a gs-style interface to wx. This module may contain a few pointers that would be helpful:


/s

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions