蟒蛇/ Tkinter的按钮和条目在同一窗口 [英] Python/Tkinter Button and Entry on the same window
本文介绍了蟒蛇/ Tkinter的按钮和条目在同一窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Python(2.7.5)初学者。因此,这里是一个基本的问题。
I'm a beginner in Python (2.7.5). So here is a basic question
我试图创建一个窗口既一个按钮和一些入门,但由于某种原因,这是行不通的。
如果我尝试以与仅条目或只有它的工作原理,但不与两者按钮,并在同一时间的条目。
I'm trying to create a window with both a Button and some Entry but for some reason it doesn't work. If I try to make a window with only entries or only a button it works but not with both the button and the entry at the same time.
这样的问题基本上是:如何创建一个窗口既一个按钮和一个条目
so the question is basically: How to create a window with both a button and an entry ?
下面是一些脚本:
from Tkinter import*
def super_function():
fen1.quit
fen1 = Tk()
entr = []
for i in range(10):
entr.append(Entry(fen1))
entr[i].grid(row=i)
Button(fen1,text='store everything in a list',command=fen1.quit).pack(side=BOTTOM)
fen1.mainloop()
感谢您!
推荐答案
的问题是,你正在使用包
和电网
在同一时间。相反,你应该只使用一个:
The problem is that you are using pack
and grid
at the same time. Instead, you should use only one:
from Tkinter import *
def super_function():
fen1.quit
fen1 = Tk()
entr = []
for i in xrange(10):
entr.append(Entry(fen1))
entr[i].grid(row=i)
# Use grid instead of pack here
Button(fen1,text='store everything in a list',command=super_function).grid()
fen1.mainloop()
这篇关于蟒蛇/ Tkinter的按钮和条目在同一窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文