Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In erlang: How do I expand wxNotebook in a panel?

(I have tagged this question as Python as well since I understand Python code so examples in Python are also welcome!).

I want to create a simple window in wxWidgets:
I create a main panel which I add to a form
I associate a boxsizer to the main panel (splitting it in two, horizontally).
I add LeftPanel to the boxsizer,
I add RightPanel to the boxsizer,
I create a new boxsizer (vertical)
I create another boxsizer (horizontal)
I create a Notebook widget
I create a Panel and put it inside the Notebook (addpage)
I add the notebook to the new boxsizer (vertical one)
I add the vertical sizer in the horizontal one
I associate the horizontal sizer to the RightPanel
I add the Left and Right panel to the main sizer.

This doesn't work...

Maybe I have missed something (mental block about sizers) but what I would like to do is to expand the notebook widget without the use of the vertical sizer inside the horizontal one (it doesn't work anyway).

So my question is. Assuming I want to expand the Notebook widget inside the RightPanel to take up the rest of the right side area of the form, how would I go about doing that?

For those that understand Erlang, This is what I have so far:

mainwindow() ->
  %% Create new environment
  X = wx:new(),

  %% Create the main frame
  MainFrame = wxFrame:new(X, -1, "Test"),
  MainPanel = wxPanel:new(MainFrame, [{winid, ?wxID_ANY}]),
  MainSizer = wxBoxSizer:new(?wxHORIZONTAL),
  wxWindow:setSizer(MainPanel, MainSizer),

  %% Left Panel...
  LeftPanel = wxPanel:new(MainPanel, [{winid, ?wxID_ANY}]),
  LeftPanelSizer = wxBoxSizer:new(?wxVERTICAL),
  wxWindow:setSizer(LeftPanel, LeftPanelSizer),
  wxWindow:setMinSize(LeftPanel, {152, -1}),

  %% Right Panel
  RightPanel = wxPanel:new(MainPanel, [{winid, ?wxID_ANY}]),
  RightPanelVerticalSizer = wxBoxSizer:new(?wxVERTICAL),
  RightPanelHorizontalSizer = wxBoxSizer:new(?wxHORIZONTAL),
  wxWindow:setBackgroundColour(RightPanel, {255,0,0}),

  Notebook = wxNotebook:new(RightPanel, ?wxID_ANY, [{size,{-1,-1}}]),
  TestPanel1 = wxPanel:new(Notebook, [{size,{-1,-1}},{winid, ?wxID_ANY}]),
  wxNotebook:addPage(Notebook, TestPanel1, "Testpanel!"),
  TestPanel2 = wxPanel:new(Notebook, [{size,{-1,-1}},{winid, ?wxID_ANY}]),
  wxNotebook:addPage(Notebook, TestPanel2, "Testpanel!"),
  wxSizer:add(RightPanelVerticalSizer, Notebook, [{border,0},{proportion,1}, {flag,?wxEXPAND}]),
  wxSizer:add(RightPanelHorizontalSizer, RightPanelVerticalSizer, [{proportion,1}, {flag,?wxEXPAND}]),
  wxWindow:setSizer(RightPanel, RightPanelHorizontalSizer),

  %% Main Sizer
  wxSizer:add(MainSizer, LeftPanel, [{border, 2}, {flag,?wxEXPAND bor ?wxALL}]),
  wxSizer:add(MainSizer, RightPanel, [{border, 2}, {flag,?wxEXPAND bor ?wxTOP bor ?wxRIGHT bor ?wxBOTTOM}]),

  %% Connect to events
  wxFrame:connect(MainFrame, close_window),
  wxWindow:center(MainFrame),  
  wxWindow:show(MainFrame),
  ...
like image 596
Mazen Harake Avatar asked Aug 02 '09 08:08

Mazen Harake


1 Answers

I'm closing this question (as soon as I can) after I figured out what I needed to do.

Basically I changed the proportion to 1 of the add command to the main panel (this will expand the whole thing)

New code:

  %% Main Sizer
  wxSizer:add(MainSizer, LeftPanel, [{proportion,0},{border, 2}, {flag,?wxEXPAND bor ?wxALL}]),
  wxSizer:add(MainSizer, RightPanel, [{proportion,1},{border, 2}, {flag,?wxEXPAND bor ?wxTOP bor ?wxRIGHT bor ?wxBOTTOM}]),
like image 169
Mazen Harake Avatar answered Oct 29 '22 00:10

Mazen Harake