Jdog
Jdog

Reputation: 10781

Some ttk styles not accessible from within python script

I am trying to use a ttk style for my Tkinter gui.

When I run on the command line

>>> from ttk import *
>>> print Style().theme_names()
('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')

which appears fine, as I want the vista style. However, when running a script with the following lines:

from ttk import *
print Style().theme_names()

the output is:

('clam', 'alt', 'default', 'classic')

and so when I try:

from ttk import *
Style().theme_use("vista")

I get:

File "test.py", line 2, in <module>
  Style().theme_use("vista")
File "/usr/lib/python2.7/lib-tk/ttk.py", line 534, in theme_use
  self.tk.call("ttk::setTheme", themename)
_tkinter.TclError: can't find package ttk::theme::vista

Not sure what it could be and I've not had much luck googling.

I'm running from within Console2 under cygwin if that makes any difference.

Thanks!

Upvotes: 1

Views: 4403

Answers (2)

Malik Brahimi
Malik Brahimi

Reputation: 16721

My guess is you're running Linux or Mac, as Vista is a theme that pertains only to Windows. In this regard, available themes can be used in accordance to your operating system.

Upvotes: 1

Bryan Oakley
Bryan Oakley

Reputation: 386382

Some of the ttk themes are supported on only one platform. xpnative, winnative, and vista, for example, only work on windows. The "aqua" theme only works on OSX. The others, I think, run on any platform.

If you're running via cygwin, the version of python you're running was probably configured differently at compile time so that it think it is running on linux rather than windows. Therefore, it doesn't have access to windows themes.

Upvotes: 4

Related Questions