title: How to use a button to call a function to display text in Tkinter
body: <p>I want to create a button which when pressed displays a message of the price_text variable in the get_btc function. I'm a GUI noob so just looking for some guidance apologies if there is already a post on this I've tried searching and haven't found a reliable answer.</p>
  <p>My current code looks like this and is split in a directory like so</p>
  <p>crypto_price--Model--scraper.py
  |
  GUI.py</p>
  <p>The contents is:</p>
  <p>Scraper.py:</p>
  <pre class="lang-py prettyprint-override"><code>from bs4 import BeautifulSoup
  import datetime
  import requests
  import time
  import lxml
  
  
  def get_btc():
  
          url = requests.get(&quot;https://uk.finance.yahoo.com/quote/BTC-GBP/&quot;)
          soup = BeautifulSoup(url.text, &quot;lxml&quot;)
          finds = soup.find_all(&quot;div&quot;, class_=&quot;D(ib) Mend(20px)&quot;)[0].find('span')
  
          for find in finds:
              price=find
              price_text= f&quot;The price of BTC at {datetime.datetime.now()} is £{price}&quot;
              print(price_text)
              time.sleep(5)
  
  
  GUI.py:
  from tkinter import *
  from Model.scraper import get_btc
  
  window = Tk()
  window.title(&quot;BTC Price&quot;)
  photo1 = PhotoImage(file=&quot;btc.png&quot;)
  Label(window, image=photo1, bg=&quot;black&quot;).grid(row=0, column=0, sticky=E)
  PriceButton = Button(text=&quot;Btc Price&quot;, command=get_btc())
  PriceButton.place(x=0, y=0)
  PriceButton.pack
  
  window.mainloop()
  </code></pre>