a***@agip.it
2004-12-14 08:35:44 UTC
Hello NG,
I have already posted this message on the wxPython NG, and after a
discussion they suggested me to post my message on the Scintilla NG. I am
using wxPython and a styled text control, with a LUA style keyword set (it
is very similar to what I need).
For what I understood till now, it seems to me that wxStyledTextCtrl (and
so Scintilla) does NOT recognize keywords that starts with characters like
$, %, @, # and so on. I was going crazy. If someone of you uses
Python+wxPython, I leave at the end 2 python scripts that are exactly the
same EXCEPT for the keyword set: the first one contains keywords WITHOUT
the character "$", the second one contains keywords that start with the
character "$". Just press the button at right to see if the keywords are
highlighted or not (they should be RED BOLD when you press the button).
Notice that in the second application there is no highlight in the
keyword... it is a big problem, because I need keywords that start with
$...
Any help is HIGHLY HIGHLY appreciated. Sorry for the long post.
Andrea.
# CODE APP 1 BEGIN #
import wx
import wx.stc as stc
#
============================================================================
# PLATFORM INDEPENDENCY DECLARATIONS
#
============================================================================
if wx.Platform == '__WXMSW__':
faces = { 'times': 'Times New Roman',
'mono' : 'Courier New',
'helv' : 'Verdana',
'other': 'Comic Sans MS',
'size' : 9,
'size2': 8,
}
else:
faces = { 'times': 'Times',
'mono' : 'Courier',
'helv' : 'Helvetica',
'other': 'new century schoolbook',
'size' : 12,
'size2': 10,
}
class ECLIPSE_STC(stc.StyledTextCtrl):
def __init__(self, parent, ID):
stc.StyledTextCtrl.__init__(self, parent, ID,
style = wx.NO_FULL_REPAINT_ON_RESIZE)
keywordsmie = ["THESE","KEYWORDS","WORK","WELL"]
self.SetLexer(stc.STC_LEX_LUA)
self.SetKeyWords(0, " ".join(keywordsmie))
self.StyleClearAll()
# Global default styles for all languages
self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
"face:%(helv)s,size:%(size)d" %
faces)
# ECLIPSE styles
# Default
self.StyleSetSpec(stc.STC_LUA_DEFAULT,
"fore:
#000000,face:%(times)s,size:%(size)d" % faces)
# Keyword
self.StyleSetSpec(stc.STC_LUA_WORD,
"fore:
#0000FF,bold,underline,size:%(size)d" % faces)
class MyFrame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title, size=(600, 350))
panel = wx.Panel(self,-1)
ed = ECLIPSE_STC(panel, -1)
ed.SetPosition(wx.Point(10,10))
ed.SetSize(wx.Size(400,300))
mystr = "Press This To\nSee The Second\nSet Of Keywords"
b = wx.Button(panel, -1, mystr, pos=(450,100), size=(100,100))
self.Bind(wx.EVT_BUTTON, self.PressedButton, b)
mystr = "THESE\nKEYWORDS\nWORK\nWELL\n\n"
ed.SetText(mystr)
ed.Colourise(0, -1)
self.ed = ed
def PressedButton(self, event):
keywords2 = ["WHY","THEY","DONOT","UPDATE"]
self.ed.SetKeyWords(1, " ".join(keywords2))
# Keyword 2
self.ed.StyleSetSpec(stc.STC_LUA_WORD2,
"fore:#FF0000,bold,size:%(size)d" %
faces)
mystr
= "THESE\nKEYWORDS\nWORK\nWELL\n\n\nWHY\nTHEY\nDONOT\nUPDATE\n"
self.ed.SetText(mystr)
self.ed.Colourise(0, -1)
app = wx.PySimpleApp()
frame = MyFrame(None, -1, "wxSTC Test")
frame.Show()
app.MainLoop()
# CODE APP 1 END #
#############################################################
# CODE APP 2 BEGIN #
import wx
import wx.stc as stc
#
============================================================================
# PLATFORM INDEPENDENCY DECLARATIONS
#
============================================================================
if wx.Platform == '__WXMSW__':
faces = { 'times': 'Times New Roman',
'mono' : 'Courier New',
'helv' : 'Verdana',
'other': 'Comic Sans MS',
'size' : 9,
'size2': 8,
}
else:
faces = { 'times': 'Times',
'mono' : 'Courier',
'helv' : 'Helvetica',
'other': 'new century schoolbook',
'size' : 12,
'size2': 10,
}
class ECLIPSE_STC(stc.StyledTextCtrl):
def __init__(self, parent, ID):
stc.StyledTextCtrl.__init__(self, parent, ID,
style = wx.NO_FULL_REPAINT_ON_RESIZE)
keywordsmie = ["THESE","KEYWORDS","WORK","WELL"]
self.SetLexer(stc.STC_LEX_LUA)
self.SetKeyWords(0, " ".join(keywordsmie))
self.StyleClearAll()
# Global default styles for all languages
self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
"face:%(helv)s,size:%(size)d" %
faces)
# ECLIPSE styles
# Default
self.StyleSetSpec(stc.STC_LUA_DEFAULT,
"fore:
#000000,face:%(times)s,size:%(size)d" % faces)
# Keyword
self.StyleSetSpec(stc.STC_LUA_WORD,
"fore:
#0000FF,bold,underline,size:%(size)d" % faces)
class MyFrame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title, size=(600, 350))
panel = wx.Panel(self,-1)
ed = ECLIPSE_STC(panel, -1)
ed.SetPosition(wx.Point(10,10))
ed.SetSize(wx.Size(400,300))
mystr = "Press This To\nSee The Second\nSet Of Keywords"
b = wx.Button(panel, -1, mystr, pos=(450,100), size=(100,100))
self.Bind(wx.EVT_BUTTON, self.PressedButton, b)
mystr = "THESE\nKEYWORDS\nWORK\nWELL\n\n"
ed.SetText(mystr)
ed.Colourise(0, -1)
self.ed = ed
def PressedButton(self, event):
keywords2 = ["$WHY","$THEY","$DONOT","$UPDATE"]
self.ed.SetKeyWords(1, " ".join(keywords2))
# Keyword 2
self.ed.StyleSetSpec(stc.STC_LUA_WORD2,
"fore:#FF0000,bold,size:%(size)d" %
faces)
mystr
= "THESE\nKEYWORDS\nWORK\nWELL\n\n\n$WHY\n$THEY\n$DONOT\n$UPDATE\n"
self.ed.SetText(mystr)
self.ed.Colourise(0, -1)
app = wx.PySimpleApp()
frame = MyFrame(None, -1, "wxSTC Test")
frame.Show()
app.MainLoop()
_______________________________________________
Andrea Gavana
Reservoir Engineer
MOGI ? Reservoir Characterization and Modeling Dept.
ENI S.p.A. ? Exploration & Production Division
Via Emilia, 1 ? 20097 San Donato Milanese (MI) ? Italy
Phone: +39 02 520 62972
Fax: +39 02 520 61824
E-mail: ***@agip.it
Updated Internet Site: http://xoomer.virgilio.it/infinity77/
____________________________________________________
Eni S.p.A.
Sede legale in Roma,
Piazzale Enrico Mattei 1, 00144 Roma
Tel. centralino: +39 06598.21
www.eni.it
Capitale sociale 4.002.934.326 i.v.
Registro Imprese di Roma,
Codice Fiscale 00484960588
Part. IVA 00905811006
R.E.A. Roma n. 756453
-------------------------------------------------------------------------------------------------------------------------------------------
Message for the recipient only, if received in error, please notify the
sender and read http://www.eni.it/disclaimer/
I have already posted this message on the wxPython NG, and after a
discussion they suggested me to post my message on the Scintilla NG. I am
using wxPython and a styled text control, with a LUA style keyword set (it
is very similar to what I need).
For what I understood till now, it seems to me that wxStyledTextCtrl (and
so Scintilla) does NOT recognize keywords that starts with characters like
$, %, @, # and so on. I was going crazy. If someone of you uses
Python+wxPython, I leave at the end 2 python scripts that are exactly the
same EXCEPT for the keyword set: the first one contains keywords WITHOUT
the character "$", the second one contains keywords that start with the
character "$". Just press the button at right to see if the keywords are
highlighted or not (they should be RED BOLD when you press the button).
Notice that in the second application there is no highlight in the
keyword... it is a big problem, because I need keywords that start with
$...
Any help is HIGHLY HIGHLY appreciated. Sorry for the long post.
Andrea.
# CODE APP 1 BEGIN #
import wx
import wx.stc as stc
#
============================================================================
# PLATFORM INDEPENDENCY DECLARATIONS
#
============================================================================
if wx.Platform == '__WXMSW__':
faces = { 'times': 'Times New Roman',
'mono' : 'Courier New',
'helv' : 'Verdana',
'other': 'Comic Sans MS',
'size' : 9,
'size2': 8,
}
else:
faces = { 'times': 'Times',
'mono' : 'Courier',
'helv' : 'Helvetica',
'other': 'new century schoolbook',
'size' : 12,
'size2': 10,
}
class ECLIPSE_STC(stc.StyledTextCtrl):
def __init__(self, parent, ID):
stc.StyledTextCtrl.__init__(self, parent, ID,
style = wx.NO_FULL_REPAINT_ON_RESIZE)
keywordsmie = ["THESE","KEYWORDS","WORK","WELL"]
self.SetLexer(stc.STC_LEX_LUA)
self.SetKeyWords(0, " ".join(keywordsmie))
self.StyleClearAll()
# Global default styles for all languages
self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
"face:%(helv)s,size:%(size)d" %
faces)
# ECLIPSE styles
# Default
self.StyleSetSpec(stc.STC_LUA_DEFAULT,
"fore:
#000000,face:%(times)s,size:%(size)d" % faces)
# Keyword
self.StyleSetSpec(stc.STC_LUA_WORD,
"fore:
#0000FF,bold,underline,size:%(size)d" % faces)
class MyFrame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title, size=(600, 350))
panel = wx.Panel(self,-1)
ed = ECLIPSE_STC(panel, -1)
ed.SetPosition(wx.Point(10,10))
ed.SetSize(wx.Size(400,300))
mystr = "Press This To\nSee The Second\nSet Of Keywords"
b = wx.Button(panel, -1, mystr, pos=(450,100), size=(100,100))
self.Bind(wx.EVT_BUTTON, self.PressedButton, b)
mystr = "THESE\nKEYWORDS\nWORK\nWELL\n\n"
ed.SetText(mystr)
ed.Colourise(0, -1)
self.ed = ed
def PressedButton(self, event):
keywords2 = ["WHY","THEY","DONOT","UPDATE"]
self.ed.SetKeyWords(1, " ".join(keywords2))
# Keyword 2
self.ed.StyleSetSpec(stc.STC_LUA_WORD2,
"fore:#FF0000,bold,size:%(size)d" %
faces)
mystr
= "THESE\nKEYWORDS\nWORK\nWELL\n\n\nWHY\nTHEY\nDONOT\nUPDATE\n"
self.ed.SetText(mystr)
self.ed.Colourise(0, -1)
app = wx.PySimpleApp()
frame = MyFrame(None, -1, "wxSTC Test")
frame.Show()
app.MainLoop()
# CODE APP 1 END #
#############################################################
# CODE APP 2 BEGIN #
import wx
import wx.stc as stc
#
============================================================================
# PLATFORM INDEPENDENCY DECLARATIONS
#
============================================================================
if wx.Platform == '__WXMSW__':
faces = { 'times': 'Times New Roman',
'mono' : 'Courier New',
'helv' : 'Verdana',
'other': 'Comic Sans MS',
'size' : 9,
'size2': 8,
}
else:
faces = { 'times': 'Times',
'mono' : 'Courier',
'helv' : 'Helvetica',
'other': 'new century schoolbook',
'size' : 12,
'size2': 10,
}
class ECLIPSE_STC(stc.StyledTextCtrl):
def __init__(self, parent, ID):
stc.StyledTextCtrl.__init__(self, parent, ID,
style = wx.NO_FULL_REPAINT_ON_RESIZE)
keywordsmie = ["THESE","KEYWORDS","WORK","WELL"]
self.SetLexer(stc.STC_LEX_LUA)
self.SetKeyWords(0, " ".join(keywordsmie))
self.StyleClearAll()
# Global default styles for all languages
self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
"face:%(helv)s,size:%(size)d" %
faces)
# ECLIPSE styles
# Default
self.StyleSetSpec(stc.STC_LUA_DEFAULT,
"fore:
#000000,face:%(times)s,size:%(size)d" % faces)
# Keyword
self.StyleSetSpec(stc.STC_LUA_WORD,
"fore:
#0000FF,bold,underline,size:%(size)d" % faces)
class MyFrame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title, size=(600, 350))
panel = wx.Panel(self,-1)
ed = ECLIPSE_STC(panel, -1)
ed.SetPosition(wx.Point(10,10))
ed.SetSize(wx.Size(400,300))
mystr = "Press This To\nSee The Second\nSet Of Keywords"
b = wx.Button(panel, -1, mystr, pos=(450,100), size=(100,100))
self.Bind(wx.EVT_BUTTON, self.PressedButton, b)
mystr = "THESE\nKEYWORDS\nWORK\nWELL\n\n"
ed.SetText(mystr)
ed.Colourise(0, -1)
self.ed = ed
def PressedButton(self, event):
keywords2 = ["$WHY","$THEY","$DONOT","$UPDATE"]
self.ed.SetKeyWords(1, " ".join(keywords2))
# Keyword 2
self.ed.StyleSetSpec(stc.STC_LUA_WORD2,
"fore:#FF0000,bold,size:%(size)d" %
faces)
mystr
= "THESE\nKEYWORDS\nWORK\nWELL\n\n\n$WHY\n$THEY\n$DONOT\n$UPDATE\n"
self.ed.SetText(mystr)
self.ed.Colourise(0, -1)
app = wx.PySimpleApp()
frame = MyFrame(None, -1, "wxSTC Test")
frame.Show()
app.MainLoop()
_______________________________________________
Andrea Gavana
Reservoir Engineer
MOGI ? Reservoir Characterization and Modeling Dept.
ENI S.p.A. ? Exploration & Production Division
Via Emilia, 1 ? 20097 San Donato Milanese (MI) ? Italy
Phone: +39 02 520 62972
Fax: +39 02 520 61824
E-mail: ***@agip.it
Updated Internet Site: http://xoomer.virgilio.it/infinity77/
____________________________________________________
Eni S.p.A.
Sede legale in Roma,
Piazzale Enrico Mattei 1, 00144 Roma
Tel. centralino: +39 06598.21
www.eni.it
Capitale sociale 4.002.934.326 i.v.
Registro Imprese di Roma,
Codice Fiscale 00484960588
Part. IVA 00905811006
R.E.A. Roma n. 756453
-------------------------------------------------------------------------------------------------------------------------------------------
Message for the recipient only, if received in error, please notify the
sender and read http://www.eni.it/disclaimer/