Export to GitHub

python-ttk - issue #1

Example for ttk.Style().map fails


Posted on Jun 8, 2008 by Happy Cat

What steps will reproduce the problem? 1. Enter the example given in the documentation for the ttk.Style().map method 2. 3.

What is the expected output? What do you see instead? Expected is display of a themed button with custom colours. Instead I get an error

Traceback (most recent call last):

File "C:\Python25\JimsPrograms\My Tile\ttkbutton.pyw", line 46, in <module>

background=[(('pressed', '!disabled'), 'black'), ('active', 'red')])

File "C:\Python25\lib\site-packages\ttk.py", line 362, in map

*(_format_mapdict(kw))))

TclError: State map must have an even number of elements

What version of the product are you using? On what operating system? Running the June 7 revision of the package with Python 2.5.1, tk 8.4 and tile 0.8.2

Please provide any additional information below.

Changing the statement giving the error to

style.map('C.TButton',

      foreground=[('pressed', 'blue'),('active', 'red')],

      background=[('pressed','black'), ('!disabled', 'black'),

                  ('active', 'red')])

gives the expected output but that does not match the documentation

Comment #1

Posted on Jun 8, 2008 by Quick Horse

The example at the documentation has been fixed since the map format happened. This can be seen at: http://svn.python.org/view?rev=63566&view=rev

I suggest you to update your local copy of the documentation. Thanks for reporting.

Status: Fixed

Labels:
Type-Defect Priority-Medium