Python 3.2 中的新手 GUI 问题
我是编程新手,我使用 Python 3.2。
我已经开始制作一个非常简单的 GUI 程序(添加了几个标签和按钮)。 我有几个问题:
如何向包含小部件的窗口添加背景?
如何让程序在按下一个按钮时退出窗口?
我希望这些问题之前没有得到解答,花了几分钟在这里搜索。
感谢您抽出时间!
I am new to programming and I use Python 3.2.
I have started to make a very simple GUI program (added a couple of labels and buttons).
I have a couple of questions:
How do I add a background to the window where I have my widgets?
How do I make the program exit a window if one button is pressed?
I hope these questions haven't been answered before, spent a couple of minutes searching here.
Thanks for your time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Tkinter 不直接支持背景图像。但是,您可以做的是创建一个标签或画布小部件,将图像加载到其中,然后使用该小部件作为所有其他小部件的容器。但是,您必须自己手动处理图像的平铺或拉伸。
关于退出的问题之前已经回答过: Python: How我可以让我的 tkinter 应用程序正常退出吗? 和 关闭 tkinter 窗口?
Tkinter doesn't directly support background images. However, what you can do is create a label or canvas widget, load the image to that, and then use that widget as the container for all other widgets. You'll have to manually handle the tiling or stretching of the image yourself, however.
The question about exiting has been answered before: Python: How can I make my tkinter app exit properly? and Close a tkinter window?
如果您想要
http://www.pygtk.org
http://www.linuxjournal.com/article/6586
I suggest you to use pyGTK if you want
http://www.pygtk.org
http://www.linuxjournal.com/article/6586