Function being called before being called by the GUI

0

I have software that I'm using Tkinter as a GUI, to get some parameters that the user will give me.

In this software I have 1 problem and one question.

The problem is this, as soon as I run the software, the process_files function is already running, and I wanted it to run only when I clicked the button.

and the other problem is how can I pass my variavel farm_name and one of the options selected in OptionMenu to my function process_files ?, I just tried to send as a parameter, but it does not work.

from Tkinter import *
from Tkinter import *
import Tkinter, Tkconstants, tkFileDialog

window = Tk()


def process_files():
  #logic here.


#interface
farm_variable = StringVar()
farm_label = Label(window, text='Nome: ').pack()
farm_name = Entry(window, textvariable=farm_variable).pack()

year_label = Label(window, text='Ano: ').pack()
default_value = StringVar(window)
default_value.set(2018)

OptionMenu(window, default_value, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010).pack()

button_2 = Button(window, text='Processar')
button_2.bind("<Button-2>", process_files())
button_2.pack(side=RIGHT)


window.mainloop()
    
asked by anonymous 14.06.2018 / 03:09

0 answers