<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
    Hi Vaclav,<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 11-04-16 17:18, Vaclav Petras wrote:<br>
    </div>
    <blockquote
cite="mid:CABo5uVvid+OmjMQCsx+pxVt78ibjrYXZKPyjva8ugAzMS=DFdg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">Hi, Paulo!<br>
        </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Mon, Apr 11, 2016 at 10:04 AM,
            Paulo van Breugel <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:p.vanbreugel@gmail.com" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:p.vanbreugel@gmail.com">p.vanbreugel@gmail.com</a></a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div>
                <div>
                  <div>I want to provide the output formatted in three
                    columns. I can use <br>
                    <span style="font-family:monospace,monospace"><br>
                      nlength = 20<br>
                      RES = [MAPy, vif, sqrtvif]<br>
                      print '{0[0]:{1}s} {0[1]:8.2f}
                      {0[2]:8.2f}'.format(RES, nlength)</span><br>
                    <br>
                  </div>
                  This prints nicely on the command line. However, on
                  the command output tab of the GUI, the order of the
                  printed lines is messed up.<br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Mixing of order can happen in GUI when using both
              stderr and stdout. What exactly is messed up? A minimal
              working example is probably needed here.<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Thanks for the help. The problem of mixed order of output was indeed
    because I was mixing print (stdout) and grass.info (stderr). The
    code is here: <a
href="https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.vif/"><a class="moz-txt-link-freetext" href="https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.vif/">https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.vif/</a></a>.
    <br>
    <br>
    <blockquote
cite="mid:CABo5uVvid+OmjMQCsx+pxVt78ibjrYXZKPyjva8ugAzMS=DFdg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div>
                <div><br>
                </div>
                If I use instead:<span
                  style="font-family:monospace,monospace"><br>
                </span><br>
                <span style="font-family:monospace,monospace"><span
                    style="font-family:monospace,monospace">nlength = 20<br>
                  </span>RES = [MAPy, vif, sqrtvif]<br>
                  <a moz-do-not-send="true" href="http://grass.info"
                    target="_blank">grass.info</a>('{0[0]:{1}s}
                  {0[1]:8.2f} {0[2]:8.2f}'.format(RES, nlength))</span><br>
                <br>
              </div>
              It looks good on the command output tab, but it is printed
              without the fixed width.</blockquote>
          </div>
          <br>
          <br>
        </div>
        <div class="gmail_extra">sys.stdout/print is the way. <a
            moz-do-not-send="true" href="http://grass.script.info">grass.script.info</a>
          and others are for messages, not output, and they go to stderr
          which might cause mixing of order with stdout in GUI and I
          unfortunately don't know how to avoid it.<br>
        </div>
      </div>
    </blockquote>
    <br>
    Following your pointer, I now replaced everything with print (I did
    not uploaded it yet) and now the columns display correctly on the
    console and in the command output tab of the addon GUI. Minor issue
    is that in the command output tab, empty lines are not printed. <br>
    <br>
    The script  runs a loop, each time printing out a line with output.
    What I noticed is that if I use print, in the command output tab the
    output is all printed at once, while in the console, the output is
    printed one line at a time. Not really a problem, but I liked that
    the output is printed line by line, as that provides a sense of
    progress. <br>
    <br>
    Cheers,<br>
    <br>
    Paulo<br>
  </body>
</html>