Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75670

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

From Terry Reedy <tjreedy@udel.edu>
Subject Re: cmd.exe on WIndows - problem with displaying some Unicode characters
Date 2014-08-04 04:39 -0400
References <yxht7c4so8ud.kqpa5p5iv0mp.dlg@40tude.net>
Newsgroups comp.lang.python
Message-ID <mailman.12626.1407141602.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 8/3/2014 6:52 PM, Wiktor wrote:
>
> Hi,
>
> as OO programming exercise, I'm trying to port to Python one of my favorite
> game from early'90 (Atari 65XL/XE) - Kolony (here's video from original
> version on C64 https://www.youtube.com/watch?v=UFycYOp2cbE, and here's

This appears to be an actual text screen, no graphics.

> video from modern rewritten (for Atari emulators) version: Kolony 2106
> https://www.youtube.com/watch?v=eX20Qqqm5eg - you get the idea? ;-)).

This appears to be text boxes on a graphics screen.

> OO Design is one thing, but I want to make it look as near as possible to
> the original (those windows-like menus in console window).

Which original? the C64 or Atari.  The important characteristic of both 
is that both have multiple overlapping popup boxes. This means that 
either you or a widget framework much keep track of stacking order and 
how to restore what was hidden when a box goes away or is moved down in 
the stacking order. I would not be surprised if the Atari had at least a 
rudimentary widget framework.

 > I tried to use
> 'standard' Unicode characters (I can see that most of my Windows monospaced
> fonts have them) to draw frame around menu. Something like this:
>
>   ┌──────────────╖
>   │ Construction ║
>   │ Production   ║
>   │ Research     ║
>   │ Exploration  ║
>   ├··············╢
>   │ Next turn    ║
>   ╘══════════════╝
>
> (I like the look of double lines on right and at the bottom)
> But when I try to print those characters, I get an error:
>
> | Traceback (most recent call last):
> |   File "E:\Moje dokumenty\python\kolony\menu.py", line 14, in <module>
> |     """
> |   File "C:\Python34\lib\encodings\cp852.py", line 19, in encode
> |     return codecs.charmap_encode(input,self.errors,encoding_map)[0]
> | UnicodeEncodeError: 'charmap' codec can't encode character '\u2556' in position 1
> | 6: character maps to <undefined>

You have two separate problems with running in the windows console.

1. The character issue. If you run a program to just print the above 
from an Idle editor, so that the output is printed to the Idle shell, 
there should be no problem.
 >>> print('\u2556'*10)
╖╖╖╖╖╖╖╖╖╖
But characters are not your real issue.

2. The random access issue. The MS console in normal use is like a 
serial printer or terminal. Once a line is printed, it cannot be 
changed. I looked at the video and the program randomly accesses a 24 or 
25 line x 80 column screen, overprinting existing characters at will and 
reversing black on white versus white of black at will.  MSDOS screens 
recognized standard ANSI screen control codes once the ANSI.SYS driver 
was installed, which was fairly normal. But cmd.exe is actually a 
regression from MS-DOS in that it apparently will not allow this.  Or it 
is a hugh pain.

You could get a program that emulates a full-screen ANSI terminal, and 
learn to use ANSI control codes.  Or you could use a tkinter (tk) Text 
widget. People have written at least serial terminal emulators for Text, 
but I did not find a full-screen.

Using tkinter, I would try making each box a separate text box placed in 
a frameand let tkinter worry about displaying them correctly and 
detecting which box get a mouse click or <enter> key.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 00:52 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-04 09:08 +1000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Christian Gollwitzer <auriocus@gmx.de> - 2014-08-04 22:35 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-04 00:20 +0100
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Andrew Berg <aberg010@my.hennepintech.edu> - 2014-08-03 18:25 -0500
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-04 00:29 +0100
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-04 09:39 +1000
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-04 10:14 +1000
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-03 17:17 -0700
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters wxjmfauth@gmail.com - 2014-08-04 01:47 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-03 21:14 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Andrew Berg <aberg010@my.hennepintech.edu> - 2014-08-04 00:06 -0500
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 04:39 -0400
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 17:00 +0200
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-08-04 17:43 +0200
        Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 18:48 +0200
          Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-05 03:06 +1000
            Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 19:22 +0200
              Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 15:43 -0400
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 15:17 -0400
        Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 22:24 +0200
          Re: cmd.exe on WIndows - problem with displaying some Unicode characters Akira Li <4kir4.1i@gmail.com> - 2014-08-05 04:51 +0400
            Re: cmd.exe on WIndows - problem with displaying some Unicode characters wxjmfauth@gmail.com - 2014-08-05 00:38 -0700
            Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-05 11:39 +0200
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-05 06:11 +1000
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters giacomo boffi <g@boffi.net> - 2014-08-04 22:53 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-08-04 10:46 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 02:46 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 02:53 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-08-04 12:24 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Andrew Berg <aberg010@my.hennepintech.edu> - 2014-08-04 05:33 -0500
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 11:04 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 11:15 -0700
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Grant Edwards <invalid@invalid.invalid> - 2014-08-04 19:30 +0000
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 15:25 -0400
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Tony the Tiger <tony@tiger.invalid> - 2014-08-05 20:26 +0000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Grant Edwards <invalid@invalid.invalid> - 2014-08-05 20:41 +0000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-06 00:16 +0200
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Tony the Tiger <tony@tiger.invalid> - 2014-08-06 18:27 +0000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters wxjmfauth@gmail.com - 2014-08-05 23:30 -0700

csiph-web