Every bit of documentation I’ve found suggests that this should work, but the cursor position doesn’t return to 0,0.
JavaScript
x
20
20
1
colorama.init()
2
3
def move (y, x):
4
print("33[%d;%dH" % (y, x))
5
6
for file in original_file:
7
for element in root.iter():
8
all_lines = all_lines+1
9
if element.text != None:
10
if element.tag in field_list:
11
if len(element.text) > field_list[element.tag]:
12
corrected_lines = corrected_lines+1
13
move(0, 0)
14
working_message(username, window_width)
15
print("{3}: {0} n {1} to {2}n---".format(element.tag, len(element.text), field_list[element.tag], corrected_lines))
16
print(corrected_lines)
17
print(all_lines)
18
19
element.text = element.text[field_list[element.tag]]
20
The important bits being that colorama is initialized, then every loop the cursor should be moved to 0,0 using the move(0,0) function (passing as string of “33[0;0H” to print).
Advertisement
Answer
The top left of the screen is at coordinate 1,1 not 0,0. So your call should be
JavaScript
1
2
1
move(1,1)
2
And your print()
call should look like this:
JavaScript
1
2
1
print("33[%d;%dH" % (y, x), end="")
2
Without that, move(1,1)
will call print()
which will issue the escape code to send the cursor to the desired coordinate and then immediately issue a carriage return/line feed. That will turn your move(1,1)
effectively into move(1,2)
.