docstr: Write a string into the console.
  
  If scrollToBottom is 'auto', then the console is automatically scrolled
  to fit the new text only if it was already at the bottom.
docstr_tok: ["Write","a","string","into","the","console",".","If","scrollToBottom","is","'auto","'",",","then","the","console","is","automatically","scrolled","to","fit","the","new","text","only","if","it","was","already","at","the","bottom","."]
code: def write(self, strn, style="output", scrollToBottom="auto"):
      """Write a string into the console.
  
      If scrollToBottom is 'auto', then the console is automatically scrolled
      to fit the new text only if it was already at the bottom.
      """
      isGuiThread = (
          QtCore.QThread.currentThread()
          == QtCore.QCoreApplication.instance().thread()
      )
      if not isGuiThread:
          sys.__stdout__.write(strn)
          return
  
      cursor = self.output.textCursor()
      cursor.movePosition(QtGui.QTextCursor.MoveOperation.End)
      self.output.setTextCursor(cursor)
  
      sb = self.output.verticalScrollBar()
      scroll = sb.value()
      if scrollToBottom == "auto":
          atBottom = scroll == sb.maximum()
          scrollToBottom = atBottom
  
      row = cursor.blockNumber()
      if style == "command":
          self._lastCommandRow = row
  
      if style == "output" and row == self._lastCommandRow + 1:
          # adjust style for first line of output
          firstLine, endl, strn = strn.partition("\n")
          self._setTextStyle("output_first_line")
          self.output.insertPlainText(firstLine + endl)
  
      if len(strn) > 0:
          self._setTextStyle(style)
          self.output.insertPlainText(strn)
          # return to output style immediately to avoid seeing an extra line of command style
          if style != "output":
              self._setTextStyle("output")
  
      if scrollToBottom:
          sb.setValue(sb.maximum())
      else:
          sb.setValue(scroll)
  
imports: import code, sys, traceback
  from ..Qt import QtWidgets, QtGui, QtCore
  from ..functions import mkBrush
  from .CmdInput import CmdInput
label_desc: Use image node_id 4 for calling the ReplWidget obj's underlying member method code with example usage: obj.write(strn, style, scrollToBottom) without return types