+ 1

def python

hi please explain more about this codes i cant understand them # print any char or string in x&y of screen with selected color def print_in_xy(self, x, y, char, color): print("%c[%d;%df" % (0x1B, x, y), end=self.styles[color] + char + self.styles["ENDC"]) # print any char or string in x&y of screen with selected color # same function but after printing secnd char first char will deleted # Or you can implement this function inside "print_in_xy" with any boolean def print_in_xy_with_clean(self, x, y, char, color): print("%c[%d;%df" % (0x1B, x, y), self.styles[color] + char + self.styles["ENDC"], end='')

24th Jun 2020, 3:04 PM
nima rasi
1 Answer
0
As far as I see, both functions print a char or string (parameter "char") on a console which accepts ANSI escape sequences. In fact the "char" is preceded by a positioning sequence "ESC [ x;y f", where x and y is the desired position, and included between two other sequences to set and reset its color. The second function prepend a space to the coloured "char": this is the effect of printing comma-separated stuff. Obviously you need ANSI support for this to work.
25th Jun 2020, 3:54 AM
Bilbo Baggins
Bilbo Baggins - avatar