title: R: Change icon of Tcltk window in Mac and Linux
body: <p>I have created a progress bar to keep tabs on the execution of some R scripts. And I want to insert a custom icon in the bar instead of the default 'Tk' one. I am able to do this on Windows using a .ico file and the following command</p>
  
  <pre><code>tcl('wm', 'iconbitmap', .win, 'Icon.ico')
  </code></pre>
  
  <p>But I am a loss about how to do the same in Mac OSX and Linux. Obviously, the .ico format doesn't work but neither does .png, .jpg, .bmp, .xbm or .xpm. Any suggestion on how I could proceed? Sample image and progress bar code attached below:-</p>
  
  <p><a href="http://tinypic.com/r/jt8efn/6" rel="nofollow noreferrer">Sample image http://tinypic.com/r/jt8efn/6</a> - <a href="http://tinypic.com/r/jt8efn/6" rel="nofollow noreferrer">http://tinypic.com/r/jt8efn/6</a></p>
  
  <pre><code>tkProgressBar2 &lt;- function (title = 'Test progress bar', label = '', min = 0, max = 100, initial = 0, width = 300, userfn='helvetica', backg='white') {
    useText &lt;- FALSE
    have_ttk &lt;- as.character(tcl('info', 'tclversion')) &gt;= '8.5'
    if (!have_ttk &amp;&amp; as.character(tclRequire('PBar')) == 'FALSE') useText &lt;- TRUE
    .win &lt;&lt;- tktoplevel(background=backg)
    tkfocus()
    tcl('wm', 'geometry', .win, '500x100+450+350')
    tcl('wm', 'iconbitmap', .win, '@Icon.xbm')
    .val &lt;- initial
    .killed &lt;- FALSE
    tkwm.geometry(.win, sprintf('%dx80', width + 40))
    tkwm.title(.win, title)
    fn &lt;- tkfont.create(family = userfn, size = 12)
    if (useText) {
      .lab &lt;- tklabel(.win, text = label, font = fn, padx = 0, background=backg)
      tkpack(.lab, side = 'left')
      fn2 &lt;- tkfont.create(family = userfn, size = 16)
      .vlab &lt;- tklabel(.win, text = '0%', font = fn2, padx = 20, background=backg)
      tkpack(.vlab, side = 'right')
      up &lt;- function(value) {
        if (!is.finite(value) || value &lt; min || value &gt; max) return()
        .val &lt;&lt;- value
        tkconfigure(.vlab, text = sprintf('%d%%', round(100 * (value - min)/(max - min))))
      }
    } else {
      .lab &lt;- tklabel(.win, text = label, font = fn, pady = 0, background=backg)
      .tkval &lt;- tclVar(0)
      tkpack(.lab, side = 'top')
      tkpack(tklabel(.win, text = '', font = fn, background=backg), side = 'bottom')
      pBar &lt;- if (have_ttk)
        ttkprogressbar(.win, length = width, variable = .tkval) else
          tkwidget(.win, 'ProgressBar', width = width, variable = .tkval)
      tkpack(pBar, side = 'bottom')
      up &lt;- function(value) {
        if (!is.finite(value) || value &lt; min || value &gt; max) return()
        .val &lt;&lt;- value
        tclvalue(.tkval) &lt;&lt;- 100 * (value - min)/(max - min)
      }
    }
    getVal &lt;- function() .val
    kill &lt;- function() if (!.killed) {
      tkdestroy(.win)
      .killed &lt;&lt;- TRUE
    }
    title &lt;- function(title) tkwm.title(.win, title)
    lab &lt;- function(label) tkconfigure(.lab, text = label)
    tkbind(.win, '&lt;Destroy&gt;', function() stop())
    up(initial)
    structure(list(getVal = getVal, up = up, title = title, label = lab, kill = kill), class = 'tkProgressBar')
  }
  
  pb &lt;- tkProgressBar2(title='Performing k-Means clustering', label='Some information in %', min=0, max=100, initial=0, width=400, userfn='verdana', backg='white')
  </code></pre>