python - Tkinter does not run the function -


i'm trying make use tkinter. when running program, pop button should appear. after pressing button, code executed , site parsed. parsing working ok, tkinter not. besides, code executed before button pressed. grateful if point mistake made.

from lxml import html import requests bs4 import beautifulsoup  def news():     page = requests.get('http://www.globo.com/index.html')      soup = beautifulsoup(page.content, 'html.parser')     bbb = soup.find_all('p', class_='hui-premium__title')     item in bbb:         ccc = item.get_text('p')         print(ccc)   tkinter import * master = tk()  b = button(master, text="latest news", command='news()') b.pack()  mainloop() 

the command attribute must given callable function, not string.

for example:

b = button(..., command=news) 

Comments