python 2.7 上的 Ttk

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4190920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 14:42:50  来源:igfitidea点击:

Ttk on python 2.7

pythontkinter

提问by Eric Pauley

I just installed python 2.7 from the python website, and was surprised to find that ttk wasn't included. Did I make a mistake installing, or is ttk really not included in the standard release? Anyway, where can I get a copy of ttk to install in my python instalation.

我刚刚从 python 网站安装了 python 2.7,并惊讶地发现 ttk 不包括在内。是我安装出错了,还是标准版本中真的没有包含 ttk?无论如何,我在哪里可以获得 ttk 的副本以安装在我的 python 安装中。

Note: I also heard that the activestate release has ttk. Should I unistall and use that instead?

注意:我也听说activestate 版本有ttk。我应该卸载并使用它吗?

采纳答案by DavidJFelix

I think you mean "ttk" not "tkk"

我想你的意思是“ttk”而不是“tkk”

The following should solve your problems if this is the case:

如果是这种情况,以下内容应该可以解决您的问题:

from Tkinter import *
from ttk import *

for more about ttk and Tkinter in python2.7, reference: http://docs.python.org/library/ttk.html

有关 python2.7 中 ttk 和 Tkinter 的更多信息,请参考:http://docs.python.org/library/ttk.html

回答by Zeke

Check out this similar question on ServerFault: https://serverfault.com/questions/184544/python-2-7-and-tkinter.

在 ServerFault 上查看这个类似的问题:https://serverfault.com/questions/184544/python-2-7-and-tkinter 。

Summary is that it is disabled by default.

总结是默认情况下它是禁用的。

回答by Wi-Fi Guy

Try this with Python 2.7:

用 Python 2.7 试试这个:

from Tkinter import *
import Tkinter as ttk

It makes this example work, which wouldn't otherwise:

它使这个示例工作,否则不会:

http://www.tkdocs.com/tutorial/grid.html

http://www.tkdocs.com/tutorial/grid.html