Python Forum
subprocess.call change color of shell
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
subprocess.call change color of shell
#6
I'm not near the linux machine at the moment, but tried on the windows 10:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import subprocess
import colorama as cr

print("Some text in default color.")

cr.init()    # Needed for Windows, supposedly ignored by linux
print(cr.Fore.GREEN)

subprocess.run("dir", shell=True)

print(cr.Style.RESET_ALL)
print("Hopefully some text in default color, again.")
Output:

Output:
C:\Python\scratch.py Some text in default color.    # Default color #    This is in Green  Volume in drive C is Acer  Volume Serial Number is 8CE3-7690  Directory of C:\Python\ 01/19/2017  09:54    <DIR>          . 01/19/2017  09:54    <DIR>          .. 01/19/2017  09:54               479 scratch.py                1 File(s)         479 bytes                2 Dir(s)  907,242,061,824 bytes free Hopefully some text in default color, again.    #Back to default color C:\Python\>
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
RE: subprocess.call change color of shell - by sparkz_alot - Jan-19-2017, 03:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 3,740 Oct-25-2023, 09:09 AM
Last Post: codelab
  simplekml change shape&color issac_n 2 4,278 Aug-20-2022, 07:15 PM
Last Post: Joseph_Paintsil
  continue if 'subprocess.call' failes tester_V 11 9,964 Aug-26-2021, 12:16 AM
Last Post: tester_V
  printing out the contents aftre subprocess.call() Rakshan 3 4,254 Jul-30-2021, 08:27 AM
Last Post: DeaD_EyE
  subprocess call cannot find the file specified RRR 6 22,063 Oct-15-2020, 11:29 AM
Last Post: RRR
  Change the color automatically Dragonos 5 4,194 Jul-28-2020, 01:17 PM
Last Post: Dragonos
  Use of input function to change screen background color in Turtles Oldman45 3 8,629 Jul-10-2020, 09:54 AM
Last Post: Oldman45
  Why wont subprocess call work? steve_shambles 3 3,843 Apr-28-2020, 03:06 PM
Last Post: steve_shambles
  subprocess.call - Help ! sniper6 0 1,986 Nov-27-2019, 07:42 PM
Last Post: sniper6
  How to use subprocess send commands to windows shell hlhp 3 6,338 Nov-26-2019, 04:40 AM
Last Post: LeanbridgeTech

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020