How can I get my editor to expand both horizontal and vertical?

I have a simple test application that uses a subclass of a StyledTextCtrl. I create my editor object in a subclass of wx.Frame.

def CreateEditor(self):
    myEditor = editor.SyntaxControl(self) # subclass of StyledTextCtrl
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(myEditor, 0, wx.EXPAND)
    self.SetSizer(sizer)
    self.SetSize((400, 300))
import wx
import wx.stc as stc

class SyntaxControl(stc.StyledTextCtrl):
    def __init__(self, parent, style=wx.SIMPLE_BORDER):
        stc.StyledTextCtrl.__init__(self, parent, style=style)
        self._styles = [None]*32
        self._free = 1
#!/usr/bin/env python
# Basic App Template
# Includes: App Object, Frame Object, MenuBar, StatusBar
# By: ShadyTyrant

import wx
import editor

class MyApp(wx.App):
    '''Can create db connections here'''
    # Propertys
    TITLE = "Basic Template 1"
    POS = (50, 60)
    SIZE = (450, 340)
    
    def OnInit(self):
        # Creates MyFrame object, and shows the window
        frame = MyFrame(self.TITLE, self.POS, self.SIZE)
        frame.Show()
        self.SetTopWindow(frame)
        return True
# End MyApp       
       
class MyFrame(wx.Frame):
    
    def __init__(self, title, pos, size):
        wx.Frame.__init__(self, None, -1, title, pos, size)
        self.CreateFileMenu()
        self.CreateMyStatusBar()
        self.CreateEditor()
        self.BindEvents()
        
    def CreateFileMenu(self):
        # Create Menu object
        fileMenu = wx.Menu()
        fileMenu.Append(1, "&About")
        fileMenu.AppendSeparator()
        fileMenu.Append(2, "E&xit")
        # Create Menu Bar object
        menuBar = wx.MenuBar()
        # Add Menu to MenuBar
        menuBar.Append(fileMenu, "&File")
        # Set MenuBar on frame
        self.SetMenuBar(menuBar)
    
    def CreateMyStatusBar(self):
        self.CreateStatusBar()
        self.SetStatusText("Hello Tyrant")
        
    def CreateEditor(self):
        myEditor = editor.SyntaxControl(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(myEditor, 0, wx.EXPAND)
        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        self.SetSize((400, 300))
        sizer.Layout()

    def BindEvents(self):
        self.Bind(wx.EVT_MENU, self.OnAbout, id=1)
        self.Bind(wx.EVT_MENU, self.OnExit, id=2)
    
    # Event handlers
    def OnAbout(self, event):
        # Create a pop up
        wx.MessageBox("This is a wxPython Hello world sample",
                      "About Test App", wx.OK | wx.ICON_INFORMATION, self)
    
    def OnExit(self, event):
        self.Close()
# End MyFrame
    
if __name__ == '__main__':
    app = MyApp(False)
    app.MainLoop()

Maybe if I clarify: I want to expand a wx.Object to fill both across, and down my frame. So my editor window will be resized both horizontal and vertical when I resize my main frame.

on line 53.... you have wx.EXPAND flat set but you have not given the permission to expand. Change to this,,,,,,,,,

sizer.Add(myEditor, 1, wx.EXPAND)

1 is the proportion/permission. so change the 0 to 1 anywhere you want to expand.
If you got more than one expand... Then you increase the proportion of the bigger control you want to .

;)

commented: Found solution +2

Doh! Thanks so much for the help, fixed.

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.