aelhadad
Posts: 37
Joined: Tue Jan 16, 2018 7:55 pm

CMD background color

Wed Apr 04, 2018 2:57 pm

Is there a way to change thecmd background color for the raspberry pi? if so do I have to change the writing color too?. Also, can I make the the writing bigger?

Thanks.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: CMD background color

Wed Apr 04, 2018 3:31 pm

hi, what window are you talking about?
-a- RASPBIAN lite HDMI
-b- Raspbian desktop HDMI lxterminal window
Image
-c- PC putty shh terminal window

aelhadad
Posts: 37
Joined: Tue Jan 16, 2018 7:55 pm

Re: CMD background color

Wed Apr 04, 2018 3:39 pm

I am using VNC with my raspberry, then I open the command prompt window and call

Code: Select all

python sensor3.py
then my data is printed on the command prompt.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: CMD background color

Wed Apr 04, 2018 3:45 pm

aelhadad wrote:
Wed Apr 04, 2018 3:39 pm
I am using VNC with my raspberry, then I open the command prompt window
lxterminal header menu [edit][preferences][style]

User avatar
PeterO
Posts: 5875
Joined: Sun Jul 22, 2012 4:14 pm

Re: CMD background color

Wed Apr 04, 2018 3:47 pm

The colour selection for lxterminal (show above) is found in the Edit Menu under Preferences and Style
PeterO
KLL beat me to it !
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: CMD background color

Wed Apr 04, 2018 11:58 pm

as you see at my LOGIN, there are bash text terminal colors, more here
but that can be used from python also

Code: Select all

pi@RPI3:~/projects $ ls
BACKUP_from_DATA  python3_sensor_terminalcolors.py
pi@RPI3:~/projects $ leafpad python3_sensor_terminalcolors.py
pi@RPI3:~/projects $ chmod +x python3_sensor_terminalcolors.py
pi@RPI3:~/projects $ ./python3_sensor_terminalcolors.py
python3_sensor_terminalcolors.py
sensor1:123.45
sensor2:67.8
pi@RPI3:~/projects $ cat python3_sensor_terminalcolors.py
#!/usr/bin/python3

# use terminal color defs as from BASH
# raspberry pi
WHT='\033[37;44m'   # white on blue background
BLU='\033[47;34m'   # blue on white background
MAG='\033[47;35m'   # magenta on white background
GRN='\033[0;32m'   # green on NO background
RED='\033[47;31m'   # red on white background
BLK='\033[47;30m'   # black on white background

BOLD='\033[1m'             # and BOLD
END2='\033[0m'             # end style
MTXT=''

MTXT='python3_sensor_terminalcolors.py'
print("{color}{text}{default}".format(color=RED,text=MTXT,default=END2))

VALUE=123.45
MTXT='sensor1'
print("{color}{text}{default}:{vcolor}{vtext}{default}".format(color=BLU,text=MTXT,vcolor=MAG,vtext=str(VALUE),default=END2))

VALUE=67.8
MTXT='sensor2'
print("{color}{text}{default}:{vcolor}{vtext}{default}".format(color=BLU,text=MTXT,vcolor=MAG,vtext=str(VALUE),default=END2))
pi@RPI3:~/projects $ 

Image

and yes, it also works from PUTTY SSH ( i use bitvise ssh client )
Image

____________________________________________________
or you go the next step and make a graphic python program ( what creates a application window )
that you can run only from desktop, not putty terminal...
PYTHON ways: Tkinter, pygame, matplotlib, pygtk, WX, QT4, QT5, QT5 QT quick qml
but if you think linux desktop applications are not your future, better try webserver HTML5 ( by python3 flask )

Return to “Beginners”