[New-bugs-announce] [issue17397] ttk::themes missing form ttk.py

klappnase report at bugs.python.org
Mon Mar 11 13:43:17 CET 2013


New submission from klappnase:

When trying to load third-party themes ttk.Style.theme_names() fails to list available themes. For example if the themes from the tile-themes project are installed one can do:

>>> from tkinter import *
>>> from tkinter import ttk
>>> root=Tk()
>>> s=ttk.Style()
>>> s.theme_names()
('clam', 'alt', 'default', 'classic')
>>> root.tk.call('ttk::themes')
('classic', 'default', 'clam', 'alt')
>>> root.tk.call('package', 'require', 'tile-themes')
'0.6'
>>> s.theme_names()
('clam', 'alt', 'default', 'classic')
>>> root.tk.call('ttk::themes')
('keramik', 'plastik', 'clam', 'winxpblue', 'alt', 'Aquativo', 'classic', 'default', 'keramik_alt')
>>> 

This has been discussed in more detail at tkinter-discuss:
http://code.activestate.com/lists/python-tkinter-discuss/3373/

As ttk::themes is described as being part of the Public API inside ttk.tcl and is also documented in the tcl wiki at http://wiki.tcl.tk/14796 resp. http://wiki.tcl.tk/23676 it appears safe to add it to ttk.py.

Considering this I prepared a patch (against b10a9d4f08eb) that adds the following method to ttk.Style():

    def themes(self, pattern=None):
        '''Returns a list of theme names available. It can be passed an
        argument which is used as an lsearch glob pattern while looking
        for the theme names.'''
        return self.tk.splitlist(self.tk.call('ttk::themes', pattern))

----------
components: Tkinter
files: patch_ttk.diff
keywords: patch
messages: 183954
nosy: klappnase
priority: normal
severity: normal
status: open
title: ttk::themes missing form ttk.py
type: enhancement
Added file: http://bugs.python.org/file29377/patch_ttk.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17397>
_______________________________________


More information about the New-bugs-announce mailing list