Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I embed IPython shell into a Python program which uses curses module?
    primarykey
    data
    text
    <p>I'm trying to drop into IPython shell when I press 'i' in my curses program. Upto this point, I set up a curses windows and several other windows. I can interact with the program using a while loop and act upon keystrokes.</p> <p>From <a href="http://heim.ifi.uio.no/~inf3330/scripting/doc/python/ipython/node9.html" rel="nofollow">Embedding IPython</a> I borrowed some code which you can see at the beginning and at the end of the block.</p> <pre><code>... from IPython.Shell import IPShellEmbed ipshell = IPShellEmbed() ... def main(): stdscr = curses.initscr() (win_maxy, win_maxx) = stdscr.getmaxyx() onethirds_win_width = int(math.floor(win_maxx/3)) half_win_heigth = int(math.floor(win_maxy/2)) begin_x = 0; begin_y = 0 height = half_win_heigth ; width = onethirds_win_width download_win = curses.newwin(height, width, begin_y, begin_x) download_win.border() download_win.refresh() download_list_win = download_win.subwin(height-2, width-2, begin_y+1, begin_x+1) begin_x = (half_win_heigth-1)+2 ; begin_y = 0 height = half_win_heigth ; width = onethirds_win_width configs_win = curses.newwin(height, width, begin_y, begin_x) configs_win.border() configs_win.refresh() configs_list_win = configs_win.subwin(height-2, width-2, begin_y+1, begin_x+1) begin_x = 0 ; begin_y = win_maxy-1 height = 1 ; width = win_maxx status_win = curses.newwin(height, width, begin_y, begin_x) begin_x = 0 ; begin_y = half_win_heigth+2 height = 1 ; width = win_maxx input_win = curses.newwin(height, width, begin_y, begin_x) input_win_textbox = curses.textpad.Textbox(input_win) #curses.textpad.rectangle(stdscr, begin_y, begin_x, begin_y+height+1, begin_x+width+1) curses.noecho() curses.cbreak() stdscr.keypad(1) stdscr.addstr(half_win_heigth+5, 5, "MCP Fetcher. Ready.") stdscr.refresh() while 1: c = stdscr.getch() download_win.border() if c == ord('q'): break # Exit the while() elif c == ord('c'): stdscr.clear() # Clear the screen elif c == ord('i'): curses.nocbreak(); stdscr.keypad(0); curses.echo() ipshell() # Start the ipython shell curses.noecho(); curses.cbreak(); stdscr.keypad(1) </code></pre> <p>...</p> <p>and the code continues.</p> <p>The problem is the IPython shell does not have echo, no cbreak and etc. How can I solve this?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload