in reply to Re: GUI to dynamically show program output
in thread GUI to dynamically show program output
kcott, thank you very much!
The example really does what I need but unfortunately it doesn't show correctly the progress bar of the command. This is probably due to the fact that the textual progress bar includes a counter which is implemented by printing "\r" char (below the entire C function).
void doProgress(char* label, size_t step, size_t total) { //progress width const int pwidth = 60; //minus label len size_t width = pwidth - strlen(label); size_t pos = (step * width) / total; size_t percent = (step * 100) / total; printf("\r%s%4d/%4d [", label, step, total); int i; //fill progress bar with = for (i = 0; i < pos; i++) { printf("%c", '='); } //fill progress bar with spaces printf("% *c", width - pos + 1, ']'); printf("%3d%%", percent); fflush(stdout); }
The net result is that I get a mess displayed when I add the text to the TextView, because TextView doesn't interpret char escape sequences. I get the same result using Tk::DoCommand.
After a little bit of searching I think that I could probably solve the thing by using pseudo-ttys in Tk or even embedding Xterm(1) inside Tk !
The two examples are all in python, so I'd just ask if the same can be done with Perl Tk (maybe playing with IPC::Run module pseudo-ttys support) ?
Comments and further suggestions are always welcome!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: GUI to dynamically show program output
by kcott (Archbishop) on Feb 05, 2021 at 07:00 UTC |