wxErlang question 4

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

wxErlang question 4

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

Re: wxErlang question 4

Frank Muller
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!!! 

/Frank


Le sam. 8 juil. 2017 à 11:01, Joe Armstrong <[hidden email]> 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
[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: wxErlang question 4

Joe Armstrong-2
On Sat, Jul 8, 2017 at 11:44 AM, Frank Muller
<[hidden email]> 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 <[hidden email]> 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
>> [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: wxErlang question 4

Simon St.Laurent-2
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
> <[hidden email]> 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 <[hidden email]> 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
>>> [hidden email]
>>> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> 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: wxErlang question 4

Joe Armstrong-2
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 <[hidden email]> 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
>> <[hidden email]> 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 <[hidden email]> 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
>>>> [hidden email]
>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>> _______________________________________________
>> 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
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: wxErlang question 4

Steve Davis
In reply to this post by Joe Armstrong-2
Sizers are crazy. A while back I had a decent go at making a hand-written version of wx interfacing directly to the erlang driver and trying to make it sensible as an API like GS. I think it should still work.

The following code was the result of a lot of reading the WxWidgets C++ API docs and translating into what I felt was sensible to get to a single interface module that resembled GS (i.e the module gx.erl).






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

Re: wxErlang question 4

Joe Armstrong-2
Wow - lot's of code for me to stare at - thanks

A couple of questions:

1) I downloaded the gx project and saw that there had been no
    commits since Jul 13 2014 - is this totally dead?

2) How do I run your gx code? - what's a top level command to create a window???

Cheers

/Joe


On Tue, Jul 11, 2017 at 1:07 AM, Steve Davis
<[hidden email]> wrote:

> Sizers are crazy. A while back I had a decent go at making a hand-written
> version of wx interfacing directly to the erlang driver and trying to make
> it sensible as an API like GS. I think it should still work.
>
> The following code was the result of a lot of reading the WxWidgets C++ API
> docs and translating into what I felt was sensible to get to a single
> interface module that resembled GS (i.e the module gx.erl).
>
> https://github.com/komone/gx/blob/master/src/ui/gx_ui_sizer.erl
>
> https://github.com/komone/gx/blob/master/src/ui/gx_ui_control.erl
>
> https://github.com/komone/gx/blob/master/src/ui/gx_ui_button.erl
>
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: wxErlang question 4

Steve Davis
1) One of those projects that I haven’t had time for. If there was interest, it may rekindle my interest in moving it along. Looking back, with the second prototype I diverged too far from the GS way of doing this as I got focused on XML definitions and so the interactive REPL part suffered. it’s really code in mid-flight.

2) However, the code still seems to work under R20 - See console session below:

Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.0  (abort with ^G)
1> gx:start().
[<0.63.0> gx_driver:150] "/opt/local/lib/erlang/lib/wx-1.8.1/priv"
[<0.63.0> gx_driver:124] info_got_wx_consts
[<0.63.0> gx_driver:134] {handle_info,
                             {wxe_driver,open_file,"/Users/stevedavis"}}
{ok,<0.62.0>}
2> rr(gx).
[aui,bitmapbutton,box,button,calendar,checkbox,checklist,
 choice,combo,control,date,dialog,editor,evh,filetree,font,
 frame,g,grid,gs,gs_font,gui,gx,gx_cache,gx_ui,gx_wx,image,
 input,line|...]
3> F = #frame{id=window, size={400,200}}.
#frame{id = window,ref = undefined,label = undefined,
       pos = {-1,-1},
       size = {400,200},
       callbacks = [],icon = undefined,title = <<"Untitled">>,
       show = true,virtual = false,content = []}
4> gx:create(F).
[#gx_ui{id = window,
        ref = #wx_ref{ref = 37,type = wxFrame,state = []},
        parent = #wx_ref{ref = 0,type = wx,state = []},
        module = gx_ui_frame}]
5> gx:names().
[window]
6> gx:config(window, size, {800, 400}).
[<0.60.0> gx_ui:59] {{g,<0.62.0>,#Port<0.3025>,undefined,<0.64.0>,gx},
                     window,
                     [{size,{800,400}}]}
[ok]
7> gx:ide().
[<0.95.0> gx_ui:59] {{g,<0.93.0>,#Port<0.3158>,undefined,<0.94.0>,ide},
                     log,
                     [{append,<<"$ {init,{gx,ide,{wx_ref,0,wx,[]},gx,start,[],[]},[{resources,undefined}]}\n">>}]}
{ok,<0.93.0>}




On Jul 11, 2017, at 2:48 AM, Joe Armstrong <[hidden email]> wrote:

Wow - lot's of code for me to stare at - thanks

A couple of questions:

1) I downloaded the gx project and saw that there had been no
   commits since Jul 13 2014 - is this totally dead?

2) How do I run your gx code? - what's a top level command to create a window???

