473,772 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic or on-the-fly color changing in curses?

I'd like to write a class or module in python that allows me to do
on-the-fly color changing in the curses module.

I'm thinking about something along the lines of this:

addstr(y, x, 'hello', brightyellow, blue)

The module would automatically interpret the above as

curses.init_pai r(i, curses.COLOR_YE LLOW, curses.COLOR_BL UE)
addstr(y, x, 'hello', curses.color_pa ir(i) | curses.A_BOLD)

What I thought I could get away with is constantly redefining the
same color_pair, as in the following:

curses.init_pai r(1, curses.COLOR_RE D, curses.COLOR_BL ACK)
scr.addstr(0, 0, 'Hello, world', curses.color_pa ir(1))

curses.init_pai r(1, curses.COLOR_BL UE, curses.COLOR_BL ACK)
scr.addstr(1, 0, 'Hello, world', curses.color_pa ir(1))

curses.init_pai r(1, curses.COLOR_GR EEN, curses.COLOR_BL ACK)
scr.addstr(2, 0, 'Hello, world', curses.color_pa ir(1))

But when I do that, all strings show up as green. My assumption
here is that all strings are assigned to color_pair(1), and when
those strings are drawn, they assume the most recent definition of
color_pair(1). In other words, it appears you can't "recycle" color
pair definitions.

So my second thought was to just pre-define every possible
combination, but, at least on Linux, I'm limited to 63 unique
colors, whereas I can create more than 63 color combinations
(foreground, background, and attribute combinations).

Am I strictly limited to using at most curses.COLOR_PA IRS colors on
a per-application basis?

Thanks,
Matt

--
Matt Garman
email at: http://raw-sewage.net/index.php?file=email
Jul 18 '05 #1
0 1876

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1879
by: Neuruss | last post by:
I've been reading an article published in E-Week entitled "Microsoft Lures Open-Source Programmer", which contains a definition for dynamic languages as follows: "Dynamic programming languages enable programs to change their structure as they run." I wonder if this definition is correct. Can we define dynamic languages this way?
14
2245
by: Spare Change | last post by:
I am told that I can have a dynamic or static string array. So if I declare string dynamic; How do I add elements to dynamic and resize it ?
1
1215
by: Chen Sun via .NET 247 | last post by:
I have posted this message 15 hours ago but I still could not seeit. So I decide repost it. I have successully used Jeffrey Ton's method to generate dymanicTextBox. Now my problem is that After the textbox show firsttime, I changed the text of textbox. I WANT to use thes new textin the textbox. But since the textbox showed second time is newgenerated, or say new populated. So how could I use the new Text in textBox? Thanks. Chen
5
3553
by: Sakcee | last post by:
Hi I am trying to use pyUnit to create a framework for testing functions I am reading function name, expected output, from a text file. and in python generating dynamic test functions something like this class getUsStatesTest( unittest.TestCase ):
0
1169
by: Prarthana Choudhary | last post by:
hi, i want to know how to save data from dynamic htmlinputfile to sql server. dynamic htmlinputfile are added in dynamic table..... thanx in advance
10
3717
by: Zytan | last post by:
This article: http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingWithArrays11142005060354AM/WorkingWithArrays.aspx claims that "In C#, arrays can be declared as fixed length or dynamic". I don't believe he is correct. With the exception of collections / arraylists, can you have a dynamically sized array in C#? Note that i am aware of Array.Resize<type>(ref myArray, newsize); for resizing arrays in .NET 2.0. Is there a way to...
1
4418
by: Tinku | last post by:
Hi friends I know Static Hashing and i know about Dynamic Hashing, still i have problem to make program with Dynamic Hashing I am new in "C" world, please help me, my problem is: i have to make program in Dynamic hashing i have to store int value in nodes user only enter int value by this value i have to find hash key and make symbol table my struct are
4
530
by: aarklon | last post by:
Hi all, recently a friend asked me is there any dynamic binding in C...?? to which i answered AFAIK it is in C++ only, but he says it is valid in C. if dynamic can be implemented via function pointers in C , can anyone give an example for dynamic binding in C...??
5
2607
by: Andrus | last post by:
How to compile source code into dynamic method ? System.Reflection.Emit.DynamicMethod requires IL code for creation. How to use C# source code to create method instead of manually creating IL code ? Assembly compilation requires passing parameters to access calling assembly members. Assemblies cannot unloaded. Dynamic method has automatic acces to assembly members. Memory allocated by dynamic code can be re-used if code is released.
2
1686
by: sachin30 | last post by:
hi is it possible to get all volume in dynamic disk.? i have two disk one is basic and other one is dynamic(os - windows server 2003 ent edition) i just want all volumes information on dynamic disk is any API in c++ that return all volume in dynamic disk? Thanks in advancce
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.