Welcome, guest | Sign In | My Account | Store | Cart

Printing to the screen with a difference. ;oD

Works on almost any version of Python running in a terminal inside Linux.

(C)2012, B.Walker, G0LCU...

Python, 26 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# HW.py
# Almost any version of standard text mode Python inside a terminal on Linux OS...
# IMPORTANT! The print() function MUST be a single line only so beware of wordwrapping, etc... etc...
# You may need to edit it if wordwrapping occurs...
# (C)2012, B.Walker, G0LCU...
#
# Edited on 02-04-2012 as per comment by S.D'Aprano.
#
# NOTE:- There is NO malicious intent in this code!!!
# I DO expect, however, that professionals _know_ how to manipulate Linux terminal colours through Python!

reset_term_colours="\033[0m"

f="\033[0;36;41m"
b="\033[0;31;46m"
lines=0

print(reset_term_colours)

for lines in range (0,50,1): print(b)

print(b+" "+f+" "+b+"   "+f+" "+b+"        "+f+" "+b+"     "+f+" "+b+"                "+f+" "+b+"   "+f+" "+b+"              "+f+" "+b+"        "+f+" "+b+"   "+f+" "+b+"\n "+f+" "+b+"   "+f+" "+b+"        "+f+" "+b+"     "+f+" "+b+"                "+f+" "+b+"   "+f+" "+b+"              "+f+" "+b+"        "+f+" "+b+"   "+f+" "+b+"\n "+f+" "+b+"   "+f+" "+b+"  "+f+"   "+b+"   "+f+" "+b+"     "+f+" "+b+"     "+f+"   "+b+"        "+f+" "+b+"   "+f+" "+b+"  "+f+"   "+b+"  "+f+" "+b+" "+f+"   "+b+"  "+f+" "+b+"     "+f+"    "+b+"   "+f+" "+b+"\n "+f+"     "+b+" "+f+" "+b+"   "+f+" "+b+"  "+f+" "+b+"     "+f+" "+b+"    "+f+" "+b+"   "+f+" "+b+"       "+f+" "+b+"   "+f+" "+b+" "+f+" "+b+"   "+f+" "+b+" "+f+"  "+b+"     "+f+" "+b+"    "+f+" "+b+"   "+f+" "+b+"   "+f+" "+b+"\n "+f+" "+b+"   "+f+" "+b+" "+f+"     "+b+"  "+f+" "+b+"     "+f+" "+b+"    "+f+" "+b+"   "+f+" "+b+"       "+f+" "+b+" "+f+" "+b+" "+f+" "+b+" "+f+" "+b+"   "+f+" "+b+" "+f+" "+b+"      "+f+" "+b+"    "+f+" "+b+"   "+f+" "+b+"   "+f+" "+b+"\n "+f+" "+b+"   "+f+" "+b+" "+f+" "+b+"      "+f+" "+b+"     "+f+" "+b+"    "+f+" "+b+"   "+f+" "+b+"       "+f+"  "+b+" "+f+"  "+b+" "+f+" "+b+"   "+f+" "+b+" "+f+" "+b+"      "+f+" "+b+"    "+f+" "+b+"   "+f+" "+b+"\n "+f+" "+b+"   "+f+" "+b+"  "+f+"    "+b+"   "+f+"   "+b+"   "+f+"   "+b+"  "+f+"   "+b+"        "+f+" "+b+"   "+f+" "+b+"  "+f+"   "+b+"  "+f+" "+b+"       "+f+"   "+b+"  "+f+"    "+b+"   "+f+" "+b+"\n\n\n\n\n Hello World!\n\n\n\n\033[0;30;46mPress Ctrl_C to Quit/Stop/Exit...")

print(reset_term_colours)

while 1: pass

DO NOT TAKE THIS SERIOUSLY!

This is just a taster of something I am working on to be released in the not too distant future.

I just wanted to see what 6 _bits_wide_ by 8 _bits_deep_ characters would look like and decided to share with everyone.

I am working on an at_a_distance_glance digital readout with digits the same size as this program.

This digital readout will HOPEFULLY eventually work on Classic AMIGAs, WinUAE, E-UAE, Windows and Linux flavours.

Bazza, G0LCU...

4 comments

Barry Walker (author) 9 years, 8 months ago  # | flag

Ooooh, voted down on 18-03-2012 by a faceless one. Ah well who cares... ;o)

Steven D'Aprano 9 years, 8 months ago  # | flag

To anyone thinking about running this code:

It will mess with your terminal settings by changing the background colour, and who knows what else.

Depending on your terminal, you may be able to fix that by using the "Reset and clear" menu command, if you have one, or you could try typing reset at the prompt.

Barry, messing around with the user's environment without warning is really rude. A smiley and shouting "don't take this seriously" doesn't excuse this childishness.

When your code makes environment changes like this, tell the user what your code does. Running stranger's code requires trust. You've just used up the last of my trust for you.

As they say, "Fool me once, shame on you. Fool me twice... well, you won't fool me twice."

Barry Walker (author) 9 years, 8 months ago  # | flag

Steven...

I accept your comment and the down vote. I am not sure if you will read this but...... Maybe I should have started and ended with this line...

print("\033[0m")

...which satisfies all versions of Python and resets the colours back to their original status for Linux flavours ONLY.

Now back to the fun part, hopefully you will read this and reply, or email me on wisecracker at tesco.net...

The thing is, I am working on a proper program that will be an at a glance digital readout that will have that size of character in black background with GREEN, _YELLOW_ and RED* conditions depending on an 8, (16 or 32), bit value. I will release the 8 bit version for free in the not too distant future.

I am trying hard to get it to work on Linux, Windows AND Classic AMIGAs from one piece of code, except the AMIGA will use Workbench colours*, from Python Version 1.4.0 to 3.2.2, I haven't got Python 3.3.x yet. So far all the colour switching for the platforms is working and simple large characters are working I now have to put them together along with a digital character set using spaces - not quite so easy.

Perhaps you will now understand why I considered it fun and also see how to generate large characters using character 32 or character 219 depending upon the platform. You did exactly what I expected though, and this was the reason for uploading. I wanted opinions as to the characters and totally expected a vote down. I didn't expect your reply though of which I humbly apologise so I will include the single line above to ensure a return to the original state after running...

I hope this will restore your trust in my ideas. I don't do anything for malicious intent, I do everything for youngsters to do for themselves, and, GIVE it all away...

Bazza...

Barry Walker (author) 9 years, 3 months ago  # | flag

21-08-2012.

Now tested on a MacBook Pro OSX 10.7.3, with Python Version 2.7.1...

Created by Barry Walker on Sat, 17 Mar 2012 (MIT)
Python recipes (4591)
Barry Walker's recipes (73)

Required Modules

  • (none specified)

Other Information and Tasks