2009-08-02 7 views
8

(J'ai aussi marqué cette question en tant que Python puisque je comprends le code Python, les exemples en Python sont donc les bienvenus!).In erlang: Comment développer wxNotebook dans un panneau?

Je veux créer une fenêtre simple wxWidgets:
créer un panneau principal que j'ajouter à une forme
j'associe un boxsizer au panneau principal (la divisant en deux, horizontalement).
ajouter LeftPanel au boxsizer,
-je ajouter RightPanel au boxsizer,
créer un nouveau boxsizer (vertical)
Je crée une autre boxsizer (horizontal)
créer un widget Notebook
créer un panneau et le mettre dans l'ordinateur portable (addPage)
-je ajouter le bloc-notes à la nouvelle boxsizer (verticale)
-je ajouter sizer verticale à l'horizontale un
j'associe sizer horizontal à la RightPanel
J'ajoute les panneaux Gauche et Droite au calibreur principal.

Cela ne fonctionne pas ...

Peut-être que je l'ai manqué quelque chose (blocage mental au sujet calibreurs), mais ce que je comme à faire est d'élargir le widget bloc-notes sans l'utilisation du calibreur vertical à l'intérieur de l'horizontale (ça ne marche pas quand même).

Donc ma question est. En supposant que je souhaite étendre le widget Notebook dans le RightPanel pour occuper le reste de la partie droite du formulaire, comment pourrais-je faire cela?

Pour ceux qui comprennent Erlang, c'est ce que j'ai jusqu'à présent:

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), 
    ... 

Répondre

4

Je ferme cette question (dès que possible) après avoir compris ce que je devais faire.

Fondamentalement, je changé la proportion de 1 de la commande ajouter au panneau principal (ce qui élargira la chose)

Nouveau 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}]), 
Questions connexes