Python ttk.Button -command, runs without button being pressed

Posted by Markus Kothe on Stack Overflow See other posts from Stack Overflow or by Markus Kothe
Published on 2010-06-01T06:58:57Z Indexed on 2010/06/01 7:03 UTC
Read the original article Hit count: 526

Filed under:
|
|
|

I'm making a small script in python with ttk and I have a problem where a function runs where it shouldn't. The button code looks as follows:

btReload = ttk.Button(treeBottomUI, text="Reload", width=17, command=loadModelTree(treeModel))
btReload.pack(side="left")

and the function is as this:

def loadModelTree(tree):
    print ("Loading models...")
    allModels = os.listdir(confModPath)
    for chunk in allModels:
        ...

For some reason, the function runs without the button being pressed. Why?

© Stack Overflow or respective owner

Related posts about python

Related posts about function