Hi all,
I've come to the stage in my MUD client's development that I've been putting off for a while, where I need to handle colour.
As it stands, I've got the colour codes removed from the output while the trigger engine does it's thing, then the whole line is passed onto the GUI where's it's printed. I'm thinking I should override wx.EditCtrl to implement something which uses write to modify the colours.
Is this over kill? Is there already such a control out there? Also, I've been looking through the docs, and I'm not entirely sure on how to change the colour of the text (using wx.TE_RICH as my style). Do I need to create wx.Font objects each time? Or how does it work?
Hi all,
I've come to the stage in my MUD client's development that I've been
putting off for a while, where I need to handle colour.
As it stands, I've got the colour codes removed from the output while
the trigger engine does it's thing, then the whole line is passed onto
the GUI where's it's printed. I'm thinking I should override wx.EditCtrl
to implement something which uses write to modify the colours.
Is this over kill? Is there already such a control out there? Also, I've
been looking through the docs, and I'm not entirely sure on how to
change the colour of the text (using wx.TE_RICH as my style). Do I need
to create wx.Font objects each time? Or how does it work?
For wx.TextCtrl you can use wx.TextAttr and SetStyle(), see the sample in the demo.
Do you need to have all the text be editable or do you just need to display it? If the latter then the above does sound like overkill and you may be better off if you create a custom class that draws the text in its paint event. It will be more work up front but in the end it will likely be more flexible and more maintainable.
Hi all,
I've come to the stage in my MUD client's development that I've been
putting off for a while, where I need to handle colour.
As it stands, I've got the colour codes removed from the output while
the trigger engine does it's thing, then the whole line is passed onto
the GUI where's it's printed. I'm thinking I should override wx.EditCtrl
to implement something which uses write to modify the colours.
Is this over kill? Is there already such a control out there? Also, I've
been looking through the docs, and I'm not entirely sure on how to
change the colour of the text (using wx.TE_RICH as my style). Do I need
to create wx.Font objects each time? Or how does it work?
For wx.TextCtrl you can use wx.TextAttr and SetStyle(), see the sample in the demo.
Do you need to have all the text be editable or do you just need to display it? If the latter then the above does sound like overkill and you may be better off if you create a custom class that draws the text in its paint event. It will be more work up front but in the end it will likely be more flexible and more maintainable.
In the interests of accessibility I think I want to keep it in an edit field yes, so I'll work with the wx.TextAttr thing. Looking into that, is there any way to see if a colour searched for with wx.TheColourDatabase.Find is valid or not? If I enter:
wx.TheColourDatabase.Find('asdf'), it returns a colour with RGB at -1. Do I just check for -1 in the RGB values? Or is there a traceback or return value I can rely upon? I was hoping for a function which returned a colour or None (or a traceback).
Hi all,
I've come to the stage in my MUD client's development that I've been
putting off for a while, where I need to handle colour.
As it stands, I've got the colour codes removed from the output while
the trigger engine does it's thing, then the whole line is passed onto
the GUI where's it's printed. I'm thinking I should override wx.EditCtrl
to implement something which uses write to modify the colours.
Is this over kill? Is there already such a control out there? Also, I've
been looking through the docs, and I'm not entirely sure on how to
change the colour of the text (using wx.TE_RICH as my style). Do I need
to create wx.Font objects each time? Or how does it work?
For wx.TextCtrl you can use wx.TextAttr and SetStyle(), see the sample
in the demo.
Do you need to have all the text be editable or do you just need to
display it? If the latter then the above does sound like overkill and
you may be better off if you create a custom class that draws the text
in its paint event. It will be more work up front but in the end it
will likely be more flexible and more maintainable.
In the interests of accessibility I think I want to keep it in an edit
field yes, so I'll work with the wx.TextAttr thing. Looking into that,
is there any way to see if a colour searched for with
wx.TheColourDatabase.Find is valid or not? If I enter:
wx.TheColourDatabase.Find('asdf'), it returns a colour with RGB at -1.
Do I just check for -1 in the RGB values? Or is there a traceback or
return value I can rely upon? I was hoping for a function which returned
a colour or None (or a traceback).
The colour with -1 components is "invalid" and is how functions like this indicate an error when returning C++ objects. You can call the colour's Ok() method to see if it is a valid colour or not.
Hi all,
I've come to the stage in my MUD client's development that I've been
putting off for a while, where I need to handle colour.
As it stands, I've got the colour codes removed from the output while
the trigger engine does it's thing, then the whole line is passed onto
the GUI where's it's printed. I'm thinking I should override wx.EditCtrl
to implement something which uses write to modify the colours.
Is this over kill? Is there already such a control out there? Also, I've
been looking through the docs, and I'm not entirely sure on how to
change the colour of the text (using wx.TE_RICH as my style). Do I need
to create wx.Font objects each time? Or how does it work?
For wx.TextCtrl you can use wx.TextAttr and SetStyle(), see the sample
in the demo.
Do you need to have all the text be editable or do you just need to
display it? If the latter then the above does sound like overkill and
you may be better off if you create a custom class that draws the text
in its paint event. It will be more work up front but in the end it
will likely be more flexible and more maintainable.
In the interests of accessibility I think I want to keep it in an edit
field yes, so I'll work with the wx.TextAttr thing. Looking into that,
is there any way to see if a colour searched for with
wx.TheColourDatabase.Find is valid or not? If I enter:
wx.TheColourDatabase.Find('asdf'), it returns a colour with RGB at -1.
Do I just check for -1 in the RGB values? Or is there a traceback or
return value I can rely upon? I was hoping for a function which returned
a colour or None (or a traceback).
The colour with -1 components is "invalid" and is how functions like this indicate an error when returning C++ objects. You can call the colour's Ok() method to see if it is a valid colour or not.