Download presentation
1
wxErlang Mats-Ola Persson
2
wxErlang GUI library for Erlang write GUI applications cross platform
cross platform look and feel
3
Example A “stupid” tic-tac-toe application
No intelligent behavior is implemented Just the (good) looks
4
Creating a window create_window() ->
wx:start(), % initialize wxErlang % create a frame (window) with no parent Frame = wx:frame(?NULL, ?wxID_ANY, “Hello World!”), wx:show(Frame). % make the frame visible
5
Creating a window Not very exciting: an empty window
6
Event-driven programming
Things “react” to mouse clicks, mouse movements, etc. Event-handlers, callback functions
7
Events create_window() -> wx:start(),
Frame = wx:frame(?NULL, ?wxID_ANY, “Hello World!”), % event-handler that reacts to close clicks wx:connect(Frame, ?wxEVT_CLOSE_WINDOW, fun(_,_) -> wx:quit() end), wx:show(Frame).
8
Layouts Platform independent layouts Sizers
No fixed sized widgets, etc. Arbitrary complex layouts Let’s add the buttons!
9
Sizers create_grid(Frame) -> Grid = wx:grid_sizer(3), % a grid sizer with 3 cols create_buttons(Grid, Frame, 9), % create 9 buttons Grid. create_buttons(_, _, 0) -> ok;create_buttons(Grid, Frame, N) -> Button = wx:button(Frame, N), %a button without label wx:add(Grid, Button), % add button to the sizer create_buttons(Grid, Frame, N - 1).
10
The result A “shell” of a tic-tac-toe application
11
wxEtop Port of the old “etop” New features context menues
view running code ...
12
From the programmers point of view
wxErlang is verbose - like most GUI libraries Trial-and-error - like most GUI libraries Interface designers XRCed, DialogBlocks, etc.
13
Design decisions Binding to the C++ GUI library wxWidgets
Get a lot for free “free” features from wxWidgets reduced maintenance work wxErlang interface resembles wxWidgets C++ interface free documentation(!) Varför wxWidgets?
14
Translation scheme Easy Functions Multiple return values => tuples
... Constants
15
Translation scheme Not as easy Classes
Overloading and overriding functions Type system
16
Safety Checks arguments Types Primitive values Objects Sanity
17
Implementational details
Most of the code is generated from wxWidgets headers Implemented as a “port program” Has a lot of bugs
18
Wrap up Current status - a prototyp wxEtop Perhaps 10% implemented
Future
19
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.