Because you are passing the browsefunc
function an argument or parameter the function runs when it starts. This is because of the way that python runs the code. You can use a lambda
expression to fix this
browsebutton1 = Button(root, text="Browsefile1", command=lambda: browsefunc("TXT_file1"))