<div dir="auto"><span style="font-family:sans-serif">The <a href="http://prog21.dadgum.com">prog21.dadgum.com</a> guy, James Hague, puts forth that he writes a GUI controller in another language and uses that as a port to communicate with. May that be a fruitful approach?</span></div><div class="gmail_extra"><br><div class="gmail_quote">6 июля 2017 г. 10:56 AM пользователь "Frank Muller" <<a href="mailto:frank.muller.erl@gmail.com">frank.muller.erl@gmail.com</a>> написал:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="auto">Joe,</div><div dir="auto"><br></div><div dir="auto">What about the idea behind "GTK server":</div><div dir="auto"><a href="http://www.gtk-server.org/" target="_blank">http://www.gtk-server.org/</a></div><div dir="auto"><br></div><div dir="auto">Best</div><div dir="auto">/Frank</div><div dir="auto"><br></div><div class="gmail_quote"><div>Le mar. 4 juil. 2017 à 18:18, Joe Armstrong <<a href="mailto:erlang@gmail.com" target="_blank">erlang@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm trying to get to grips with wxErlang so I toddled over to Ericsson<br>
and sat down for a few hours with Dan Gudmundsson and asked him a boat<br>
load of stupid questions.<br>
<br>
I'll be writing a lot more about this and setting up a github project<br>
to document how to get tame wxErlang ...<br>
<br>
Here's a first attempt at figuring out how things work.<br>
<br>
My usual approach to understanding things is always the same.<br>
<br>
"Take a program that works. Then remove non-essential bits until<br>
all that is left is so simple that you can understand it."<br>
<br>
How about making some buttons - this should be easy<br>
<br>
I started with demo.erl in ${ERL_TOP}/lib/wx/examples/<wbr>demo/demo.erl<br>
<br>
This has some code for making buttons - but it also does *a lot more*<br>
and *it is highly redundant* -- from the point of view of learning the<br>
code volume does not assist comprehension, nor does using a generic behavior.<br>
<br>
What do I mean by this?<br>
<br>
   - ex_button.erl is written using wx_object.erl<br>
     so to understand ex_button.erl I have to also understand wx_object.erl<br>
   - ex_button.erl has repeated code. For example<br>
     several buttons have tooltips, but I only need to be shown how to do this<br>
     *once* not several times<br>
   - ex_button.erl introduces several new concepts - in particular spacers<br>
     and sizers - and I haven't a clue what they do.<br>
<br>
Now I'm going to refactor ex_button.erl so take a deep breath ...<br>
<br>
First refactoring: remove the dependency on wx_object<br>
<br>
I'd already figured out that a *minimal* wx windows program is:<br>
<br>
    start() -><br>
        Wx = wx_win:new(),<br>
        Frame = wxFrame:new(Wx, -1, "Window Title"),<br>
        wxFrame:show(Frame).<br>
<br>
To make the window do something I'd want to write:<br>
<br>
    start() -><br>
        Wx = wx_win:new(),<br>
        Frame = wxFrame:new(Wx, -1, "Window Title"),<br>
        setup_window(Frame),<br>
        wxFrame:show(Frame),<br>
        loop().<br>
<br>
    loop() -><br>
        receive<br>
            Any -><br>
                io:format("Any=~p~n",[Any])<br>
        end,<br>
        loop().<br>
<br>
Given this structure I refactored ex_button.erl into buttons_demo.erl<br>
which removes all the wx_object code. So now I can stare are the code<br>
in buttons_demo.erl and see if I can understand it, for my point of<br>
view it's far easier to understand than ex_buttons.erl since there is<br>
no dependency on wx_object.erl<br>
<br>
Second refactoring: Simplify buttons_demo.erl<br>
<br>
The original program has four rows of buttons - but one will<br>
be sufficient for me.<br>
<br>
I now removed many lines of code, until only one line of buttons<br>
remained.<br>
<br>
The resulting code buttons_demo1.erl now only creates one line of buttons<br>
and has a couple of sizers.<br>
<br>
Dan told me that the line of code:<br>
<br>
   wxStaticBoxSizer:new(?<wbr>wxHORIZONTAL, Panel,[{label, "wxButton"}]),<br>
<br>
Is wxWidgets way of making an hbox - Goodness wxWidgets can be build<br>
using Knuthian hboxes and vboxes (horray).<br>
<br>
I'm still not happy with buttons_demo1.erl since it mixes two ideas:<br>
<br>
   - making buttons<br>
   - putting buttons in a container and laying out the containers<br>
<br>
This needs to be refactored into:<br>
<br>
   - a pure button examples<br>
   - a pure layout example<br>
<br>
My intention is to try and decompose wxErlang into a large number of<br>
small examples, where each example illustrates one feature of the<br>
system. Also so show how to build complex examples from the small<br>
parts.<br>
<br>
I'll make all the code available on github so you can join in the fun<br>
(is this fun?).<br>
<br>
Notes:<br>
<br>
[1] Feel free to send me examples of wxErlang code - preferably<br>
one example per module that illustrates one feature.<br>
<br>
[2] Anybody want to do this for elixir?<br>
<br>
[3] The WxWidgets documentation is a terminological mess - they call<br>
*everything* (including a button) a window.<br>
<br>
[4] The WxWidget examples (in C++) require subclassing several objects<br>
resulting in multiple files per example - the Erlang equivalent is<br>
nicely contained within a single module (which is far nicer)<br>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
</blockquote></div></div>
<br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div></div>