Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 16th, 2012, 07:01 AM
Ploppz Ploppz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 Ploppz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 25 sec
Reputation Power: 0
Colours in the command prompt!

Hey.
I need to change the color of one word when I run my program in the command prompt (i.e. run it by double clicking on the .py file)
I searched and found this function. (a little altered for my need)

PHP Code:
 def changeColor(colorID):
    
windll.Kernel32.GetStdHandle.restype c_ulong
    h 
windll.Kernel32.GetStdHandle(c_ulong(0xfffffff5))
    
windll.Kernel32.SetConsoleTextAttribute(hcolorID


The thing is, all it can do is change the color of a single line.
Tried this:

PHP Code:
print("I will call it "), end="")
changeColor(4)
print(
newNameend="");
changeColor(2)
print(
"!"); 


But it would only change the color of the line to 2 and to 4 if I removed the changeColor(2) line. So does anyone know any way to change the color of just one word?

Thanks in advance

Reply With Quote
  #2  
Old December 16th, 2012, 01:17 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,360 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 9 h 55 m 30 sec
Reputation Power: 383
http://ascii-table.com/ansi-escape-sequences.php

examples in many computer languages
__________________
[code]Code tags[/code] are essential for python code!

Last edited by b49P23TIvg : December 16th, 2012 at 01:26 PM.

Reply With Quote
  #3  
Old December 17th, 2012, 08:38 AM
Ploppz Ploppz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 Ploppz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 25 sec
Reputation Power: 0


Thank you for your reply! I didn't have time to test it before now and got this

PHP Code:
 Traceback (most recent call last):
  
File "D:\~ Programming\Python\PYTHON\Test.py"line 4in <module>
    
import colorama
ImportError
No module named 'colorama' 

Reply With Quote
  #4  
Old December 17th, 2012, 08:52 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,360 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 9 h 55 m 30 sec
Reputation Power: 383
I take it you didn't bother to search the internet for colorama, nor did you bother to learn about ANSI terminal control sequences.
https://www.google.com/webhp?sourceid=chrome-instant&ie=UTF-8&ion=1#hl=en&tbo=d&qscrl=1&sclient=psy-ab&q=colorama.py&oq=&gs_l=&pbx=1&qscrl=1&fp=d518ec0f384933bc&bpcl=39967673&ion=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&bvm=bv.1355325884,d.dmQ&biw=949&bih=532

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Colours in the command prompt!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap