[Tkinter-discuss] new ttk theme made with theme_create() doesn't inherit from parent

Pawel Mosakowski pawel at mosakowski.net
Tue Aug 18 00:13:22 CEST 2015


Hi,

When I create a new theme and set it to inherit from already existing
one, the new theme comes up empty. It has no elements and buttons
displayed with it show only label, no other layout components.

I have no idea if it's normal behaviour or something is wrong with my
setup. Maybe I'm just using it wrong. I'm running Python 3.4.3 with tk
8.6.4 on Arch Linux.

===============================================
Test program
===============================================
import tkinter as tk
import tkinter.ttk as ttk

style = ttk.Style()

print('Available themes: ', style.theme_names())

print('\nSetting theme to default')
style.theme_use('default')

print('\nDisplaying theme "{0}" elements'.format(style.theme_use()))
print(style.element_names())

print('\nCreating new theme')
style.theme_create('new_theme', parent='default')

print('\nAvailable themes: ', style.theme_names())

print('\nSetting theme to new_theme')
style.theme_use('new_theme')

print('\nDisplaying theme "{0}" elements'.format(style.theme_use()))
print(style.element_names())

=================================================
Output
=================================================
Available themes:  ('clam', 'alt', 'default', 'classic')

Setting theme to default

Displaying theme "default" elements
('label', '', 'focus', 'treearea', 'separator', 'image', 'arrow',
'downarrow', 'Menubutton.indicator', 'Treeitem.row', 'vsash', 'text',
'sizegrip', 'indicator', 'Treeheading.cell', 'leftarrow', 'border',
'Radiobutton.indicator', 'hsash', 'vseparator', 'fill', 'thumb',
'background', 'uparrow', 'hseparator', 'trough', 'rightarrow',
'Treeitem.indicator', 'slider', 'field', 'pbar',
'Checkbutton.indicator', 'textarea', 'client', 'tab', 'padding')

Creating new theme

Available themes:  ('new_theme', 'clam', 'alt', 'default', 'classic')

Setting theme to new_theme

Displaying theme "new_theme" elements
()
===================================================
Output end
===================================================

Thanks in advance,
Pawel Mosakowski


More information about the Tkinter-discuss mailing list