在tkinter中使用函数时未保存用户输入

时间:2016-12-12 18:48:21

标签: python function input tkinter

我正在调用函数中的函数来尝试打印用户输入的输入。当我调用ultra()函数时它工作并成功打印用户输入,但是当我调用package()函数时,它调用了其中的ultra函数,它打印为空白并且不起作用。我做错了什么?

    from tkinter import *
    import tkinter

    def package():
        global IDVar
        window=tkinter.Tk()
        window.title('Lightning Parties')

        lbl_package=tkinter.Label(window, text='Please click on the Package you would like!', fg='white', bg='purple', font=('comicsans', 10))
        lbl_package.pack()

        lbl=tkinter.Button(window, text='Ultra',command=ultra)
        lbl.pack()

     def ultra():
        import tkinter
        global IDVar
        win = Tk()
        win.wm_title("Lightning Parties Validating")
        frame1=Frame(win)
        frame1.pack()
        Label(frame1, text="Lightning Parties - Validating", font=("Helvetica 12 bold")).grid(row=0, column=0)
        Label(frame1, text="ID").grid(row=1, column=0, sticky=W)
        IDVar=StringVar()
        title= Entry(frame1, textvariable=IDVar)
        title.grid(row=1,column=1,sticky=W)
        frame2 = Frame(win)
        frame2.pack()
        b1= Button(frame2, text="continue ", command=save)
        b1.grid(column=1, row=2, sticky=W)
        def save():
            global ID
            ID = IDVar.get()
            print ('here is', ID)    


    package()

1 个答案:

答案 0 :(得分:0)

您无法创建var checkboxQueryString; $form.find ("input[type=\"checkbox\"]:not( \":checked\")" ).each(function( i, e ) { checkboxQueryString += "&" + $( e ).attr( "name" ) + "=N" }); 的多个实例。如果您需要多个窗口,请创建Tk

的实例