Python ANSI Colour codes transparent background - python

I was wondering if it was possible to set the background colour of text, using ANSI colour codes, to transparent, or just the colour of the terminal, so you can use colours without having to deal with the background colour not being the right colour.

You can do this by ending the escape code using 49m. For example, red text on a transparent background would be \033[1;31;49m.
Happy colouring!

Related

ANSI Color Escape Sequences Different Foreground and Background color with 256 colors

I'm using the ANSI Escape Sequence codes to add color to terminal output in my program.
I am mainly using this code, where COLOR can be any value between 0 and 255 to achieve great color variation.
\033[38;5;COLOR;1m TEXT \u001b[0m
The problem is that using the 256 color spectrum I am unable to have the "background" (7m) be colored with the string in the foreground being colored as well.
Using this format I am able to have the background and foreground have their own colors, but I am no longer able to use 256 colors, being reverted to 8 or so...
\x1b[1;32;41m Green On Red \x1b[0m"
After extensive testing with values and formats, I have not found a way to have separately colored background and foreground with the 256 color spectrum. Is there a way to do this?
Managed to figure it out!
I simply run the escape sequence twice before the text. Once for background color, once for foreground color.
\033[48;5;(ONE OF 256 COLORS)m\033[38;5;(ONE OF 256 COLORS)m TEXTHERE \033[0;0m
This allows me to use the whole 256-color spectrum in both BG and FG, no imports or addons needed.

(Tkinter) Making a frame transparent without making the whole window transparent

I have a label that is the background image and a frame on that label that shows other images and buttons, but I have some white spaces. Is it possible to make those spaces transparent to show the background image?
I've tried making the background a color and making that color transparent with:
window.attributes("-transparentcolor", "#20fc03");
frame.configure(background="20fc03");
but it makes the whole window transparent showing my desktop.
I can provide code if needed, I just do not know what would be useful.

How to change font colour and size of Python Shell

I am using Python 3 and I am not sure if this is a possible query because I've searching it up and I couldn't find a solution. My question is, I want to learn how to change colour and size of my output.
How to make the size bigger or smaller?
Able to make the font size big
How to change the background colour of shell?
Able to make the background colour, for example, right now, it's all white but I want it black.
How to change the output colour of shell?
I would love to see colourful fonts operating in black background shell
I hope there is a solution to this! Thanks in advance
I know about the color part, but I came for the size.
To start off with, to close the color, use \u001b[0m. If you don't use this, all text will become the color that you started with until you close it.
Green is\u001b[32m
Black is\u001b[30m
Pink is \u001b[35m
There are much more, but is you experiment with different numbers, you can highlight and do different colors.
To make a sentence with color, format it like this:
print("\u001b[35mHi, coders. This is pink output.\u001b[0m")
Test that code. it will come out in pink.

Curses set bright and dark backgrounds

For this, it might be useful to note that I'm running python on a Mac in xterm-color
I'm trying to build a chess game with curses in Python, but I can't figure out how to set the color pairs to use bright black or bright white (so I can have better contrast between board and pieces.) The terminal shows the bright colors as being the color + 8 (so the 8-15 range,) but if I try to use those, I get back init_pair() returned ERR (For example, in:)
curses.init_pair(1, 0, 15)
I also thought that using the A_BOLD and A_BLINK attributes might let me set bright colors in curses, but that doesn't appear to have any effect. For example:
pad.addstr(y, x, "qwert", curses.color_pair(1)|curses.A_BOLD)
What do I need to do to get these colors?
Edit:
It turns out that I had a wrong setting in the terminal ("Use bright colors for bold text" was unchecked,) but I still don't seem to have any way to set a bright background color.
I still don't seem to have any way to set a bright background color.
This question is old, but in case someone will look for answer to it, you just have to combine curses.A_BOLD with curses.A_REVERSE, for example:
curses.init_pair(1, curses.COLOR_GREEN, curses.color_BLACK);
// Pair with green as a foreground color and black as a background
curses.color_pair(1);
// Pair with light green as a background color and black as a foreground
curses.color_pair(1) | curses.A_BOLD | curses.REVERSE;
... and now you have 2 × more pairs :)
In this case, the issue is simply that I had "Use bright colors for bold text" unchecked (oops, I was messing with the settings for the wrong terminal style.) It is somewhat worrying that I might not be able to rely on users having these settings on Mac OS however.

wxPython TextCtrl Transparent Background

How can I make a TextCtrl have a transparent background? By this I mean see the desktop behind it.
Current Code:
self.control.SetBackgroundColour(wx.Color(0,0,0,0))
But that just makes the background colour black.
I am using Python 2.7 on Windows 7
To my knowledge textCtrt can't be transparent or use a background image, but you can change the background color.
TIP:
You can use the exact color as your background image by finding out the exact HEX color value.
Example code:
self.SetBackgroundColour('#232321')

Categories