Cheers

/Joe


On Tue, Jul 11, 2017 at 1:07 AM, Steve Davis
<[hidden email]> wrote:
Sizers are crazy. A while back I had a decent go at making a hand-written
version of wx interfacing directly to the erlang driver and trying to make
it sensible as an API like GS. I think it should still work.

The following code was the result of a lot of reading the WxWidgets C++ API
docs and translating into what I felt was sensible to get to a single
interface module that resembled GS (i.e the module gx.erl).

https://github.com/komone/gx/blob/master/src/ui/gx_ui_sizer.erl

https://github.com/komone/gx/blob/master/src/ui/gx_ui_control.erl

https://github.com/komone/gx/blob/master/src/ui/gx_ui_button.erl




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

Re: wxErlang question 4

Joe Armstrong-2
It didn't work for me - how did you launch this?

I did erl -pa ebin in the root directory (gx-master)
gx:config works and I see a window

but gx:idx() crashes with a badmatch
in line 37 of gx_ui_filetree.erl the line saying

 directory = path:type(Path),

I think this is returning undefined -

Do I have to set some environment variables or something?

./Joe



On Tue, Jul 11, 2017 at 1:22 PM, Steve Davis
<[hidden email]> wrote:

> 1) One of those projects that I haven’t had time for. If there was interest,
> it may rekindle my interest in moving it along. Looking back, with the
> second prototype I diverged too far from the GS way of doing this as I got
> focused on XML definitions and so the interactive REPL part suffered. it’s
> really code in mid-flight.
>
> 2) However, the code still seems to work under R20 - See console session
> below:
>
> Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10]
> [async-threads:10] [hipe] [kernel-poll:false]
>
> Eshell V9.0  (abort with ^G)
> 1> gx:start().
> [<0.63.0> gx_driver:150] "/opt/local/lib/erlang/lib/wx-1.8.1/priv"
> [<0.63.0> gx_driver:124] info_got_wx_consts
> [<0.63.0> gx_driver:134] {handle_info,
>                              {wxe_driver,open_file,"/Users/stevedavis"}}
> {ok,<0.62.0>}
> 2> rr(gx).
> [aui,bitmapbutton,box,button,calendar,checkbox,checklist,
>  choice,combo,control,date,dialog,editor,evh,filetree,font,
>  frame,g,grid,gs,gs_font,gui,gx,gx_cache,gx_ui,gx_wx,image,
>  input,line|...]
> 3> F = #frame{id=window, size={400,200}}.
> #frame{id = window,ref = undefined,label = undefined,
>        pos = {-1,-1},
>        size = {400,200},
>        callbacks = [],icon = undefined,title = <<"Untitled">>,
>        show = true,virtual = false,content = []}
> 4> gx:create(F).
> [#gx_ui{id = window,
>         ref = #wx_ref{ref = 37,type = wxFrame,state = []},
>         parent = #wx_ref{ref = 0,type = wx,state = []},
>         module = gx_ui_frame}]
> 5> gx:names().
> [window]
> 6> gx:config(window, size, {800, 400}).
> [<0.60.0> gx_ui:59] {{g,<0.62.0>,#Port<0.3025>,undefined,<0.64.0>,gx},
>                      window,
>                      [{size,{800,400}}]}
> [ok]
> 7> gx:ide().
> [<0.95.0> gx_ui:59] {{g,<0.93.0>,#Port<0.3158>,undefined,<0.94.0>,ide},
>                      log,
>                      [{append,<<"$
> {init,{gx,ide,{wx_ref,0,wx,[]},gx,start,[],[]},[{resources,undefined}]}\n">>}]}
> {ok,<0.93.0>}
>
>
>
>
> On Jul 11, 2017, at 2:48 AM, Joe Armstrong <[hidden email]> wrote:
>
> Wow - lot's of code for me to stare at - thanks
>
> A couple of questions:
>
> 1) I downloaded the gx project and saw that there had been no
>    commits since Jul 13 2014 - is this totally dead?
>
> 2) How do I run your gx code? - what's a top level command to create a
> window???
>
> Cheers
>
> /Joe
>
>
> On Tue, Jul 11, 2017 at 1:07 AM, Steve Davis
> <[hidden email]> wrote:
>
> Sizers are crazy. A while back I had a decent go at making a hand-written
> version of wx interfacing directly to the erlang driver and trying to make
> it sensible as an API like GS. I think it should still work.
>
> The following code was the result of a lot of reading the WxWidgets C++ API
> docs and translating into what I felt was sensible to get to a single
> interface module that resembled GS (i.e the module gx.erl).
>
> https://github.com/komone/gx/blob/master/src/ui/gx_ui_sizer.erl
>
> https://github.com/komone/gx/blob/master/src/ui/gx_ui_control.erl
>
> https://github.com/komone/gx/blob/master/src/ui/gx_ui_button.erl
>
>
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: wxErlang question 4

Steve Davis
You shouldn’t have to, no. I just cloned a new copy from github (and cleared my ERL_LIBS to make sure I wasn’t pulling in anything else) and it all seemed to work for me.

Do you have the stacktrace?


> On Jul 11, 2017, at 9:39 AM, Joe Armstrong <[hidden email]> wrote:
>
> It didn't work for me - how did you launch this?
>
> I did erl -pa ebin in the root directory (gx-master)
> gx:config works and I see a window
>
> but gx:idx() crashes with a badmatch
> in line 37 of gx_ui_filetree.erl the line saying
>
> directory = path:type(Path),
>
> I think this is returning undefined -
>
> Do I have to set some environment variables or something?
>
> ./Joe
>
>
>
> On Tue, Jul 11, 2017 at 1:22 PM, Steve Davis
> <[hidden email]> wrote:
>> 1) One of those projects that I haven’t had time for. If there was interest,
>> it may rekindle my interest in moving it along. Looking back, with the
>> second prototype I diverged too far from the GS way of doing this as I got
>> focused on XML definitions and so the interactive REPL part suffered. it’s
>> really code in mid-flight.
>>
>> 2) However, the code still seems to work under R20 - See console session
>> below:
>>
>> Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10]
>> [async-threads:10] [hipe] [kernel-poll:false]
>>
>> Eshell V9.0  (abort with ^G)
>> 1> gx:start().
>> [<0.63.0> gx_driver:150] "/opt/local/lib/erlang/lib/wx-1.8.1/priv"
>> [<0.63.0> gx_driver:124] info_got_wx_consts
>> [<0.63.0> gx_driver:134] {handle_info,
>>                             {wxe_driver,open_file,"/Users/stevedavis"}}
>> {ok,<0.62.0>}
>> 2> rr(gx).
>> [aui,bitmapbutton,box,button,calendar,checkbox,checklist,
>> choice,combo,control,date,dialog,editor,evh,filetree,font,
>> frame,g,grid,gs,gs_font,gui,gx,gx_cache,gx_ui,gx_wx,image,
>> input,line|...]
>> 3> F = #frame{id=window, size={400,200}}.
>> #frame{id = window,ref = undefined,label = undefined,
>>       pos = {-1,-1},
>>       size = {400,200},
>>       callbacks = [],icon = undefined,title = <<"Untitled">>,
>>       show = true,virtual = false,content = []}
>> 4> gx:create(F).
>> [#gx_ui{id = window,
>>        ref = #wx_ref{ref = 37,type = wxFrame,state = []},
>>        parent = #wx_ref{ref = 0,type = wx,state = []},
>>        module = gx_ui_frame}]
>> 5> gx:names().
>> [window]
>> 6> gx:config(window, size, {800, 400}).
>> [<0.60.0> gx_ui:59] {{g,<0.62.0>,#Port<0.3025>,undefined,<0.64.0>,gx},
>>                     window,
>>                     [{size,{800,400}}]}
>> [ok]
>> 7> gx:ide().
>> [<0.95.0> gx_ui:59] {{g,<0.93.0>,#Port<0.3158>,undefined,<0.94.0>,ide},
>>                     log,
>>                     [{append,<<"$
>> {init,{gx,ide,{wx_ref,0,wx,[]},gx,start,[],[]},[{resources,undefined}]}\n">>}]}
>> {ok,<0.93.0>}
>>
>>
>>
>>
>> On Jul 11, 2017, at 2:48 AM, Joe Armstrong <[hidden email]> wrote:
>>
>> Wow - lot's of code for me to stare at - thanks
>>
>> A couple of questions:
>>
>> 1) I downloaded the gx project and saw that there had been no
>>   commits since Jul 13 2014 - is this totally dead?
>>
>> 2) How do I run your gx code? - what's a top level command to create a
>> window???
>>
>> Cheers
>>
>> /Joe
>>
>>
>> On Tue, Jul 11, 2017 at 1:07 AM, Steve Davis
>> <[hidden email]> wrote:
>>
>> Sizers are crazy. A while back I had a decent go at making a hand-written
>> version of wx interfacing directly to the erlang driver and trying to make
>> it sensible as an API like GS. I think it should still work.
>>
>> The following code was the result of a lot of reading the WxWidgets C++ API
>> docs and translating into what I felt was sensible to get to a single
>> interface module that resembled GS (i.e the module gx.erl).
>>
>> https://github.com/komone/gx/blob/master/src/ui/gx_ui_sizer.erl
>>
>> https://github.com/komone/gx/blob/master/src/ui/gx_ui_control.erl
>>
>> https://github.com/komone/gx/blob/master/src/ui/gx_ui_button.erl
>>
>>
>>

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

Re: wxErlang question 4

Steve Davis
I see why. You can either:

1) rename the parent directory to “gx” rather than “gx-master” 
2) or edit the path attribute in priv/ide.xml line 41 <filetree id="filetree" fill="both" path="../gx" onclick="on_tree" ondblclick="on_tree" onchange="on_tree”>  change it to a valid directory (e.g. ../gx-master in your case)...

...and it should work.



When I left it, I was using the editor to hack the code itself…

Alternatively set the path

On Jul 11, 2017, at 12:57 PM, Steve Davis <[hidden email]> wrote:

You shouldn’t have to, no. I just cloned a new copy from github (and cleared my ERL_LIBS to make sure I wasn’t pulling in anything else) and it all seemed to work for me.

Do you have the stacktrace?


On Jul 11, 2017, at 9:39 AM, Joe Armstrong <[hidden email]> wrote:

It didn't work for me - how did you launch this?

I did erl -pa ebin in the root directory (gx-master)
gx:config works and I see a window

but gx:idx() crashes with a badmatch
in line 37 of gx_ui_filetree.erl the line saying

directory = path:type(Path),

I think this is returning undefined -

Do I have to set some environment variables or something?

./Joe



On Tue, Jul 11, 2017 at 1:22 PM, Steve Davis
<[hidden email]> wrote:
1) One of those projects that I haven’t had time for. If there was interest,
it may rekindle my interest in moving it along. Looking back, with the
second prototype I diverged too far from the GS way of doing this as I got
focused on XML definitions and so the interactive REPL part suffered. it’s
really code in mid-flight.

