[erlang-questions] wxErlang question 1

Joe Armstrong erlang@REDACTED
Sun Jul 2 11:30:29 CEST 2017


On Sun, Jul 2, 2017 at 10:41 AM, PAILLEAU Eric <eric.pailleau@REDACTED> wrote:
> Le 01/07/2017 à 16:37, Joe Armstrong a écrit :
>>
>> Do I have to swallow a book on wxWidgets to learn how to program
>> wxErlang? - programming by reading the source and guessing what it
>> means is not my favorite occupation.
>
>
> Hi Joe,
>
> did you tried wx:demo() ?

Yes - but it's not much help. Let me explain why...

If I start reading the code the first line in the first example that
seems to do anything is:

     Panel = wxPanel:new(Parent, [])

The documentation in wx.pdf says (at the top) says "See external
documentation: wxPanel"

So Panel = wxPanel:new creates a new Panel (I could have guessed that)
indeed I did *guess* that - but what the heck is a Panel?

Google google google ... in http://docs.wxwidgets.org/trunk/classwx_panel.html

I found this text:

<quote>
A panel is a window on which controls are placed.

It is usually placed within a frame. Its main feature over its parent
class wxWindow is code for handling child windows and TAB traversal,
which is implemented natively if possible (e.g. in wxGTK) or by
wxWidgets itself otherwise.
</quote>

I'm not slightly wiser - you stick things in it - my coal is to create a
"canvas" (A thing I can draw on) - now is what I call a canvas what
wxWidgets calls a canvas or is it a GraphicsContext ??

And what is a Frame - and has the wxErlang Panel been placed in a frame
it's been placed in "Parent" but what the heck is Parent.

So here is my problem. The wxErlang documentation says "read the
external documentation" and the external documentation and the
external documentation is written in terms of Panels, Frames, Windows,
Spacers, WobbleBongers and DingleSplodgers.

I know diddly squat about Panels and Frames so this is not not much help...

What I want to do is plot a rectangle in window - What I would like
very much is a simple module - let's call this simple_graphics.erl

My code would be like this:

     Win = simple_graphics:make_window(),
     Can = simple_graphics:add_canvas(Win)
     Rect = simple_graphics:add_object(Can, #{type=rect,x=>10,y=>20,
                 ht => 200, width=>30, color=>red})

It should be possible to write simple_graphics.erl *using* wx widgets
and the documentation. So far I've tried in vain for several hours.

Can anybody write simple_graphics.erl????

<aside>
30'odd years ago I could write graphics programs using Borland Turbo
Graphics on an IBM PC running DOS - 30 years ago a kid could write
graphics in BASIC running on a Sinclair spectrum.

My turbo pascal compiled instantly and was only a few lines of code
(more or less like the lines above) - oh and the *entire* OS and all
the tools fitted into a few tens of MBytes of storage and ran in less
than 640K Bytes of memory.
</aside>

The problem with things like wxErlang is that the people who implement
wxErlang (Dan G - all praise be to his name) know what all these
Panels and Frames are - to them it is "obvious" and thus needs no
explanation.

<aside>
This is a common failing. By the time you become an expert in something
certain things will be obvious to you, other things less obvious.

You will see the need to explain to non-experts the non-obvious things
and even the difficult
things - but you omit to explain the obvious things.

When explaining things you have to imagine the mind-set of a non-expert.

A good time to write an explanation of something is just after the instant when
you understand something for the first time. At this point in time you
understand
the new thing AND why you didn't understand it (ie you can remember
how you thought
yesterday when you didn't understand it.)

Two weeks later you will have forgotten why you did not understand it
and thus not
be able to explain it ...
</aside>


Bears of little brain and limited attention span (like me)would be
deliriously happy if they could draw a rectangle in a window - and
they would cry from the mountain top - "Hej, Ma I'm a programmer - I
drew a rectangle in a window"

Right now I'm waiting for enlightenment to strike me. (and reading up
on the C++ xwidgets stuff - which is very definitely in the "you don't
want to know"
category.

Cheers

/Joe




>
> It is a good cheat sheet every time I need to do some wx.
> However I admit it is always a pain when not doing wx regularly.
>
> Regards
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list