Python中Tkinter的问题 [英] Problems with Tkinter in Python

查看:107
本文介绍了Python中Tkinter的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

topFrame=Frame(root)
topFrame.pack()
bottomFrame=Frame(root)
bottomFrame.pack(side=BOTTOM)

one=Label(root, text="one", bg="black", fg="white")
two=Label(root, text="Two", bg="white", fg="black")
three=Label(root, text="three", fg="purple", bg="green")
one.pack()
two.pack(fill=X)
three.pack(side=LEFT, fill=Y

button1=Button(topFrame, text="Button1", fg="red")
button2=Button(topFrame, text="Button2", fg="green")
button3=Button(topFrame, text="Button3", fg="blue")
button4=Button(bottomFrame, text="Button4", fg="purple")


button1.pack(side=LEFT)
button2.pack(side=LEFT)
button3.pack(side=LEFT)
button4.pack(side=BOTTOM)



root.mainloop()





为什么第13行会出错,语法无效?

第13行是:



Why does line 13 give an error, "Invalid Syntax"?
Line 13 is:

button1=Button(topFrame, text="Button1", fg="red")

推荐答案

因为第11行不完整:

Because line 11 is incomplete:
three.pack(side=LEFT, fill=Y



它需要一个右括号。


It needs a closing parenthesis.


这篇关于Python中Tkinter的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