Python 2.7 - ttk module seemingly not working in Windows 8.1

冷暖自知 提交于 2019-12-10 09:39:33

问题


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 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.

My questions are these:

  • 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?

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.

Thanks in advance!

Updated with code and screenshot: (in response to @Bryan Oakley)

Here is the code I use:

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()

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

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


回答1:


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").

To address your specific questions:

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

Not that I am aware of.

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.

Do i really need to install pyttk-0.3.2?

No, you don't.



来源:https://stackoverflow.com/questions/29690484/python-2-7-ttk-module-seemingly-not-working-in-windows-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!