Hi,
Replace:
self.main_panel_sizer.Add(search_sizer, 1, wx.ALL, 5)
with:
self.main_panel_sizer.Add(search_sizer, 0, wx.ALL, 5)
So that the notebook expands vertically on panel:
import wx
import wx.lib.agw.flatnotebook as fnb
class TheFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "The Frame", size=(800, 600),
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX
)
self.create_menu_bar()
self.create_panel()
self.create_search_bar()
self.create_notebook()
self.Layout()
def create_panel(self):
self.main_panel = wx.Panel(self, -1)
self.main_panel_sizer = wx.BoxSizer(wx.VERTICAL)
self.main_panel.SetSizer(self.main_panel_sizer)
def create_search_bar(self):
search_sizer = wx.BoxSizer(wx.HORIZONTAL)
search_font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, faceName="Calibri")
search_label = wx.StaticText(self.main_panel, -1, "Search By: ")
search_label.SetFont(search_font)
sampleList = ['one', 'two', 'three']
self.ch = wx.Choice(self.main_panel, -1, (100, 50), choices=sampleList)
self.text_ctrl = wx.TextCtrl(self.main_panel, -1)
search_sizer.Add(search_label, 0, wx.ALL, 5)
search_sizer.Add(self.ch, 0, wx.ALL, 5)
search_sizer.Add(self.text_ctrl, 0, wx.ALL, 5)
self.main_panel_sizer.Add(search_sizer, 0, wx.ALL, 5)
def create_notebook(self):
self.the_notebook = fnb.FlatNotebook(self.main_panel, -1, agwStyle=fnb.FNB_VC71 | fnb.FNB_NO_X_BUTTON)
self.notebook_tab_1 = wx.Panel(self.main_panel, -1)
self.notebook_tab_2 = wx.Panel(self.main_panel, -1)
self.the_notebook.AddPage(self.notebook_tab_1, "Tab 1")
self.the_notebook.AddPage(self.notebook_tab_2, "Tab 2")
self.list_ctrl_1 = wx.ListCtrl(self.notebook_tab_1, -1, style=wx.LC_REPORT)
self.list_ctrl_2 = wx.ListCtrl(self.notebook_tab_2, -1, style=wx.LC_REPORT)
tab_1_sizer = wx.BoxSizer(wx.VERTICAL)
tab_2_sizer = wx.BoxSizer(wx.VERTICAL)
tab_1_sizer.Add(self.list_ctrl_1, 1, wx.EXPAND)
tab_2_sizer.Add(self.list_ctrl_2, 1, wx.EXPAND)
self.list_ctrl_1.InsertColumn(0, "Col 1")
self.list_ctrl_1.InsertColumn(1, "Col 2")
self.list_ctrl_1.InsertColumn(2, "Col 3")
self.list_ctrl_2.InsertColumn(0, "Col 1")
self.list_ctrl_2.InsertColumn(1, "Col 2")
self.list_ctrl_2.InsertColumn(2, "Col 3")
for ix, list_ctrl in enumerate([self.list_ctrl_1, self.list_ctrl_2]):
for i in range(5):
index = list_ctrl.InsertItem(list_ctrl.GetItemCount(), f"Test {str(i*1*(ix+1))}")
list_ctrl.SetItem(index, 1, f"Test {str(i*2*(ix+1))}")
list_ctrl.SetItem(index, 2, f"Test {str(i*3*(ix+1))}")
self.notebook_tab_1.SetSizer(tab_1_sizer)
self.notebook_tab_2.SetSizer(tab_2_sizer)
self.notebook_tab_1.Layout()
self.notebook_tab_2.Layout()
self.main_panel_sizer.Add(self.the_notebook, 1, wx.EXPAND|wx.ALL, 10)
def create_menu_bar(self):
self.menuBar = wx.MenuBar()
self.menu_file = wx.Menu()
self.menu_help = wx.Menu()
self.menuBar.Append(self.menu_file, "File")
self.menuBar.Append(self.menu_help, "Help")
self.SetMenuBar(self.menuBar)
if __name__ == "__main__":
app = wx.App(False)
frame = TheFrame()
frame.Show()
app.MainLoop()