[erlang-questions] Multiple wx-erlang processes

Bob Cowdery <>
Mon May 16 10:02:10 CEST 2011


Dan
Thanks, good to know I'm on the right track.

Bob

On 16/05/2011 08:26, Dan Gudmundsson wrote:
> Yes that is how how handle set/get_env.
>
> But why not create the panel and setup the event subscription inside
> init as well,
> the thought here was that wx_object is used to override the C++ object and
> thus you return {Panel, State} from init.
Thanks, yes I could do that. I guess it was just consistency. My main
process does just that but the setup of each panel is a separate module
with create_display/3. I didn't want to change the pattern just because
this was a separate process.
> /Dan
>
> On Sun, May 15, 2011 at 9:32 PM, Bob Cowdery <> wrote:
>> Hi,
>>
>> This seems to initialise ok but is it the correct way to do things
>> before I start implementing the main functions.
>>
>> I have a main wx processing using wx_object behaviour. This handles all
>> the user interaction stuff. Now I want a separate process that will
>> handle graphic displays. I create another wx_object process and start it
>> from the main wx process
>>
>> The start/2 and init/2 of the graphic display.
>>
>> start(Env, Frame) ->
>>    wx_object:start_link({local, ?MODULE}, ?MODULE, [Env, Frame], []),
>>    {ok, self()}.
>>
>> init([Env, Frame]) ->
>>    io:format("~p starting~n", [?MODULE]),
>>    wx:set_env(Env),
>>    {Frame, #state{}}.
>>
>> I pass in wx:get_env() and the main frame of the main wx process as I
>> don't want another frame.
>>
>> Then call from the main process (which is using AUI) to set up the
>> drawing surface.
>>
>> handle_cast({create_display, Parent, Manager, Pane}, State) ->
>>    %% Canvas on which to build graphics
>>    Canvas = wxPanel:new(Parent, [{style, ?wxFULL_REPAINT_ON_RESIZE}]),
>>    ...
>>
>> Regards
>> Bob
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>




More information about the erlang-questions mailing list