How to set Background to black and Foreground color to white in Prettytable? - prettytable

I want to display tabular data using Prettytable where the background is black and foreground is white. I cannot use the HTML option.
from prettytable import PrettyTable
tbl = PrettyTable(header_color='\033[40m')
tbl.field_names = ["col1", "col2", "Parameter", "AUC"]
tbl.add_row(["Type 1", "Vacc1", 9, 0.89])
tbl.add_row(["Type 2", "Vacc2", 7, 0.98])
tbl.add_row(["Type 3","Vacc3" ,27, 0.73])
tbl.add_row(["Type 4","Vacc4", 19, 0.72])
print('\033[40m','\033[37m',tbl)
I would like to know how we can have black background and white letters for the above table. Are there properties in prettytable that we need to use or is there some other library in conjunction with prettytable that I need to use to get the desired output.

Have you tried some libraries such as colorama
to format the colour schema of your print's output ? Other than that, the trivial way is
adding colour to your text manually.

Related

What is the color code for iOS system labels in both light and dark mode?

Human Interface Guidelines, "Color" section talks about the using system color is preferred. There are color codes for all system colors however for the foreground content text color there only APIs provided.
So what exactly is the color code for labels in both light and dark mode? Our designers need these colors for their mockup.
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/
The color code fetched from the Playground does not seem right. The hex codes are all the same.
The RGB values of secondary, tertiary, and quaternary label colour are in fact the same. They only differ in the alpha value, which you might have forgotten about :)
From what I observed:
Label colour has 100% alpha
Secondary label colour has 60% alpha
Tertiary label colour has 30% alpha
Quaternary label colour has 18% alpha
Here's another way to find the hex value of a system colour. Go to the asset catalog of an Xcode project. Add a colour set:
Then, select "Any Appearance" or "Dark Appearance" depending on which one you want ("Any Apperance" means "not dark"). You can even check the "High Contrast" box to have more options for how your dynamic colour will look depending on the situation.
Then select your desired colour from the "Content" dropdown (see freehand circle).
Finally, you can click on "Show Color Panel" to see the hex:

Creating a transparent color within a string palette

I am working within Google Earth Engine and am trying to create a no-color/completely transparent color (no boarder and no fill). Below is a line of code where the first color should be the transparent "color". Basically I want my min value to not show up in the map at all.
Map.addLayer(image, {min: 0, max: 3, palette: [transparent, '#0571b0', '#FFDF00', '#ca0020']},'image');
I have tried creating a variable to set a color as completely transparent (change the opacity to 0), but the palette command cannot take variables. Only strings. I've also read SVG fill color transparency, but do not understand how to change the opacity of that specific color without creating a variable (which again, palette doesn't allow). Lastly, I tried adding 00 to the end of another color, but that did not work either.
Any suggestions?
Update:
I was never able to find a solution to this and ended up just going with a white back ground. It was purely for a nicer aesthetic look to allow a basemap to be seen. If I ever come across a solution, I'll be sure to post it.
I had the same question. I found the solution in the developer group.
See the answers: https://groups.google.com/g/google-earth-engine-developers/c/WcxtEIzudxw/m/GscOlsQhDgAJ
The Solution:
// create your previous mask
image = image.eq(1)
// mask and set the opacity
image = image.mask(image.mask().where(image.eq(0),0.0))

why I get slightly different colour even though I put the same RGB number?

In launchScreen.StoryBoard I set the colour manually using color picker like the picture above. as you can see red = 255, green=171, blue=0
from the launch screen, it will contiune to MainVC, in MainVC, I set the splash screen when fetching data from the internet
and because I use the library, I should put the colour programatically. I use the code below to generate the colour
backgroundColor: UIColor(red:255/255, green:171/255, blue:0/255, alpha:1.0)
I think I have put exactly the same RGB number , but the result is slightly different.
you can see from the gif file in here: http://g.recordit.co/tANf6VH4iC.gif
the colour near the logo will be different after around 2 seconds
Open the color scheme settings by clicking button and then select sRGB XXXXX scheme as shown below. Now correct the RGB values and see the results.
Click on that settings (gear) icon and select the same coloring scheme. That will correct this.

how to set a view's background color using a precise hex via interfacebuilder?

In IB, when I go to the attributes inspector and click the "background" drop down -> other, I get a color pallet with several tabs (wheel, slider, apllets) but there is no place to set a precise such as #ff5911 for example.
Is there a way to do that without using code?
In Xcode 6, you can set hex values in the RGB slider tab.
You can switch to the RGB-Slider and use the RGB value of your hex code. There are several converters in the web:
http://www.javascripter.net/faq/hextorgb.htm
ff5911 => R: 255, G: 89, B: 17
I think there isn't the possibility in the Interace Builder to directly put in the hex value. Another way would be using the "magnifier" symbol and click on the desired color.
Add a hex color picker to your system. I use http://wafflesoftware.net/hexpicker/.

Which script editor can code-color hex color values?

I frequently work with lots of hexadecimal color values in my programs. Is there a script editor that can code-color the color values, based upon the colors they describe? .. (eg #FF0000 should be colored RED and 0x00FF00 should be colored GREEN)
The text editor UltraEdit has since version 20.00 the CSS color tooltip feature which is described as follows by IDM Computer Solutions, Inc.
Hovering cursor over a supported color definition causes a color "swatch" to be displayed. Users can CTRL+CLICK on "swatch" to invoke OS color picker to select a new color.
"Display CSS color tooltips" Configuration option added under Advanced -> Configuration -> Editor Display -> Miscellaneous
Detects and supports colors defined in the following formats:
Hex RGB
Functional notation RGB
RGBA
HSL
HSLA
Tooltips supported in the following file types:
HTML
CSS
Javascript
PHP
Perl
Python
Ruby
This feature does not syntax highlight the color value itself in the text file with the color according to the value. But it displays the color in a rectangle below the mouse pointer when mouse pointer is positioned over a color value in one of the supported formats.
So this feature of UltraEdit is not exactly what have been asked for, but is perhaps nevertheless very helpful for you.
In my point of view it does not really make sense to syntax highlight the color value itself in the color according to the value as this results most likely quite often in not visible or hard to see values. For example think about color value white with using white as text background color. Lots of combinations of text and background colors make the text very hard to read.
SynWrite editor can do it. #RRGGBB or rgb(rr, gg, bb) fragments are hilited.

Resources