Hi every one! :)

Based on the example of StyledTextCtrl of the wxPython demo i managed to write a small application intended to Php code writing.

Does anyone know how to set styles for Php codes?

I found it's necessary to use SetLexer(stc.STC_LEX_HTML) because STC_LEX_PHP is deprecated.
But i have no idea how to set all StyleSetSpec for php (and also html, because this one can even be used into php code).

If anyone has any experience and/or some examples to share, i'd be very grateful!

Thank you very much in advance.

As we are in the php section i wonder if there is any reader of this forum who can answer me? Let me explain:

i tell that because a moderator has moved my thread here, in php section, whereas i posted it in python section, and as you can see my question is about management of styles definitions in a styledtextctrl with wxpython... so i think it's inappropriate
to have moved it here.
Indeed, php users who can answer may be rare, and python users who read php threads may be rare too.

The moderator who has moved my thread has just told me he did so because users flagged it for moving over to PHP.

This is not fair from the part of this users... :/

Post a new question in the Python forum if you want, but

Does anyone know how to set styles for Php codes

how to set all StyleSetSpec for php

implies PHP. Do you meant you are writing something like an IDE and want to know how to highlight certain PHP keywords?

Hi zentraders, thanks for your answers.

Do you meant you are writing something like an IDE and want to know how to highlight certain PHP keywords?

Yes it's what i mean. I think i was clear... :)

The keywords i used are:

StyledTextCtrl
an application intended to Php code writing.
SetLexer (stc.STC_LEX_HTML)
StyleSetSpec for php
set styles for Php codes

All of this concerns the code highlighting with wxPython. And my ask is how to do that for php code highlighting.


Following various informations i found, i started like that:

self.wysiwyg.SetLexer(stc.STC_LEX_HTML)

self.StyleSetSpec(stc.STC_HPHP_VARIABLE, "fore:#8B6914,size:%(size)d" % faces)
self.StyleSetSpec(stc.STC_HPHP_OPERATOR, "fore:#A020F0,size:%(size)d" % faces)

I need more informations about the way to complete my code and my StyleSetSpec definitions and make it works well.

Thanks again for you interest!

Sorry, I don't have must experience with that. I only use SetBackgroundColour, etc.

Hi woooee,

i found the solution:

1. set style for STC_HPHP_WORD
2. set declaration for this style with SetKeywords

self.mytextctrl.StyleSetSpec(stc.STC_HPHP_WORD, "fore:#0000FF")
self.mytextctrl.SetKeyWords(4, "class function for if elseif else foreach while echo")

It works just fine!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.