2) However, the code still seems to work under R20 - See console session
below:

Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10]
[async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.0  (abort with ^G)
1> gx:start().
[<0.63.0> gx_driver:150] "/opt/local/lib/erlang/lib/wx-1.8.1/priv"
[<0.63.0> gx_driver:124] info_got_wx_consts
[<0.63.0> gx_driver:134] {handle_info,
                           {wxe_driver,open_file,"/Users/stevedavis"}}
{ok,<0.62.0>}
2> rr(gx).
[aui,bitmapbutton,box,button,calendar,checkbox,checklist,
choice,combo,control,date,dialog,editor,evh,filetree,font,
frame,g,grid,gs,gs_font,gui,gx,gx_cache,gx_ui,gx_wx,image,
input,line|...]
3> F = #frame{id=window, size={400,200}}.
#frame{id = window,ref = undefined,label = undefined,
     pos = {-1,-1},
     size = {400,200},
     callbacks = [],icon = undefined,title = <<"Untitled">>,
     show = true,virtual = false,content = []}
4> gx:create(F).
[#gx_ui{id = window,
      ref = #wx_ref{ref = 37,type = wxFrame,state = []},
      parent = #wx_ref{ref = 0,type = wx,state = []},
      module = gx_ui_frame}]
5> gx:names().
[window]
6> gx:config(window, size, {800, 400}).
[<0.60.0> gx_ui:59] {{g,<0.62.0>,#Port<0.3025>,undefined,<0.64.0>,gx},
                   window,
                   [{size,{800,400}}]}
[ok]
7> gx:ide().
[<0.95.0> gx_ui:59] {{g,<0.93.0>,#Port<0.3158>,undefined,<0.94.0>,ide},
                   log,
                   [{append,<<"$
{init,{gx,ide,{wx_ref,0,wx,[]},gx,start,[],[]},[{resources,undefined}]}\n">>}]}
{ok,<0.93.0>}




On Jul 11, 2017, at 2:48 AM, Joe Armstrong <[hidden email]> wrote:

Wow - lot's of code for me to stare at - thanks

A couple of questions:

1) I downloaded the gx project and saw that there had been no
 commits since Jul 13 2014 - is this totally dead?

2) How do I run your gx code? - what's a top level command to create a
window???

Cheers

/Joe


On Tue, Jul 11, 2017 at 1:07 AM, Steve Davis
<[hidden email]> wrote:

Sizers are crazy. A while back I had a decent go at making a hand-written
version of wx interfacing directly to the erlang driver and trying to make
it sensible as an API like GS. I think it should still work.

The following code was the result of a lot of reading the WxWidgets C++ API
docs and translating into what I felt was sensible to get to a single
interface module that resembled GS (i.e the module gx.erl).

https://github.com/komone/gx/blob/master/src/ui/gx_ui_sizer.erl

https://github.com/komone/gx/blob/master/src/ui/gx_ui_control.erl

https://github.com/komone/gx/blob/master/src/ui/gx_ui_button.erl






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

Re: wxErlang question 4

Joe Armstrong-2
In reply to this post by Steve Davis
Stack trace follows:


test.erl

-module(test).

-compile(export_all).
-include("include/gx.hrl").

test() ->
    gx:start(),
    %% rr(gx).
    F = #frame{id=window, size={400,200}},
    gx:create(F),
    gx:names(),
    gx:config(window, size, {800, 400}),
    gx:ide().




1> test:test().

[<0.67.0> gx_driver]
"/usr/local/Cellar/erlang/20.0/lib/erlang/lib/wx-1.8.1/priv"

[<0.67.0> gx_driver] {handle_info,{wxe_driver,open_file,"enabled"}}

[<0.66.0> gx_srv] {g,<0.66.0>,#Port<0.765>,undefined,<0.68.0>,gx}

[<0.70.0> gx_srv] {g,<0.70.0>,#Port<0.779>,undefined,<0.71.0>,ide}

** exception exit: {{badmatch,undefined},

                    [{gx_ui_filetree,create,3,

                                     [{file,"src/ui/gx_ui_filetree.erl"},

                                      {line,37}]},

                     {gx_ui,create,3,[{file,"src/gx_ui.erl"},{line,44}]},

                     {gx_ui,'-create/3-lc$^0/1-0-',3,

                            [{file,"src/gx_ui.erl"},{line,39}]},

                     {gx_ui_panel,create,3,

                                  [{file,"src/ui/gx_ui_panel.erl"},{line,46}]},

                     {gx_ui,create,3,[{file,"src/gx_ui.erl"},{line,44}]},

                     {gx_ui_tab,create,3,

                                [{file,"src/ui/gx_ui_tab.erl"},{line,35}]},

                     {gx_ui,create,3,[{file,"src/gx_ui.erl"},{line,44}]},

                     {gx_ui,'-create/3-lc$^0/1-0-',3,

                            [{file,"src/gx_ui.erl"},{line,39}]}]}

     in function  gx_wx:batch/2 (src/gx_wx.erl, line 39)

     in call from gx_srv:start/1 (src/gx_srv.erl, line 33)

/Joe

On Tue, Jul 11, 2017 at 7:57 PM, Steve Davis
<[hidden email]> wrote:

> You shouldn’t have to, no. I just cloned a new copy from github (and cleared my ERL_LIBS to make sure I wasn’t pulling in anything else) and it all seemed to work for me.
>
> Do you have the stacktrace?
>
>
>> On Jul 11, 2017, at 9:39 AM, Joe Armstrong <[hidden email]> wrote:
>>
>> It didn't work for me - how did you launch this?
>>
>> I did erl -pa ebin in the root directory (gx-master)
>> gx:config works and I see a window
>>
>> but gx:idx() crashes with a badmatch
>> in line 37 of gx_ui_filetree.erl the line saying
>>
>> directory = path:type(Path),
>>
>> I think this is returning undefined -
>>
>> Do I have to set some environment variables or something?
>>
>> ./Joe
>>
>>
>>
>> On Tue, Jul 11, 2017 at 1:22 PM, Steve Davis
>> <[hidden email]> wrote:
>>> 1) One of those projects that I haven’t had time for. If there was interest,
>>> it may rekindle my interest in moving it along. Looking back, with the
>>> second prototype I diverged too far from the GS way of doing this as I got
>>> focused on XML definitions and so the interactive REPL part suffered. it’s
>>> really code in mid-flight.
>>>
>>> 2) However, the code still seems to work under R20 - See console session
>>> below:
>>>
>>> Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10]
>>> [async-threads:10] [hipe] [kernel-poll:false]
>>>
>>> Eshell V9.0  (abort with ^G)
>>> 1> gx:start().
>>> [<0.63.0> gx_driver:150] "/opt/local/lib/erlang/lib/wx-1.8.1/priv"
>>> [<0.63.0> gx_driver:124] info_got_wx_consts
>>> [<0.63.0> gx_driver:134] {handle_info,
>>>                             {wxe_driver,open_file,"/Users/stevedavis"}}
>>> {ok,<0.62.0>}
>>> 2> rr(gx).
>>> [aui,bitmapbutton,box,button,calendar,checkbox,checklist,
>>> choice,combo,control,date,dialog,editor,evh,filetree,font,
>>> frame,g,grid,gs,gs_font,gui,gx,gx_cache,gx_ui,gx_wx,image,
>>> input,line|...]
>>> 3> F = #frame{id=window, size={400,200}}.
>>> #frame{id = window,ref = undefined,label = undefined,
>>>       pos = {-1,-1},
>>>       size = {400,200},
>>>       callbacks = [],icon = undefined,title = <<"Untitled">>,
>>>       show = true,virtual = false,content = []}
>>> 4> gx:create(F).
>>> [#gx_ui{id = window,
>>>        ref = #wx_ref{ref = 37,type = wxFrame,state = []},
>>>        parent = #wx_ref{ref = 0,type = wx,state = []},
>>>        module = gx_ui_frame}]
>>> 5> gx:names().
>>> [window]
>>> 6> gx:config(window, size, {800, 400}).
>>> [<0.60.0> gx_ui:59] {{g,<0.62.0>,#Port<0.3025>,undefined,<0.64.0>,gx},
>>>                     window,
>>>                     [{size,{800,400}}]}
>>> [ok]
>>> 7> gx:ide().
>>> [<0.95.0> gx_ui:59] {{g,<0.93.0>,#Port<0.3158>,undefined,<0.94.0>,ide},
>>>                     log,
>>>                     [{append,<<"$
>>> {init,{gx,ide,{wx_ref,0,wx,[]},gx,start,[],[]},[{resources,undefined}]}\n">>}]}
>>> {ok,<0.93.0>}
>>>
>>>
>>>
>>>
>>> On Jul 11, 2017, at 2:48 AM, Joe Armstrong <[hidden email]> wrote:
>>>
>>> Wow - lot's of code for me to stare at - thanks
>>>
>>> A couple of questions:
>>>
>>> 1) I downloaded the gx project and saw that there had been no
>>>   commits since Jul 13 2014 - is this totally dead?
>>>
>>> 2) How do I run your gx code? - what's a top level command to create a
>>> window???
>>>
>>> Cheers
>>>
>>> /Joe
>>>
>>>
>>> On Tue, Jul 11, 2017 at 1:07 AM, Steve Davis
>>> <[hidden email]> wrote:
>>>
>>> Sizers are crazy. A while back I had a decent go at making a hand-written
>>> version of wx interfacing directly to the erlang driver and trying to make
>>> it sensible as an API like GS. I think it should still work.
>>>
>>> The following code was the result of a lot of reading the WxWidgets C++ API
>>> docs and translating into what I felt was sensible to get to a single
>>> interface module that resembled GS (i.e the module gx.erl).
>>>
>>> https://github.com/komone/gx/blob/master/src/ui/gx_ui_sizer.erl
>>>
>>> https://github.com/komone/gx/blob/master/src/ui/gx_ui_control.erl
>>>
>>> https://github.com/komone/gx/blob/master/src/ui/gx_ui_button.erl
>>>
>>>
>>>
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions