sizer 中的 WxWidgets 面板似乎不起作用 [英] WxWidgets panels in sizers don't seem to be working
问题描述
我有一个 WxWidgets 项目,设置如下:
I have a WxWidgets project that is setup like this:
Main Frame->Main Panel->Vertical Sizer
->Horizontal Sizer for a few buttons etc
->Horizontal Sizer that shows all the main info.
->In that main sizer, I have a SimpleBook
->The Simple book has 3 panels in it.
无论如何,SimpleBook 的可见页面都在顶部的几个按钮"sizer 之下.
No matter what, the SimpleBook's visable page is under the top "few buttons" sizer.
当在 sizer 中有面板时,面板是否遵守 sizer 在窗口内的位置?
When having a panel in a sizer, the does the panel abide by the sizer's location within window?
当 SimpleBook 是 Sizer 时,这看起来完美".但我正在尝试修复 这个stackoverflow 问题.
This looked "perfect" when the SimpleBook was a Sizer. But I'm trying to fix bugs in this stackoverflow question.
添加简单的代码.这里的任何错误等都只是复制/粘贴错误.代码编译得很好.在这里很难找到所有相关的部分来复制.
Adding simple code. Any mistakes etc in here is simply a copy/paste error. The code compiles perfectly fine. It was hard to find all the relevant pieces to copy here.
type ControlWindow struct {
wx.Frame
panel wx.Panel
gamePanel wx.Panel
editProfilePanel wx.Panel
newProfilePanel wx.Panel
mainBook wx.Simplebook
profileChoice ControlChoice
platformChoice ControlChoice
vSizerEditProfile wx.BoxSizer
vSizerNewProfile wx.BoxSizer
gridSizerEditProfile wx.FlexGridSizer
vSizerMainArea wx.BoxSizer
vSizerGameGrid wx.BoxSizer
statusbar wx.StatusBar
toolbar wx.ToolBar
menubar wx.MenuBar
hSizerSearch wx.BoxSizer
nextResults wx.Button
prevResults wx.Button
auiManager wx.AuiManager
}
func MainWindow() ControlWindow {
getPlatforms()
w := ControlWindow{}
w.Frame = wx.NewFrame(wx.NullWindow, -1, title", wx.DefaultPosition, wx.NewSizeT(800, 600))
mainSizer := wx.NewBoxSizer(wx.VERTICAL)
w.panel = wx.NewPanel(w, wx.ID_ANY)
w.mainBook = wx.NewSimplebook(w.panel, wx.ID_ANY)
blankPanel := wx.NewPanel(w, wx.ID_ANY)
w.gamePanel = wx.NewPanel(w.panel, wx.ID_ANY)
w.GameGrid = wx.NewGrid(w.gamePanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.EXPAND|wx.ALL)
w.vSizerGameGrid = wx.NewBoxSizer(wx.VERTICAL)
w.vSizerGameGrid.Add(w.GameGrid)
w.editProfilePanel = wx.NewPanel(w.panel, wx.ID_ANY)
w.newProfilePanel = wx.NewPanel(w.panel, wx.ID_ANY)
w.vSizerNewProfile = wx.NewBoxSizer(wx.VERTICAL)
vSizer := wx.NewBoxSizer(wx.VERTICAL)
hSizerLoad := wx.NewBoxSizer(wx.HORIZONTAL)
w.hSizerSearch = wx.NewBoxSizer(wx.HORIZONTAL)
w.vSizerMainArea = wx.NewBoxSizer(wx.HORIZONTAL)
w.vSizerEditProfile = wx.NewBoxSizer(wx.VERTICAL)
w.gridSizerEditProfile = wx.NewFlexGridSizer(3, 3, 7)
hSizerLoad.Add(w.platformChoice.Choice)
hSizerLoad.Add(w.profileChoice.Choice)
hSizerLoad.Add(profileEditButton)
hSizerLoad.Add(newProfileButton)
w.hSizerSearch.Add(searchInput)
w.hSizerSearch.Add(searchBy)
w.hSizerSearch.Add(searchButton)
w.hSizerSearch.Add(resetSearch)
w.hSizerSearch.Add(perPage)
w.hSizerSearch.Add(w.prevResults, 0, wx.ALIGN_BOTTOM)
w.hSizerSearch.Add(w.totalGamesLabel, 0, wx.ALIGN_BOTTOM)
w.hSizerSearch.Add(w.nextResults, 0, wx.ALIGN_BOTTOM)
//Just so I can see where the panel actually is.
blankPanel.SetBackgroundColour(wx.GetBLUE())
w.mainBook.AddPage(blankPanel, "Blank Panel", true)
w.mainBook.AddPage(w.gamePanel, "Game Panel Text", false)
w.mainBook.AddPage(w.editProfilePanel, "Edit Profile Panel Text", false)
w.mainBook.AddPage(w.newProfilePanel, "New Profile Panel Text", false)
w.vSizerMainArea.Add(w.mainBook, 1, wx.EXPAND|wx.ALL)
w.vSizerMainArea.Layout()
/*This is what I had before but it left artifacts when hiding and showing sizers.
**So that's why I'm trying to use simplebook...
* w.vSizerMainArea.Add(w.vSizerGameGrid, 1, wx.EXPAND|wx.ALL, 5)
* w.vSizerMainArea.Add(w.vSizerNewProfile, 1, wx.EXPAND|wx.ALL, 5)
* w.vSizerMainArea.Add(w.vSizerEditProfile, 1, wx.EXPAND|wx.ALL, 5)
* w.vSizerMainArea.Hide(w.vSizerGameGrid, false)
* w.vSizerMainArea.Hide(w.vSizerNewProfile, false)
* w.vSizerMainArea.Hide(w.vSizerEditProfile, false)
*/
hSizerRunButtons.Add(SaveProfileGameChanges, 0, wx.ALIGN_BOTTOM)
hSizerRunButtons.Add(RunButton, 0, wx.ALIGN_BOTTOM)
vSizer.Add(hSizerLoad, 0, wx.EXPAND|wx.ALL, 5)
vSizer.Add(w.hSizerSearch, 0, wx.EXPAND|wx.ALL, 5)
vSizer.Add(w.vSizerMainArea, 3, wx.EXPAND|wx.ALL, 5)
vSizer.Add(hSizerRunButtons, 0, wx.EXPAND|wx.ALL, 5)
w.panel.SetSizer(vSizer)
mainSizer.Add(w.panel, 1, wx.ALL|wx.EXPAND, 5)
w.SetSizer(mainSizer)
return w
}
推荐答案
您必须创建 wxSimplebook
页面,并将书籍控件本身作为父级而不是一些完全不同的窗口.
You must create wxSimplebook
pages with the book control itself as parent and not some completely different window.
这篇关于sizer 中的 WxWidgets 面板似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!