[wxPython-users] wxStyledTextCtrl_2 woes

David Brown david at atomicbinary.com
Tue Jul 4 20:16:45 PDT 2006


Robin Dunn wrote:
> David Brown wrote:
>>
>>> I'm working on an editor for the Flat Assembler programming language 
>>> so I need to use the wxStyledTextCtrl_2 for syntax highlighting. 
>>> I've been trying for hours to use the code from the demo, but I keep 
>>> getting errors no matter what I do.
>>>
>>> Can someone please provide a simple example of the most minimal way 
>>> to show a wxStyledTextCtrl_2 that is set to fill the empty space of 
>>> my frame and redraw itself when the window is resized (or whatever 
>>> it has to do to update itself)? I would really appreciate it.
>>>
>>> Thanks,
>>> David
>>
>> Never mind about the above. I finally got it working. My next problem 
>> is that nothing is getting highlighted. :( Here's my code:
>>
>> import wx
>> from wx import stc
>> import keyword
>>
>> class fsCodeEditor(stc.StyledTextCtrl):
>>    def __init__(self, parent, ID, pos=wx.DefaultPosition, 
>> size=wx.DefaultSize, style=0):
>>        stc.StyledTextCtrl.__init__(self, parent, ID, pos, size, style)
>>        self.SetLexer(stc.STC_LEX_ASM)
>>        self.SetKeyWords(0, " ".join(keyword.kwlist))
>
> Are you sure that you want to use the Python keywords as the ASM 
> keywords?
>
>>        self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:Courier 
>> New,size:10")
>>        self.StyleClearAll()
>
> You are not setting any styles, and so all styles used by the lexer 
> are going to be drawn exactly the same way.  So it's not a matter of 
> things not getting highlighted, but that the highlighted things are 
> indistinguishable from everything else.
>
I removed the keyword stuff. I had no idea what that was for, so I just 
put it there just in case it was required. How do I find out what style 
types are used in the ASM lexer? Are they the same as the Python lexer? 
I'm pretty new to Python, so please forgive my dumb questions. :P

Thanks,
David




More information about the wxpython-users mailing list