wxErlang question 1

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

wxErlang question 1

Joe Armstrong-2
I have some wxErlang questions:

I have created a wxFrame and I want to get some messages sent to me
when things happen.

Looking in the examples in the erlang distribution I can find lines of
code like (for example)

    wxFrame:connect(Frame, close_window),

and

    wxFrame:connect(Frame, command_menu_selected, [{callback, Add}, {id, 747}]),


Once these calls have been make the process creating the frame is
sent close_window and command_menu_selected messages.

My questions are "how can I find all the possible values of the 2'nd argument to
wxFrame:connect - and "what is the 3'rd argument" and what is the meaning of the
data in the messages.

I did find a method for answering the first question (which might be correct)

1) go to http://docs.wxwidgets.org/trunk/classwx_frame.html
   and look up section called "Event emitted by this class"
   this has events called

   EV_CLOSE(func)
   EV_ICONIZE(func)

and so on the erlang name of these events appears to be 'close' and 'iconize'

2) If the event you want is not in this list go to the top of the page
   Here we see that wxFrame inherits the properties of wxTopLevelWindow.
   Click on this leads to
   http://docs.wxwidgets.org/trunk/classwx_top_level_window.html
   and we can check which events it omits

Is this how to find the names of the events or is there a better way?

What about my questions 2 and 3?

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.

Cheers

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

Re: wxErlang question 1

PAILLEAU Eric
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() ?

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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxErlang question 1

Joe Armstrong-2
On Sun, Jul 2, 2017 at 10:41 AM, PAILLEAU Eric <[hidden email]> 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
> [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
|  
Report Content as Inappropriate

Re: wxErlang question 1

PAILLEAU Eric

I sympathize :) .

You could however look at wx:demo()  , entry 'frame_utils' and try 'Open
wxMiniFrame' .

This is probably what is the closer to the need you have, if I
understand well.

But yes, I agree, there is a need for a simple documentation for newbies.
I'm not enough specialist of wx to write simple thing on it unfortunately.

Hope this can help anyway.
Regards and good luck :)



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

Re: wxErlang question 1

Joe Armstrong-2
The trouble is that the wx:demo examples are all written using the
wx_object behaviour
which conveniently hides all the interesting things.

I guess I'll have to add some trace statements to wx_object to see
what's *really* happening.

Imagine you want to make an omelette and have no cookbook, all you have to do is
unbreak the eggs and the rest is easy.

wx:demo is the omelette and what I want is the cookbook :-)

/Joe

On Sun, Jul 2, 2017 at 11:57 AM, PAILLEAU Eric <[hidden email]> wrote:

>
> I sympathize :) .
>
> You could however look at wx:demo()  , entry 'frame_utils' and try 'Open
> wxMiniFrame' .
>
> This is probably what is the closer to the need you have, if I understand
> well.
>
> But yes, I agree, there is a need for a simple documentation for newbies.
> I'm not enough specialist of wx to write simple thing on it unfortunately.
>
> Hope this can help anyway.
> Regards and good luck :)
>
>
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxErlang question 1

PAILLEAU Eric
Yes,
there is a need to write a book on this, and lot of people possibly
wanting to buy this. A market found.

to stay with your food metaphor, a french joke, which expresses our 'wx
distress'.
"If I had mushrooms I could do a mushroom omelette but I don't have eggs
either".



Le 02/07/2017 à 12:21, Joe Armstrong a écrit :

> The trouble is that the wx:demo examples are all written using the
> wx_object behaviour
> which conveniently hides all the interesting things.
>
> I guess I'll have to add some trace statements to wx_object to see
> what's *really* happening.
>
> Imagine you want to make an omelette and have no cookbook, all you have to do is
> unbreak the eggs and the rest is easy.
>
> wx:demo is the omelette and what I want is the cookbook :-)
>
> /Joe
>
> On Sun, Jul 2, 2017 at 11:57 AM, PAILLEAU Eric <[hidden email]> wrote:
>>
>> I sympathize :) .
>>
>> You could however look at wx:demo()  , entry 'frame_utils' and try 'Open
>> wxMiniFrame' .
>>
>> This is probably what is the closer to the need you have, if I understand
>> well.
>>
>> But yes, I agree, there is a need for a simple documentation for newbies.
>> I'm not enough specialist of wx to write simple thing on it unfortunately.
>>
>> Hope this can help anyway.
>> Regards and good luck :)
>>
>>
>>
>

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

Re: wxErlang question 1

