[erlang-questions] Multiple wx-erlang processes

Bob Cowdery bob@REDACTED
Sun May 15 21:32:00 CEST 2011


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



More information about the erlang-questions mailing list