I am trying to write a simple editor with syntax highlighting and I also want to allow the user to customize the editor such as look and feel. I was pointed to StyledTextCtrl and I read through the documentation on yellowbrain.com. This seems to be the package that I want to use.
However I am trying to do simple things that I can’t seem to find a simple answer to. For instance I want the user to be able to configure the background color of the editor, (e.g. a black background with white text) I cannot seem to figure out how to get that to work.
import wx
import wx.stc as stc
class InitializeBuild(wx.App):
def __init__(self, redirect=False, filename=None, useBestVisual=False, clearSigInt=True):
wx.App.__init__(self, redirect, filename, useBestVisual, clearSigInt)
def OnInit(self):
return True
class Frame(wx.Frame):
def __init__(self, parent=None, id=-1, title="My Programming Editor", pos=wx.DefaultPosition, size=(500,500)):
wx.Frame.__init__(self, parent, id, title, pos, size)
class Editor(stc.StyledTextCtrl):
# The actual initializer of the widget
def __init__(self, parent, id):
stc.StyledTextCtrl.__init__(self,parent, id,style=1)
self.SetBackgroundColour(wx.Colour(0,0,0))
Main
app = InitializeBuild()
main = Frame()
ed = Editor(main, -1)
main.Show()
app.MainLoop()