Python 2.7 - ttk 模块似乎在 Windows 8.1 中不起作用 [英] Python 2.7 - ttk module seemingly not working in Windows 8.1

查看:37
本文介绍了Python 2.7 - ttk 模块似乎在 Windows 8.1 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My application's GUI is Tkinter based and it is quite functional. I have been trying to use ttk to make it look more modern. I use Python 2.7 in Windows 8.1. Importing ttk goes without error and coding including ttk in the script runs without error. However, the resulting interface looks almost same as the one done only with Tkinter. This is especially true for the buttons. I tried different ttk styles and they almost look same or some worse than Tkinter-only based interface.

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

Tkversion in my system is 8.5. I have been using ttk that comes as part of Python 2.7 itself. I attempted installing pyttk-0.3.2 from https://pypi.python.org/pypi/pyttk but its installation always fails even after several attempts.

我的问题是:

  • 是否存在 Python 2.7 的模块 ttk 在 Windows 8.1 下无法正常运行的已知问题?
  • ttk 库中是否有可能出错,即使在使用 ttk 导入或运行代码期间从未导致错误?
  • 我真的需要安装 pyttk-0.3.2 吗?
  • 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?

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

Also, can you please recommend a software (hopefully minimal - meaning not requiring to install too many external libraries) that is coded in Python 2.7 using Tkinter and ttk? This would help me as a point of reference on testing ttk in my computer.

提前致谢!

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

Updated with code and screenshot: (in response to @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'.

Seven ttk theme styles are available: 'winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative'.

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

Here is the screenshot (updated on Apr 20) for each type:

推荐答案

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

Your question doesn't mention it, but you should also have a "vista" theme available. Try using that theme. You might also try not setting the theme, and rely on the default (which I think should be "vista").

解决您的具体问题:

是否存在 Python 2.7 的模块 ttk 在 Windows 8.1 下无法正常运行的已知问题?

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

我不知道.

即使在使用 ttk 导入或运行代码期间从未导致错误的情况下,ttk 库中是否也有可能出错?

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

这极不可能,但显然有可能.

That is highly unlikely, but apparently it's possible.

我真的需要安装 pyttk-0.3.2 吗?

Do i really need to install pyttk-0.3.2?

不,你没有.

这篇关于Python 2.7 - ttk 模块似乎在 Windows 8.1 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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