Richard A. O'Keefe-2
In reply to this post by Joe Armstrong-2
For me, the gold standard remains Interlisp-D.
Interlisp reference manual, 1983 edition (I have it beside me
still), chapter 19 "Interlisp-D Display Facilities".
50 pages.  Complete. Day 1: I've never written any graphics
code in my life.  Read the chapter.  Day 2: read it again.
Day 3: try some small examples.   Day 5: multipane graphic
debugger for the Prolog "microcode" complete.  The nearest
I've ever found is Tcl/Tk.

Do the wxWindows tutorials help at all?
For me, http://docs.wxwidgets.org/stable/overview_helloworld.html
convinced me to stay away.


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

Re: wxErlang question 1

Joe Armstrong-2
On Mon, Jul 3, 2017 at 1:09 AM, Richard A. O'Keefe <[hidden email]> wrote:
> For me, the gold standard remains Interlisp-D.
> Interlisp reference manual, 1983 edition (I have it beside me
> still), chapter 19 "Interlisp-D Display Facilities".
> 50 pages.  Complete. Day 1: I've never written any graphics
> code in my life.  Read the chapter.  Day 2: read it again.
> Day 3: try some small examples.   Day 5: multipane graphic
> debugger for the Prolog "microcode" complete.  The nearest
> I've ever found is Tcl/Tk.

Tcl/Tk was (is) great (bar some rather strange quirks)

>
> Do the wxWindows tutorials help at all?
> For me, http://docs.wxwidgets.org/stable/overview_helloworld.html
> convinced me to stay away.

The examples are horrible - an application seem to consist of a number specific
classes which override or extends the behaviour of the standard classes.

My problem here is that the standard classes do zillions of things and
which methods
must be overridden or extended to achieve somethings is unobvious.

In my opinion use of callbacks and an event loop is the wrong way to
do graphics -
wxWidgets (and friends) seem to me to be extremely complex ways of
hiding concurrency
and replacing it with callbacks and an event loop.

Every time I get locked into a modal window I think - "yet another
concurrency failure"

A typical example is a program that has a form and an account
preferences page. When I'm filling in the form I need some detail that
is the account preferences - but I can't access this until
I've filled in the form - a typical concurrency error.

I think it might be possible to tame wxErlang but right now I can't
figure out how to even do simple
things.

/Joe



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

Re: wxErlang question 1

Dan Gudmundsson-2

On Mon, Jul 3, 2017 at 10:24 AM Joe Armstrong <[hidden email]> wrote:
On Mon, Jul 3, 2017 at 1:09 AM, Richard A. O'Keefe <[hidden email]> wrote:
> For me, the gold standard remains Interlisp-D.
> Interlisp reference manual, 1983 edition (I have it beside me
> still), chapter 19 "Interlisp-D Display Facilities".
> 50 pages.  Complete. Day 1: I've never written any graphics
> code in my life.  Read the chapter.  Day 2: read it again.
> Day 3: try some small examples.   Day 5: multipane graphic
> debugger for the Prolog "microcode" complete.  The nearest
> I've ever found is Tcl/Tk.

Tcl/Tk was (is) great (bar some rather strange quirks)

>
> Do the wxWindows tutorials help at all?
> For me, http://docs.wxwidgets.org/stable/overview_helloworld.html
> convinced me to stay away.

The examples are horrible - an application seem to consist of a number specific
classes which override or extends the behaviour of the standard classes.

My problem here is that the standard classes do zillions of things and
which methods
must be overridden or extended to achieve somethings is unobvious.


Agree..
 
In my opinion use of callbacks and an event loop is the wrong way to
do graphics -
wxWidgets (and friends) seem to me to be extremely complex ways of
hiding concurrency
and replacing it with callbacks and an event loop.


Agree, and it doesn't fit erlang programming modal at all, but the alternative
is to go the tcl/tk way and write our own gui-api, but we don't have resources
nor interest to do that.

And when we started with wxWidgets there where no alternatives, QT was not
open source.
 
Every time I get locked into a modal window I think - "yet another
concurrency failure"

A typical example is a program that has a form and an account
preferences page. When I'm filling in the form I need some detail that
is the account preferences - but I can't access this until
I've filled in the form - a typical concurrency error.


Modal dialogs have it's uses, does not confuse non expert users and so on,
and for example the file dialog is modal on many OS'es.
 
I think it might be possible to tame wxErlang but right now I can't
figure out how to even do simple
things.

Example sent in the other thread.
 

/Joe



>
>
_______________________________________________
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
Loading...