How do i set the size of my listbox to be the same as my split window?
I tried to use sizer but because this is my first time using it and it did not work.please help. THANKS

class bucky(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Frame aka window')
        #panel=wx.Panel(self)
        self.sp = wx.SplitterWindow(self)
        self.p1 = wx.Panel(self.sp, style=wx.SUNKEN_BORDER)
        self.p2 = stc.StyledTextCtrl(self.sp, style=wx.TE_MULTILINE)
        self.p1.Hide()
        self.sp.Initialize(self.p2)
        self.p1.SetBackgroundColour("purple")
        self.sp.SplitHorizontally(self.p2, self.p1, 350)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.p1, wx.EXPAND)
        self.sizer.Fit(self)
        mylist=['sex', 'toy', 'yx']
        cunt=wx.ListBox(self.p1, -1, wx.DefaultPosition, self.sizer,mylist,wx.LB_SINGLE)
        cunt.SetSelection(1)

if __name__=='__main__':
    app=wx.PySimpleApp()
    frame=bucky(parent=None,id=-1)
    frame.Show()
    app.MainLoop()

My advice, use some simple code to explore the basics of what you want to accomplish ...

# exploring wxPython widget's
# wx.SplitterWindow(parent, id, pos, size, style)
# wx.ListBox(parent, id, pos, size, choices, style)
# wx.TextCtrl(parent, id, value, pos, size, style)

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize, mychoices, mytext):
        wx.Frame.__init__(self, parent, -1, mytitle, size=mysize)

        split1 = wx.SplitterWindow(self, -1,
            style=wx.SP_LIVE_UPDATE)
        self.listbox = wx.ListBox(split1, -1, choices=mychoices)
        self.listbox.SetBackgroundColour('green')
        self.text = wx.TextCtrl(split1, -1, value=mytext,
            style=wx.TE_MULTILINE)
        # set splitter window's direction and content
        # top or left content first, then give initial sash position
        split1.SplitVertically(self.listbox, self.text, 150)
     

# a test list for the listbox
mychoices = [
'Mark',
'Molly',
'Frederik',
'Pauline'
]

# a test string for the multiline text control
mytext = '\n'.join(mychoices*10)

app = wx.App(0)

mytitle = 'drag the splitter sash'
mysize = (400, 300)
MyFrame(None, mytitle, mysize, mychoices, mytext).Show()

app.MainLoop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.