gpt4 book ai didi

Python 2.7 - ttk 模块似乎无法在 Windows 8.1 中运行

转载 作者:行者123 更新时间:2023-11-28 18:38:43 25 4
gpt4 key购买 nike

我的应用程序的 GUI 是基于 Tkinter 的,它非常实用。我一直在尝试使用 ttk 使其看起来更现代。我在 Windows 8.1 中使用 Python 2.7。导入 ttk 没有错误,脚本中包含 ttk 的编码也没有错误。然而,生成的界面看起来几乎与仅使用 Tkinter 完成的界面相同。按钮尤其如此。我尝试了不同的 ttk 样式,它们看起来与仅基于 Tkinter 的界面几乎相同或更差。

我系统中的 Tkversion 是 8.5。我一直在使用作为 Python 2.7 本身一部分的 ttk。我尝试从 https://pypi.python.org/pypi/pyttk 安装 pyttk-0.3.2但即使经过多次尝试,它的安装总是失败。

我的问题是:

  • 是否存在 Python 2.7 模块 ttk 在 Windows 8.1 下运行不佳的已知问题?
  • ttk 库中是否有可能出错,即使它在使用 ttk 导入或运行代码时从未导致错误?
  • 我真的需要安装 pyttk-0.3.2 吗?

此外,您能否推荐一个使用 Tkinter 和 ttk 在 Python 2.7 中编码的软件(希望是最小的——意味着不需要安装太多外部库)?这将有助于我作为在我的计算机中测试 ttk 的引用点。

提前致谢!

更新了代码和截图:(回应@Bryan Oakley)

这是我使用的代码:

from Tkinter import *
import ttk

root = Tk()
root.geometry("")
root.title("classic")

button_1 = Button(root, text='Tkinter')
button_1.grid(row=0, column=0, padx=10, pady=10)

button_2 = ttk.Button(root, text='ttk')
button_2.grid(row=0, column=1, padx=10, pady=10)

style = ttk.Style()
style.theme_use('classic')

root.mainloop()

有七种 ttk 主题样式可用:'winnative'、'clam'、'alt'、'default'、'classic'、'vista'、'xpnative'

这是每种类型的屏幕截图(更新于 4 月 20 日):

Themes- Screenshot

最佳答案

你的问题没有提到它,但你也应该有一个“vista”主题可用。尝试使用该主题。您也可以尝试设置主题,并依赖默认设置(我认为应该是“vista”)。

解决您的具体问题:

Is there a known problem of Python 2.7's module ttk not playing nice under Windows 8.1?

据我所知不是。

Is there a possibility of error in ttk libraries even though it never results in error during import or running code with ttk?

这不太可能,但显然有可能。

Do i really need to install pyttk-0.3.2?

不,你不知道。

关于Python 2.7 - ttk 模块似乎无法在 Windows 8.1 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29690484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com