StyledTextCtrl Questions

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

Hello,

Instead of SetBackgroundColour use StyleSetSpec and the related STC_STYLE_* flags for configuring the styles.

self.StyleSetSpec(0, “back:#000000,fore:#FFFFFF”)

self.StyleSetSpec(stc.STC_STYLE_DEFAULT, “back:#000000,fore:#FFFFFF”)

Cody

···

On Aug 16, 2008, at 7:46 PM, Scott Hall wrote:

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


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Scott Hall <smhall316 <at> gmail.com> writes:

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 think the test/demo application PyStylesCreator is not to bad to show the
various STC capabilities.

http://spinecho.ze.cx > PyStyleCreator

Jean-Michel Fauth, Switzerland

jmf wrote:

Scott Hall <smhall316 <at> gmail.com> writes:

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 think the test/demo application PyStylesCreator is not to bad to show the
various STC capabilities.

http://spinecho.ze.cx > PyStyleCreator
  

hi Jean-Michel,
probably you mean this:
http://spinecho.ze.cx/PyStylesCreator

btw, why not put these links on your front page,
more people might be interested !

cheers,
Stef

···

Jean-Michel Fauth, Switzerland

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

That link don’t work either. It does offer up a link that does work however:

http://spinecho.ifrance.com/pystylescreator.html

But if you click it, you’ll notice that the URL in the browser doesn’t change from the original once.

Cheers,

–Tim

···

On Mon, Aug 18, 2008 at 11:13 AM, Stef Mientki s.mientki@ru.nl wrote:

jmf wrote:

Scott Hall <smhall316 gmail.com> writes:

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 think the test/demo application PyStylesCreator is not to bad to show the

various STC capabilities.

http://spinecho.ze.cx > PyStyleCreator

hi Jean-Michel,

probably you mean this:

http://spinecho.ze.cx/PyStylesCreator