[erlang-questions] wxErlang: wxApp behaviour?
jwebb@REDACTED
jwebb@REDACTED
Tue Jan 29 05:56:53 CET 2008
Hi Dan,
I finally found some time to take a closer look at wxErlang. And I got
thoroughly distracted ;)
The attached patch (well, more of a suggestion, really) is a rough cut
attempt to implement the wx server as a behaviour. The programmer
declares wx_app behaviour and a couple of callback functions
e.g.)
-module(basic).
-behaviour(wx_app).
-export([on_init/2, on_event/2,...]).
then, in the spirit of wxWidgets, performs widget initialization in the
on_init/2 callback
on_init(AppContext, AppArgs) -> ..., {ok, State}.
and handles unconnected events in the on_event/2 callback
on_event(Event,State) -> ..., {ok,NewState}.
The application can can be started by calling the wx_app module's start
or start_link functions
wx_app:start(Mod, Args, Opts) -> {ok,Pid} | {error, Reason}
Abstracting out the subsystem start up and event loop plus getting all
that OTP goodness [almost] for free might be one way to go. I've only
dabbled with the basic.erl example but you can try something like
> {ok,Pid} = wx_app:start(basic, [], [{debug,[trace]}]).
Anyway, just a thought...
Best Regards
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wxerlang.patch
Type: application/octet-stream
Size: 14260 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080129/6b3e589e/attachment.obj>
More information about the erlang-questions
mailing list