'How to change the color of text selector (blinking) cursor for every widgets at once?

I have make a tkinter project in python which has black background so I wanted to change the color of the text selecter (the blinking one) cursor of the widgets and I know that I can do it individually by using insertbackground but the real problem is that my code is vere long it includes multiple textbox and entry widgets so is there is any easy way to set the default color of the cursor with minimum editing of the code as it is a very time taking work to edit each and every widgets manually. So please help me...

Thank in Advance..



Solution 1:[1]

To set the default you can use the little-used option database. This is a feature what has more relevance in X11-based window systems, but is still useful on all platforms for problems such as this.

For example, after creating the root window you can set the default for the insertbackground option to "red" for all widgets like so:

root = tk.Tk()
root.option_add("*insertBackground", "red")

This default value will be used for any new widgets created after defining the default value.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bryan Oakley