在erlang中:如何在面板中展开wxNotebook?
(我也将这个问题标记为Python,因为我理解Python代码,所以也欢迎Python中的示例!)。
我想在 wxWidgets 中创建一个简单的窗口:
我创建一个主面板并将其添加到表单中
我将 boxsizer 关联到主面板(将其水平分成两部分)。
我将 LeftPanel 添加到 boxsizer,
我将 RightPanel 添加到 boxsizer,
我创建了一个新的 boxsizer(垂直)
我创建了另一个 boxsizer(水平)
我创建了一个笔记本小部件
我创建一个面板并将其放入笔记本中(addpage)
我将笔记本添加到新的 boxsizer(垂直的)
我在水平尺寸调整器中添加了垂直尺寸调整器
我将水平调整器关联到 RightPanel
我将左侧和右侧面板添加到主尺寸调整器中。
这不起作用...
也许我错过了一些东西(关于尺寸调整器的心理障碍),但我想要做的是展开笔记本小部件,而不使用水平大小调整器内的垂直大小调整器(无论如何它都不起作用)。
所以我的问题是。 假设我想扩展 RightPanel 内的 Notebook 小部件以占据表单右侧区域的其余部分,我将如何去做呢?
对于那些了解 Erlang 的人,这就是我到目前为止所拥有的:
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),
...
(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),
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在弄清楚我需要做什么后,我将(尽快)结束这个问题。
基本上我将主面板的添加命令的比例更改为 1(这将扩展整个内容)
新代码:
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: