tkinter doesn't open image via function

后端 未结 2 1497
孤城傲影
孤城傲影 2021-01-26 07:35

Tkinter doesn\'t open the image. We can ask the opening incorrectly, we need help. I need it to open the image through the menu. be sure to use pil, as the image can be anything

2条回答
  •  梦谈多话
    2021-01-26 08:25

    If I am not mistaken, your menu opens as soon as you run the application, not when you click the import button.

    It's because you need to pass the callback to the add_command, but you're calling the method instead

    file_menu.add_command(label = "Import...", command=input_file())
    

    Remove the () from input_file(). just pass input_file. it will not call the method directly anymore.

    file_menu.add_command(label = "Import...", command=input_file)
    

提交回复
热议问题