I want to make a menu-driven program for elementary database management.
So, please provide me some idea on how to use alternative of gotoxy in python with the help of below example.
I have C code which draws a vertical & a horizontal line in the center of screen as below:
JavaScript
x
18
18
1
#include<stdio.h>
2
#define HLINE for(i=0;i<79;i++)
3
printf("%c",196);
4
#define VLINE(X,Y) {
5
gotoxy(X,Y);
6
printf("%c",196);
7
}
8
int main()
9
{
10
int i,j;
11
clrscr();
12
gotoxy(1,12);
13
HLINE
14
for(y=1;y<25;y++)
15
VLINE(39,y)
16
return 0;
17
}
18
Is there something like gotoxy()
in Python too?
Advertisement
Answer
First, there’s no such thing as gotoxy
or clrscr
in standard C. You’re using a platform-specific library which provides them. The solution is the same for Python: use a library. One library that supports a vast number of terminals and is part of the Python distribution is curses
. See http://docs.python.org/2/library/curses.html for the documentation.