Is it possible to get the text color of insertion point in richtextctrl?

Hi,

In my app I need to get the text color of the current position. For example, when the user move the text cursor on a blue word the app must return the blue color.
Is there any way to do it?

Thanks in Advance.

A.A

I’m not sure and haven’t tried it, but poking around through the wxRichTextCtrl documentation–maybe this works?

my_textattribute = TextAttr() #create a blank text attributes (“textattr”) object
my_richtextctrl.GetStyle(the_current_position, my_text_attribute) # “fills” the new textattr with the style at that position.

#Now get what you want, for example:

background_color_of_selection = my_textattribute.GetBackgroundColour()

foreground_color_of_selection = my_textattribute.GetTextColour()

···

On Thu, Jan 7, 2016 at 6:54 PM, a.m.n.alsubhi@gmail.com wrote:

Hi,

In my app I need to get the text color of the current position. For example, when the user move the text cursor on a blue word the app must return the blue color.
Is there any way to do it?

Thanks in Advance.

A.A

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thanks. It works perfectly.

···

On Friday, January 8, 2016 at 12:16:08 AM UTC-5, Che M wrote:

I’m not sure and haven’t tried it, but poking around through the wxRichTextCtrl documentation–maybe this works?

my_textattribute = TextAttr() #create a blank text attributes (“textattr”) object
my_richtextctrl.GetStyle(the_current_position, my_text_attribute) # “fills” the new textattr with the style at that position.

#Now get what you want, for example:

background_color_of_selection = my_textattribute.GetBackgroundColour()

foreground_color_of_selection = my_textattribute.GetTextColour()

On Thu, Jan 7, 2016 at 6:54 PM, a.m.n....@gmail.com wrote:

Hi,

In my app I need to get the text color of the current position. For example, when the user move the text cursor on a blue word the app must return the blue color.
Is there any way to do it?

Thanks in Advance.

A.A

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.