Author Topic: Curses, python and windows - riddle?  (Read 7570 times)

Avagart

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 567
  • Karma: +0/-0
    • View Profile
Curses, python and windows - riddle?
« on: April 28, 2015, 01:36:43 AM »
I would like to share some thoughts...

Some days ago I wanted to made 100% terminal (as TUI, not CLI) app for Windows (break from libtcod ;) ). I'm programming in python for 4 years so I decided to do it in python.

I read more than I would like to read about the problems with TUI application programmed in python under Windows. Especially about curses module. I didn't want to use pseudoconsole or emulated terminal as in wcurses. I tried a lot things - from simple libraries as termcolor and colorama, to more complex tools (ipython, click, docopt). Some had small capabilities, some had bad documentation and some just did not fit me.

I could probably achieve the desired result with combination a few simple tools and native python's libraries, but it could be screwed up.

I decided to try something what was advised against from everybody. Just use standard curses compiled under windows. Works perfect. Or... or almost perfectly. I didn't notice any issues, bugs or anything what can bother me. However, there is one problem. I cannot run scripts using curses in pycharm. New application will not start. Even simplest curses code what should be run with pycharm's built-in terminal doesn't work. Ok, there is problem, because this makes debugging more difficult.

But as I say earlier, standard curses works under windows without problems.

I thought why I have seen no such this type answer to the question 'curses, python and windows'. Wherever I was looking for advice I read: 'curses under windows? unfortunately, it's impossible'. Or 'just use wcurses'.
And... There is interesting.

Maybe curses support under python builds for windows is fixed now and those answers are out of date?

mushroom patch

  • Rogueliker
  • ***
  • Posts: 554
  • Karma: +0/-0
    • View Profile
Re: Curses, python and windows - riddle?
« Reply #1 on: April 30, 2015, 11:39:15 PM »
Hm, interesting. Could you say a little more about your build environment?

jlund3

  • Newcomer
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Re: Curses, python and windows - riddle?
« Reply #2 on: May 01, 2015, 03:16:03 AM »
I cannot run scripts using curses in pycharm. New application will not start. Even simplest curses code what should be run with pycharm's built-in terminal doesn't work. Ok, there is problem, because this makes debugging more difficult.

But as I say earlier, standard curses works under windows without problems.

Probably what this means is that the terminal emulator baked into PyCharm doesn't not support all of the escape sequences that curses uses, while whatever terminal emulator you are using outside of PyCharm does. If this is the case, unfortunately there isn't a whole lot you can do about it.

Avagart

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 567
  • Karma: +0/-0
    • View Profile
Re: Curses, python and windows - riddle?
« Reply #3 on: May 29, 2015, 11:18:34 PM »
I was absent for a little time - sorry for missing responses.

@mooshroom_path: I don't know what *exacly* you need to know, but first what i mind: PyCharm CE 3.1.1. JRE 1.7.0_40-b43 x86.

@jlund3: I think that's is more than possible, but... There wasn't a crux. Information about inoperative pycharm's terminal was side-case of my quest. That was I wanted to convey, there is:

Internet (stackoverflow etcetera) says that is impossible to work with standard curses under windows. Need to use sort of 'emulator of curses' for windows (like w_curses), or work under linux. But - surprisingly - I have windows and work with curses without bigger problems. I'm using Notepad++ (I prefer this than Vim; maybe it's less 'professional', but a lot more intuitive and user-friendly) and execute scripts by windows terminal. Works great.
Next thing. Supposedly curses are problematic because they are not portable. There is few terinal types and code working good in one terminal does not have to work on another terminal. False! ...or dunno. Maybe it's by my code, but I tested my app on several windows and linux terminal and it worked without errors. There, my curses-based program is 'cross-terminal' ;)