Extracted from my elixir sips episode on wx, and maybe not how I'd ultimately prefer to do it, but this works:
-------
So there's a problem with this code, and that's that there's no such thing as
the `wx_const` module we used in the sizer. The issue here is that wxwidgets
provides some constants in an `.hrl` file that define magic numbers for things
like "make this box sizer horizontally oriented", but there's no trivial way
presently to get at the constants from an .hrl file from Elixir.
What we're going to do is define a trivial erlang module that will just return
that value. To add an erlang module to your Elixir project, just make a `src`
directory and put an `.erl` file in there:
```sh
mkdir src
vim src/wx_const.erl
```
Alright, so this module is trivial:
```erlang
-module(wx_const).
-compile(export_all).
-include_lib("wx/include/wx.hrl").
wx_horizontal() ->
?wxHORIZONTAL.
wx_vertical() ->
?wxVERTICAL.
wx_expand() ->
?wxEXPAND.
wx_all() ->
?wxALL.
```
Alright, with that in place, let's run it again:
```sh
iex -S mix
```
OK, cool, so now we've got multiple buttons in the frame. We want to build a
grid of numbers. We'll do this with three horizontal boxsizers embedded in a
vertical boxsizer. Let's see what that looks like. We're just going to do this
in a very naive way, more to learn about wx than to end up with code we're
thrilled with here:
```elixir
defmodule WxCalc.Window do
@title 'WxCalc'
def start do
wx = :wx.new
panel = :wxFrame.new(wx, -1, @title)
first_row = :wxBoxSizer.new(:wx_const.wx_horizontal)
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.