Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.05; '"""': 0.07; 'column': 0.07; 'error:': 0.07; 'mouse': 0.07; 'tkinter': 0.07; 'url:msdn': 0.07; '(those': 0.09; 'encode': 0.09; 'framework.': 0.09; 'idea?': 0.09; 'key.': 0.09; 'screen.': 0.09; 'subject:characters': 0.09; 'api': 0.11; 'python': 0.11; 'random': 0.14; 'windows': 0.15; '6:52': 0.16; ';-)).': 0.16; 'accesses': 0.16; 'codec': 0.16; 'displaying': 0.16; 'editor,': 0.16; 'emulates': 0.16; 'menu.': 0.16; 'reedy': 0.16; 'regression': 0.16; 'reversing': 0.16; 'rewritten': 0.16; 'screen,': 0.16; 'subject:Unicode': 0.16; 'url:85)': 0.16; 'url:windows': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'trying': 0.19; 'widget': 0.19; 'written': 0.21; '>>>': 0.22; 'appears': 0.22; 'programming': 0.22; 'issue.': 0.22; 'separate': 0.22; 'print': 0.22; 'header :User-Agent:1': 0.23; '>>>': 0.24; 'documented': 0.24; 'driver': 0.24; 'subject:problem': 0.24; 'text,': 0.24; 'unicode': 0.24; 'fairly': 0.24; "i've": 0.25; '>': 0.26; 'order.': 0.26; 'recognized': 0.26; 'skip:" 30': 0.26; 'this:': 0.26; 'least': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'character': 0.29; 'characters': 0.30; 'moved': 0.30; "i'm": 0.30; 'lines': 0.31; 'apparently': 0.31; 'changed.': 0.31; 'subject:some': 0.31; 'file': 0.32; 'this.': 0.32; 'run': 0.32; 'text': 0.33; 'running': 0.33; '(most': 0.33; 'framework': 0.33; 'actual': 0.34; 'screen': 0.34; 'could': 0.34; 'subject:with': 0.35; "can't": 0.35; 'problem.': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; '14,': 0.36; 'idle': 0.36; 'version:': 0.36; 'next': 0.36; 'possible': 0.36; 'hi,': 0.36; 'received:10.0': 0.36; 'should': 0.36; 'turn': 0.37; 'url:microsoft': 0.37; 'two': 0.37; 'received:10': 0.37; 'skip:& 10': 0.38; 'problems': 0.38; 'url:library': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'track': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'skip:u 10': 0.60; '8bit%:29': 0.60; 'skip:c 50': 0.60; 'worry': 0.60; 'most': 0.60; 'received:unknown': 0.61; 'black': 0.61; 'making': 0.63; 'real': 0.63; 'production': 0.68; '8bit%:50': 0.68; 'normal.': 0.68; 'received:bluehost.com': 0.68; 'url:en-us': 0.68; 'url:v': 0.71; 'url:youtube': 0.71; '8bit%:100': 0.72; 'url:%1': 0.72; 'construction': 0.72; 'serial': 0.72; 'click': 0.77; 'url:watch': 0.77; 'restore': 0.78; 'boxes.': 0.84; 'characters,': 0.84; 'detecting': 0.84; 'exercise,': 0.84; 'fonts': 0.84; 'hugh': 0.84; 'popup': 0.84; 'them)': 0.84; '\xe2\x94\x82': 0.84; 'boxes': 0.91; 'shell,': 0.91; 'skip:\xe2 30': 0.91; 'skip:\xe2 40': 0.91; 'thing,': 0.91 X-Authority-Analysis: v=2.1 cv=LbyvtFvi c=1 sm=1 tr=0 a=bHMQH+OLnPEWGwbUEerQzQ==:117 a=bHMQH+OLnPEWGwbUEerQzQ==:17 a=cNaOj0WVAAAA:8 a=f5113yIGAAAA:8 a=tcnv99F1KMcA:10 a=NQx7NIpX_PoA:10 a=WiSE-OA02TIA:10 a=aDqhzxAoLLkA:10 a=9HSTQGAzAAAA:8 a=7j9GTTBHwvYA:10 a=foBewTYRo0cA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=9iDbn-4jx3cA:10 a=cKsnjEOsciEA:10 a=DIXMLw6YAAAA:20 a=pcK22BEDAAAA:20 a=yMhMjlubAAAA:8 a=VkWFv1cD0lblid-dZBsA:9 a=QEXdDO2ut3YA:10 a=TSbVqHtbAAAA:8 a=M-LyRjNoI-briMZ097YA:9 a=Y-JARPd6o8sxTZZr:21 a=_W_S_7VecoQA:10 Date: Mon, 04 Aug 2014 02:53:11 -0700 From: Glenn Linderman User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: cmd.exe on WIndows - problem with displaying some Unicode characters References: In-Reply-To: Content-Type: multipart/alternative; boundary="------------060202080305010509000006" X-Identified-User: {1756:box1033.bluehost.com:areliabl:nevcal.com} {sentby:smtp auth 75.141.227.179 authed with test@nevcal.com} X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 247 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407146001 news.xs4all.nl 2950 [2001:888:2000:d::a6]:46770 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75678 This is a multi-part message in MIME format. --------------060202080305010509000006 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/4/2014 1:39 AM, Terry Reedy wrote: > 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 >> | """ >> | 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 > > 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 key. > I've never used the API from Python but random console access is documented at http://msdn.microsoft.com/en-us/library/windows/desktop/ms687404%28v=vs.85%29.aspx --------------060202080305010509000006 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 8/4/2014 1:39 AM, Terry Reedy wrote:
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.

I've never used the API from Python but random console access is documented at http://msdn.microsoft.com/en-us/library/windows/desktop/ms687404%28v=vs.85%29.aspx
--------------060202080305010509000006--