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()