ArgParse - Adding colors with colorama

Building Command Line Tools with Python, Julia and Nodejs Module 02 - Building Command Line Tools in Python with ArgParse
7 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.26
List Price:  €93.23
You save:  €27.97
£55.95
List Price:  £79.94
You save:  £23.98
CA$95.75
List Price:  CA$136.79
You save:  CA$41.04
A$107.23
List Price:  A$153.20
You save:  A$45.96
S$95.15
List Price:  S$135.94
You save:  S$40.78
HK$547.94
List Price:  HK$782.80
You save:  HK$234.86
CHF 63.91
List Price:  CHF 91.30
You save:  CHF 27.39
NOK kr766.40
List Price:  NOK kr1,094.90
You save:  NOK kr328.50
DKK kr486.75
List Price:  DKK kr695.39
You save:  DKK kr208.64
NZ$117.46
List Price:  NZ$167.81
You save:  NZ$50.35
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,670.29
List Price:  ৳10,958.03
You save:  ৳3,287.74
₹5,832.01
List Price:  ₹8,331.80
You save:  ₹2,499.79
RM334.37
List Price:  RM477.70
You save:  RM143.32
₦88,678.72
List Price:  ₦126,689.32
You save:  ₦38,010.60
₨19,457.85
List Price:  ₨27,798.13
You save:  ₨8,340.27
฿2,591.43
List Price:  ฿3,702.20
You save:  ฿1,110.77
₺2,274.88
List Price:  ₺3,249.97
You save:  ₺975.09
B$360.25
List Price:  B$514.66
You save:  B$154.41
R1,330.75
List Price:  R1,901.16
You save:  R570.40
Лв127.68
List Price:  Лв182.41
You save:  Лв54.73
₩96,191.02
List Price:  ₩137,421.64
You save:  ₩41,230.61
₪265.67
List Price:  ₪379.55
You save:  ₪113.87
₱4,044.82
List Price:  ₱5,778.57
You save:  ₱1,733.74
¥10,886.62
List Price:  ¥15,552.99
You save:  ¥4,666.36
MX$1,193.70
List Price:  MX$1,705.36
You save:  MX$511.66
QR254.90
List Price:  QR364.16
You save:  QR109.26
P969.33
List Price:  P1,384.82
You save:  P415.49
KSh9,413.65
List Price:  KSh13,448.65
You save:  KSh4,035
E£3,352.26
List Price:  E£4,789.16
You save:  E£1,436.89
ብር3,973.96
List Price:  ብር5,677.33
You save:  ብር1,703.36
Kz58,616.62
List Price:  Kz83,741.62
You save:  Kz25,125
CLP$66,678.07
List Price:  CLP$95,258.47
You save:  CLP$28,580.40
CN¥507.14
List Price:  CN¥724.52
You save:  CN¥217.38
RD$4,110.44
List Price:  RD$5,872.31
You save:  RD$1,761.87
DA9,401.90
List Price:  DA13,431.87
You save:  DA4,029.96
FJ$160.42
List Price:  FJ$229.18
You save:  FJ$68.76
Q543.26
List Price:  Q776.12
You save:  Q232.86
GY$14,630.45
List Price:  GY$20,901.55
You save:  GY$6,271.09
ISK kr9,795.80
List Price:  ISK kr13,994.60
You save:  ISK kr4,198.80
DH709.23
List Price:  DH1,013.23
You save:  DH303.99
L1,246.59
List Price:  L1,780.93
You save:  L534.33
ден4,020.35
List Price:  ден5,743.61
You save:  ден1,723.25
MOP$563.94
List Price:  MOP$805.67
You save:  MOP$241.72
N$1,340.22
List Price:  N$1,914.68
You save:  N$574.46
C$2,572.43
List Price:  C$3,675.06
You save:  C$1,102.63
रु9,316.74
List Price:  रु13,310.19
You save:  रु3,993.45
S/259.29
List Price:  S/370.43
You save:  S/111.14
K265.67
List Price:  K379.55
You save:  K113.87
SAR262.50
List Price:  SAR375.02
You save:  SAR112.51
ZK1,825.88
List Price:  ZK2,608.51
You save:  ZK782.63
L324.76
List Price:  L463.96
You save:  L139.20
Kč1,644.30
List Price:  Kč2,349.11
You save:  Kč704.80
Ft25,615.12
List Price:  Ft36,594.60
You save:  Ft10,979.47
SEK kr760.35
List Price:  SEK kr1,086.27
You save:  SEK kr325.91
ARS$61,118.20
List Price:  ARS$87,315.45
You save:  ARS$26,197.25
Bs482.97
List Price:  Bs689.99
You save:  Bs207.01
COP$272,384.35
List Price:  COP$389,137.18
You save:  COP$116,752.82
₡35,055.79
List Price:  ₡50,081.85
You save:  ₡15,026.05
L1,725.31
List Price:  L2,464.83
You save:  L739.52
₲519,197.15
List Price:  ₲741,742.01
You save:  ₲222,544.85
$U2,684.12
List Price:  $U3,834.62
You save:  $U1,150.50
zł281.58
List Price:  zł402.27
You save:  zł120.69
Already have an account? Log In

