title: How to display function output to Tkinter GUI?
body: <p>I'm a bit stuck with Tkinter. The problem is the following: I want the output of the function to be displayed on the GUI app window (please see the screenshot). What am I doing wrong and can someone please assist me in rearranging the code logic? The list of nicknames is perfectly displayed in the console though.</p>
  <p><a href="https://i.stack.imgur.com/3CKxM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3CKxM.png" alt="GUI" /></a><a href="https://i.stack.imgur.com/RD7te.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RD7te.png" alt="console output" /></a></p>
  <pre><code>import tkinter as tk
  import random
  
  window = tk.Tk()
  window.title(&quot; Magical Name Generator &quot;)
  
  window.geometry(&quot;400x400&quot;)
  
  # Functions.
  
  def name_gen():
      &quot;&quot;&quot;
      This function randomly concatenates items from
      two lists and combines them in one name.
      &quot;&quot;&quot;
      first = (&quot;ara&quot;, &quot;isil&quot;, &quot;ar&quot;, &quot;beo&quot;, &quot;boro&quot;, &quot;dene&quot;, &quot;bele&quot;, &quot;eo&quot;, \
               &quot;teo&quot;, &quot;ea&quot;, &quot;el&quot;, &quot;ele&quot;, &quot;ele&quot;, &quot;fara&quot;, &quot;fea&quot;, &quot;dea&quot;, \
               &quot;bere&quot;, &quot;feo&quot;, &quot;fan&quot;, &quot;tau&quot;)
      second = (&quot;gorn&quot;, &quot;dur&quot;, &quot;wen&quot;, &quot;orn&quot;, &quot;mir&quot;, &quot;thor&quot;, &quot;den&quot;, &quot;dred&quot;, \
                &quot;ndil&quot;, &quot;dil&quot;, &quot;wing&quot;, &quot;rond&quot;, &quot;mer&quot;, &quot;wyn&quot;, &quot;nor&quot;, &quot;gal&quot;, \
                &quot;zar&quot;, &quot;nar&quot;, &quot;mar&quot;, &quot;dorn&quot;, &quot;ron&quot;)
      first_part = random.choice(first)
      second_part = random.choice(second)
      name = (first_part + second_part)
      print(name.title())
  
  def name_plot():
      for _ in range(10):
          names = str(name_gen())
  
  def display_name():
      showup = str(name_plot())
      display_name = tk.Text(master=window, height=10, width=30)
      display_name.grid(column=0, row=5)
      display_name.insert(tk.END, showup)
  
  # Labels.
  
  label_head = tk.Label(text=&quot; Hello, Wanderer! \n Choose your name wisely. &quot;, font=(&quot;The New Roman&quot;, 25))
  label_head.grid()
  
  label_enter = tk.Label(text=&quot; Pick the one that suits you best. &quot;)
  label_enter.grid(column=0, row=1)
  
  label_output = tk.Label(text=display_name())
  label_output.grid()
  
  # Button.
  
  button_submit = tk.Button(text=&quot;Generate&quot;, bg=&quot;green&quot;, command=display_name)
  button_submit.grid(column=0, row=11)
  
  window.mainloop()
  </code></pre>