From: Florent R. <f.r...@fr...> - 2015-11-27 15:06:31
|
Hi Paraic, Paraic OCeallaigh <par...@gm...> wrote: > Thank you for a very comprehensive answer. I have figured out the use > of programbox and I am very pleased with the results. Instead of > filling the "args" option with specific commands I wrote a bash script > and inserted that into the args and it outputs nicely into programbox > with a few 'sleep' commands to make it readable. Glad to see you managed to come up with something that works for you. > One question I had was, there is an option to use colors > ("--enable-colors") but I am unsure how to use it. Is there a chance > to use it to format the output being displayed to programbox, if I > wanted to put a certain color on one part of the text? I tried tput in > the bash script and it just outputs the escape codes and doesn't add > any color. Where did you find --enable-colors? I only have --colors here. Is it a typo? It seems this option doesn't work with the programbox widget in dialog. It does work with msgbox (in this particular case, but see below): dialog --colors --msgbox 'abc\Zb\Z1def\Znghi' 0 0 It also works in pythondialog: msg = r"Excellent! Press \Zb\Z1OK\Zn to see..." d.msgbox(msg, colors=True) but it doesn't seem to work with programbox. Actually, it does for the optional title but not for the piped output: echo 'abc\Zb\Z1def\Znghi' | \ dialog --colors --programbox 'ABC\Zb\Z1DEF\ZnGHI' 0 0 *but* if I change the text to include spaces, as in: dialog --colors --msgbox 'Optional aaa\Zb\Z1title\Zn...' 0 0 or: echo 'abc\Zb\Z1def\Znghi' | \ dialog --colors --programbox 'Optional aaa\Zb\Z1title\Zn...' 0 0 then I obtain something like this: Optio aaatitle (where 'title' is in bold red, OK) I just took the \Z* sequences from dialog(1), so maybe it is simply that I don't understand the "grammar" of these escape sequences. Maybe you can explain this? I don't know if these sequences correspond to a well-known standard. They don't look like ANSI escape sequences at least... Maybe their interpretation by dialog is buggy? I suggest you to discuss this with Thomas Dickey, the dialog maintainer (<http://invisible-island.net/dialog/dialog.html>). > P.S os.system is gone now from my script! thanks for that.. :) Good. :) Since you said you were beginning with Python, I also wanted to point you to the textwrap module which you may find helpful. Example: textwrap.fill(longString, width=79) This may be useful if you have long lines that are truncated in the output of programs you monitor. Although pretty simple to implement oneself, textwrap.indent() is also very convenient for nice text formatting. I also wanted to say that if you don't want to bother with progressbox or programbox in the middle of a pythondialog-based program and don't care about visual unity, you can just print to the terminal between dialog calls. If you want the program to wait for the user to press Enter before proceeding to the next dialog, you can use 'input("Press Enter to continue...")' (the function was named 'raw_input()' in Python 2). Regards -- Florent |