Skip to content Skip to sidebar Skip to footer

Is It Possible To Print A String At A Certain Screen Position Inside Idle?

EDIT: I just discovered that it's possible to obtain a similar behaviour by using the standard library 'curses'. There are some demonstrations about how it works here and there, fo

Solution 1:

I don't know if this works on IDLE, but it does in any normal terminal:

import sys
def print_there(x, y, text):
     sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
     sys.stdout.flush()

This uses Ansi-Escape Sequences

Solution 2:

This question only has one real answer and it isn't a very good one. The method:

import sys
def print_there(x, y, text):
     sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
     sys.stdout.flush()

Isn't perfect. I'd recommend staying clear of doing things like this in the terminal. If you want to do Gui's and stuff use Pygame, Tkinter, or Django.

Solution 3:

Use Tkinter to make it perfect by select under frame and provide row and column number to display your output

Post a Comment for "Is It Possible To Print A String At A Certain Screen Position Inside Idle?"