Transcript

All right, so welcome back again. So in the previous tutorial, we saw how to add colors to our CLA using Tim color. So in this tutorial, we're going to see how to add another alternative of adding colors in a different package. Let's see how to do this. I'm just going to clear all this, then we're going to create another file, right? So let's call this one as colors with color.

Color with colorable is the name of the particular using for our class colors. Very interesting. So let's close out of this. So how do we record it? So the basic idea is that first of all, it is going to install color on switches. So just go with pip install, color, or color.

Right? Very, very difficult just how to work with it. So you can install it on Windows when you understand it's going to work. But how it works is different on Windows and an on on Windows and an on Linus origins Be system. So we seen that one in that upcoming session. So that is how to install.

So let's create something very basic. So I just copy this to save us time. Copy this, to see what time right so that we don't repeat the same thing. So I'll copy this off piece of this tool, we're going to take off all of this, we don't need any of these anymore. To do the same thing I've done it right, so let's decode this. And let's check up what is working perfectly RC Li, there's going to be a Python three then we're passing my color with that help and it's working perfect right everything is working as expected.

So let's see how to work with it. So the simplest way of working with it is that you are going to face a file import it. So let's import it so is going to be from here to be from from Kala drama input. Yes, ever since 2003, in case you're working on unit on Windows, you just go it, put it in, it's going to enable us to be able to use the sky colors on Windows, right. But if you're not on Windows, you can still use it without it. Then the next one is we need to port for for foreground color, then we need to go back for background color, add important stuff for staff so that they can use it to mean stuff.

You're going to put in it for initializing on reduce to Windows, foreground background and stuff. So let's see how to record it. So first of all be adding the colors to it. For the simplicity of it Nicola does not do the normal print, then what you add a color to it. So first of all, I'm just going to pass the names for for the foreground color, then I'll specify the particular color which I want the foreground color to be blue. So in this color must be in cups right?

Then I can just go on with the same thing that we have here. So let's copy this here and paste it here. He's going to give us our full color for one color as blue. So let's save it. Let's run it See I come back here so the same thing as good if that let's give it a different name likeness Mark Marcus in a second Hello monkey so they face Mark was right was cut make Buddha the face Mark Marcus was with our color. As you can see here it's without color but the second one is with a color right the color was foreground color is blue is it basically this is I want to add a background color to it.

Then I can just change it. So there are seven colors is supposed to go with blue, cyan, magenta and the rest so let's add another color to it. So you can see that the circle is supposed to this is going to be magenta to concrete. Jen, I hope magenta is supported. Must see Let's also put magenta. So let's come back again to this, run it again.

So we see that we have our blue foreground and our magenta foreground. Let's add another color for the background. So this is how to work with focal, we get also to work with background, I can supply the background color, so I'm just going to go to this option and supply the background color BG to back does not supply the particular color. So what color do I want for these two, I want the background color to be quite staccato. If I save it and I come back here and now I can run it and I can see that we have Hello right in macros. But you see you notice something that once you set off like this, it influences the next color.

Right? So that is one disadvantage when you are using color oma, right? So that is a bug right to see that is affecting it. Let's change it and see so you can actually see what I mean. I'm going to change this one from black to black. So you see that is actually affected.

So background color is a black hole black is supported. I come back to this ironic that now even Dennis one following is still black, that isn't the best method right? The simplest way that after doing this you can reset it with this stuff, right so I can come back to this place can go with my style to sit is to print then style that a particular style and style so good to be reset. We have several styles if I go You said oh no is going to reset that. So that if I run it again. Now my Is it good secured, right?

The same thing can be here. So if I come back to this and then let's put in a claim test so there's going to be claims. If I play this claim that in between our blue color and our magenta considered the blue is going to influence the one without color. So let's go this one without color. This is going to be without color. Apologies for the noise.

So without color, so this without color is going to also be influenced by the first one. So let's see, if I run it. I said there we don't color is blue, right? This one is blue, but I did not specify any color, there is a disadvantage, or something that you have to face. So how do you fix it, simply by going with pre install, then you just pass that breast on to the points that you don't want to see that come back here. They put no it's going to reset it to that point, then the next one is going to be without the color.

So let's try it again. So run it now see that without color is without color is how to work with karma. So karma is very interesting. You see the option of doing some interesting stuff, it always foreground background color can add format here, so we have stars, it all comes with another color likeness. A preset can also be dim. So let's say this one to dim, which you come to do, come back here.

Can I run it again? Now? This is Tim right? It still affected this one. So we have to always make sure that after every color you end it with reset. Then we have to see it working perfectly well.

Let's write again. Now it's working, it's not affecting anyone. So that is how to work with Chroma and how to add colors to your CLR using color aroma. So thank you for watching. I'll see in the next session. Stay blessed.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.