[erlang-questions] wxErlang question 4

Joe Armstrong erlang@REDACTED
Sat Jul 8 16:07:18 CEST 2017


There will be - right now my thoughts are not well enough organised to
create a set of
meaningful examples - what I want to do (and am doing) is making a set
of micro-examples
each of which illustrates exactly one point.  So far I have had some
success with:

    buttons
    text editor areas
    vboxes and hboxes
    button click events
    graphics drawing
    menus
    comboboxes
    listboxes

Images are not playing ball yet :-)

I also want to add the built-in things like file selectors, color
selectors, and make some things
like tabbed dialogues.

I also have problems with the fact that many of my programs appear to
work but I do not
understand why they work - and conversely many program that I think should work
do not work.

My problems with non-working programs is that I don't yet know enough
to know]if a) the program
is incorrect and should not work or b) the system is incorrect.

At this stage I'm sending mails to the list asking specific questions -

Anybody reading this thread should feel free to post questions and
example programs.

In particular very short programs that do very simple things, not
complex programs that do many things.

Cheers

/Joe




On Sat, Jul 8, 2017 at 3:46 PM, Simon St.Laurent <simonstl@REDACTED> wrote:
> Is there a repo with these micro-demos in progress?  I'd like to play along.
>
> Thanks,
> Simon
>
>
>
> On 7/8/2017 6:00 AM, Joe Armstrong wrote:
>>
>> On Sat, Jul 8, 2017 at 11:44 AM, Frank Muller
>> <frank.muller.erl@REDACTED> wrote:
>>>
>>> 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!!!
>>
>> Yes - bit I I want a minimal *extensible* solution - wx:new has (as I
>> understand it) - a
>> lot of side-effects and returns a reference that i can use to make other
>> things.
>>
>> I could not (I guess) create two windows with the above.
>>
>> In my version you can say
>>
>>      test() ->
>>            W = wx:new(),
>>            Frame1 = wxFrame:new(W,-1,"window1"),
>>            Frame2 = wxFrame:new(W,-1,"window2"),
>>            ...
>>
>> and get two windows
>>
>> Really I'd better naming so I'd say
>>
>> Frame = lib:make_frame(WinRef),
>> Panel = lib:make_panel(Frame),
>> Vbox = lib:make_vbox(Panel, ...)
>>
>> and strict rules about the order of adding things - I find the heavy
>> overloading and inheritance
>> rules terrible to understand
>>
>> /Joe
>>
>>> /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
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list