WxDialog框有更多的sizer,其中两个box sizer彼此相邻。 这些sizer有更多的控件,如ListCtrl,StatisTextCtlr,TreeCtrl等。
任何一个sizer的长度内容太长,对话框水平增加,因此两个sizer都增加了。
那么,当第二个sizer的内容长度增加时,我们可以给第一个sizer提供水平滚动条(动态)吗?那么我们可以防止对话框水平增加大小。
def __init__(self, parent, Name, Platform, someList=None):
wx.Dialog.__init__(self, parent, wx.ID_ANY, 'select name', size=(-1,-1), pos=(-1,-1))
# Generate UI
self.createLayout()
self.createSizers()
self.Fit()
self.Layout()
self.CenterOnParent()
def createSizers(self):
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
..............
SelectionSizer = wx.StaticBoxSizer(self.staticBoxSelection, wx.VERTICAL)
self.horzDetailsSizer = wx.BoxSizer(wx.HORIZONTAL)
self.userDetailsSizer = wx.BoxSizer(wx.VERTICAL)
self.userDetailsSizer.Add(self.DetailsName, 0, wx.ALIGN_LEFT)
self.userListingSizer = wx.BoxSizer(wx.VERTICAL)
self.userListingSizer.Add(self.LocationSizer, 0, wx.EXPAND)
self.userListingSizer.AddSpacer(5)
self.userListingSizer.Add(self.ListBox, 1, wx.EXPAND)
# Horizontal Splitter
self.horzDetailsSizer.Add(self.userListingSizer, 3, wx.EXPAND)
self.horzDetailsSizer.AddSpacer(5)
self.horzDetailsSizer.Add(self.userDetailsSizer, 2, wx.EXPAND)
# Add selection subsizers to main
SelectionSizer.Add(self.horzDetailsSizer, 1, wx.EXPAND | wx.ALL, 5)
............
self.mainSizer.AddSpacer(5)
self.mainSizer.Add(self.headerText, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5)
self.mainSizer.AddSpacer(8)
self.mainSizer.Add(mainHeader, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.LEFT | wx.RIGHT, 35)
self.mainSizer.AddSpacer(5)
self.mainSizer.Add(SelectionSizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
self.mainSizer.AddSpacer(5)
.............
.......
## Initialize mainSize
self.SetSizer(self.mainSizer)
在Advance中感谢。任何答案都将不胜感激