Error in a minimal tkSimpleDialog example

前端 未结 2 1968
情深已故
情深已故 2021-02-20 07:01

I was trying out a python code example at Rosetta Code - a programming chrestomathy site, where solutions to the same task are presented in as many different programming languag

2条回答
  •  礼貌的吻别
    2021-02-20 07:29

    The error message is telling you that the dialog needs a parent window.

    With Python 2.x, you create the root window with:

    import tkinter
    from tkinter import simpledialog
    root = tkinter.Tk()
    

    To hide the root window if you don't want it, use:

    root.withdraw()
    

    See the Python Tkinter Docs for more info.

提交回复
热议问题