Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
tkinter Python变量.Get()_Python_Tkinter - Fatal编程技术网

tkinter Python变量.Get()

tkinter Python变量.Get(),python,tkinter,Python,Tkinter,当我在条目中添加一些文本并确认它时,我没有得到任何信息,就像什么都没有一样。我尝试查找它,但失败了。请有人帮助我,这可能是非常简单的事情。thx from tkinter import * win = Tk() def press(): win1 = Tk() def confirm(): text=inp.get()+" "+inp1.get() print(text) win1.destroy() inp = Stri

当我在条目中添加一些文本并确认它时,我没有得到任何信息,就像什么都没有一样。我尝试查找它,但失败了。请有人帮助我,这可能是非常简单的事情。thx

from tkinter import *

win = Tk()
def press():
    win1 = Tk()
    def confirm():
        text=inp.get()+" "+inp1.get()
        print(text)
        win1.destroy()
    inp = StringVar()
    Entry(win1, textvariable=inp).pack()
    inp1 = StringVar()
    Entry(win1, textvariable=inp1).pack()
    t_okno1 = Button(win1, text='Pridaj', command=confirm)
    t_okno1.pack()

B = Button(win, text='Pridaj Tovar', command=press)
B.pack()

除非调用
mainloop
,否则不会出现
win
窗口

B = Button(win, text='Pridaj Tovar', command=press)
B.pack()
win.mainloop()
win1
可能应该是
Toplevel
实例,而不是
Tk
,以便正确处理事件

def press():
    win1 = Toplevel()

我应该问得更好,我从打印(文本)中什么也没有得到,我的窗口会很好地弹出