I am struggling with styles in TKinter My main problem is that you cannot click anything in the treeview.
To test, simply press the \"Press To Test\" Button
For
Question: cannot click anything in the treeview.
Using.theme_create
disablesselected
style inTreeview
.
Click is working, you can verify this by binding a callback to the event '
def on_selected(event):
print('on_selected{}'.format(event))
t1.bind('', on_selected)
Reference:
For each widget, you can bind Python functions and methods to events. If an event matching the event description occurs in the widget, the given handler is called with an object describing the event.
You are loosing the 'selected'
style or the '!selected'
style becomes the same. Therefore no color change happens if you click at a Row.
Solution:
Set explicit a 'selected'
style for the Treeview
widget in your new theme
.
style.theme_create("fclassic", parent="alt",
settings={
'Treeview': {
'map': {
'background': [('!selected', 'blue'), ('selected', 'red')],
'foreground': [('selected', 'black')],
'font': [('selected', ("Century Gothic", 10, 'bold'))],
} # end 'map'
} # end 'Treeview'
} # end settings
)
Reference:
collect all the information on setting the colors of modern widgets
Tested with Python: 3.5 - 'TclVersion': 8.6 'TkVersion': 8.6