hello to all,
how to colorize css and javascript in html ?
I can’t do it
example =
import wx
import wx.stc as stc
class htmlSTC(stc.StyledTextCtrl):
def __init__(self, parent):
stc.StyledTextCtrl.__init__(self, parent)
self.SetLexer(stc.STC_LEX_HTML)
self.StyleSetSpec(stc.STC_P_STRING,"back:#000000,fore:#888800")
self.StyleSetSpec(stc.STC_HJA_KEYWORD,"back:#000000,fore:#ff0000")
self.StyleSetSpec(stc.STC_CSS_CLASS,"back:#ffff00,fore:#ff00ff")
class frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None,title='HTML View',size=(800,400))
self.view=htmlSTC(self)
txt="""<!DOCTYPE html>
<html lang='fr'>
<head>
<meta charset='utf-8'>
<title>titre de la page</title>
<style>
body {
background-color:#0a000a;
}
</style>
<script>
function pageChargee() {
alert('page chargée');
}
if ( window.attachEvent )
window.attachEvent('onload',pageChargee);
else window.addEventListener('load',pageChargee,false);
</script>
</head>
<body>
<div>exemple</div>
</body>
</html>"""
self.view.SetText(txt)
sizer=wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.view,1,wx.EXPAND)
self.SetSizer(sizer)
self.Show()
app=wx.App(False)
frm=frame()
app.MainLoop()
it works in html not in css and javascript included
thank you in advance
( sorry, French translation with deepl.com !! )