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


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to