[issue42328] ttk style.map function incorrectly handles the default state for element options.

2020-11-11 Thread Pat Thoyts


New submission from Pat Thoyts :

When cloning a ttk style it is useful to copy an existing style and make 
changes. We can copy the configuration and layout using:

style.layout('Custom.TEntry', **style.layout('TEntry'))
style.configure('Custom.TEntry', **style.configure('TEntry))

However, doing this with style.map can result in an exception. An example of 
this occurs for any style that has a defined default state in the map eg the 
TNotebook.Tab in the clam theme:

>>> style.map('TNotebook.Tab','background')
[('selected', '#dcdad5'), ('#bab5ab',)]

However, calling Tk directly:

>>> style.tk.call(style._name,"map","TNotebook.Tab","-background")
(, '#dcdad5', , 
'#bab5ab')

The second pair is defining the default state ('') to use color #bab5ab but 
this is being mangled by the code that converts this into pythons response.

The culprit is ttk._list_from_statespec which treats the statespec with the 
empty string as None and drops it and then returns the value in place of the 
state and then puts in an empty value.

--
components: Tkinter
messages: 380798
nosy: patthoyts
priority: normal
severity: normal
status: open
title: ttk style.map function incorrectly handles the default state for element 
options.
type: behavior
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue42328>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42328] ttk style.map function incorrectly handles the default state for element options.

2020-11-11 Thread Pat Thoyts


Change by Pat Thoyts :


--
keywords: +patch
nosy: +Pat Thoyts
nosy_count: 1.0 -> 2.0
pull_requests: +22138
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23241

___
Python tracker 
<https://bugs.python.org/issue42328>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32426] Tkinter.ttk Widget does not define wich option exists to set the cursor

2020-11-12 Thread Pat Thoyts


Pat Thoyts  added the comment:

The Tk documentation for the acceptable cursor names is the cursors manual 
page. https://www.tcl.tk/man/tcl/TkCmd/cursors.htm

Tk does not provide a way to get all these names in script.

This should probably be closed.

--
nosy: +patthoyts

___
Python tracker 
<https://bugs.python.org/issue32426>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42328] ttk style.map function incorrectly handles the default state for element options.

2020-11-14 Thread Pat Thoyts


Pat Thoyts  added the comment:

So if you look at the clamTheme.tcl file you can see the definition of the map 
for the TNotebook.Tab style looks like the following:

ttk::style map TNotebook.Tab \
  -padding [list selected {6 4 6 2}] \
  -background [list selected $colors(-frame) {} $colors(-darker)] \
  -lightcolor [list selected $colors(-lighter) {} $colors(-dark)] \
  ;

The vista theme uses these too on Windows.

So calling this from script we can see the resulting empty elements in tcl:

% ttk::style map TNotebook.Tab
-lightcolor {selected #eeebe7 {} #cfcdc8} -padding {selected {6 4 6 2}} 
-background {selected #dcdad5 {} #bab5ab}

As I put in the bug, this gets mistranslated in python with the value for that 
state map element getting put into the first element.

The simplest demonstration is that the following raises an exception:

import tkinter as tk
import tkinter.ttk as ttk
style = ttk.Style()
style.theme_use('clam')
style.map('Custom.TNotebook.Tab', **style.map('TNotebook.Tab'))

--

___
Python tracker 
<https://bugs.python.org/issue42328>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27309] Visual Styles support to tk/tkinter file and message dialogs

2016-06-20 Thread Pat Thoyts

Pat Thoyts added the comment:

As explained in the SO answer, in Tk on Windows the messagebox, file open 
dialog, save as dialog and in 8.6 up the font dialog are all system standard 
dialogs. Tk gets Windows to show the common dialog or messagebox and just wraps 
the Win32 API calls. As a result these dialogs are not themed using ttk as the 
various elements are not Tk controls at all.

The theming control is therefore provided by Windows and is controlled at an 
application level by the use of an RT_MANIFST resource. This contains various 
chunk of XML and one of these is used to declare that theming may be applied by 
the Visual Styles API. The Tk executables include this bit of manifest but the 
python exe does not.

You can test this out using the attached python.exe.manifest file. To allow 
this to work you have to remove the existing RT_MANIFEST resource from the 
python executable as an embedded resource overrides a sibling manifest file. I 
find the easiest way to work with this is to open the exe in Visual Studio and 
use the resources view to change the resource in place. You can copy the 
contents of the manifest file over the existing RT_MANIFEST resource or you can 
remove the embedded resource and let the system pick up the python.exe.manifest 
file from the same folder as python.exe.

This is not dependent on Tk version. All versions of Tk since around 8.0 have 
delegated to the Win32 MessageBox and GetOpenFileName API calls. With the 
introduction of Window XP and the Visual Styles API Microsoft added this 
requirement to declare support for theming via manifests. So if you have the 
right manifest and theming is enabled on your system then Tk 8.4 and 8.3 will 
all show themed common dialogs and messageboxes.

This does not affect OS X or X Windows. On X Windows Tk provides all these 
dialogs itself and so they use Tk widgets (or ttk widgets in more recent 
versions). On OS X I believe the messagebox and common dialogs are all system 
provided but it will have its own system for controlling that.

In short, python needs to merge it this manifest with the manifest being put in 
place already. The Visual Studio 'mt' tool can do that if you want to merge 
manifests.

--
nosy: +Pat Thoyts
Added file: http://bugs.python.org/file43487/python.exe.manifest

___
Python tracker 
<http://bugs.python.org/issue27309>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com