GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ttk.Style.element_create using incorrect tk.call syntax · Issue #68166 · python/cpython

ttk.Style.element_create using incorrect tk.call syntax #68166

New issue
Copy link
New issue
Copy link
Closed
Closed
ttk.Style.element_create using incorrect tk.call syntax#68166
Copy link
Assignees
serhiy-storchaka
Labels
3.13only security fixesonly security fixestopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-featureA feature request or enhancementA feature request or enhancement

Description

jmorgensen
mannequin
opened on Apr 16, 2015
Issue body actions
BPO 23978
Nosy @terryjreedy, @roseman, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/serhiy-storchaka'
closed_at = None
created_at = <Date 2015-04-16.22:49:38.007>
labels = ['type-bug', 'expert-tkinter']
title = 'ttk.Style.element_create using incorrect tk.call syntax'
updated_at = <Date 2015-08-06.21:25:09.278>
user = 'https://bugs.python.org/jmorgensen'

bugs.python.org fields:

activity = <Date 2015-08-06.21:25:09.278>
actor = 'terry.reedy'
assignee = 'serhiy.storchaka'
closed = False
closed_date = None
closer = None
components = ['Tkinter']
creation = <Date 2015-04-16.22:49:38.007>
creator = 'jmorgensen'
dependencies = []
files = []
hgrepos = []
issue_num = 23978
keywords = []
message_count = 3.0
messages = ['241286', '241370', '248149']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'markroseman', 'serhiy.storchaka', 'jmorgensen']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue23978'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

Linked PRs

  • gh-68166: Add support of "vsapi" in ttk.Style.element_create() #111393
  • gh-68166: Tkinter: Add tests and examples for element_create() #111453
  • [3.12] gh-68166: Tkinter: Add tests and examples for element_create() (GH-111453) #111857
  • [3.11] gh-68166: Tkinter: Add tests and examples for element_create() (GH-111453) #111858

Activity

  1. jmorgensen commented on Apr 16, 2015

    @jmorgensen
    jmorgensenmannequin
    on Apr 16, 2015
    MannequinAuthor
    More actions

    Style.element_create passes all spec elements as a single string into tk.call rather than breaking up arguments into "words." However, it passes the options properly as a list.

    This causes python to crash with a stacktrace like the one below.

    def element_create(self, elementname, etype, *args, **kw):
    """Create a new element in the current theme of given etype."""
        spec, opts = _format_elemcreate(etype, False, *args, **kw)
        self.tk.call(self._name, "element", "create", elementname, etype,
            spec, *opts)

    And in _format_elemcreate:

        spec = "%s %s" % (iname, imagespec)
        ...
        spec = "%s %s %s" % (class_name, part_id, statemap)

    Reproduction (on win):

    >>> import ttk
    >>> Style().element_create('custom.test', 'vsapi', 'SPIN', 2)
      File "<stdin>", line 1, in <module>
      File "C:\Miniconda\lib\lib-tk\ttk.py", line 466, in element_create
        spec, *opts)
    _tkinter.TclError: missing required arguments 'class' and/or 'partId'

    and, similarly:

    >>> import ttk
    >>> ttk.Style().element_create('custom.test', 'vsapi', 'SPIN', 2, width=5)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Miniconda\lib\lib-tk\ttk.py", line 466, in element_create
        spec, *opts)
    _tkinter.TclError: expected integer but got "-width"
  2. jmorgensen
    added
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    topic-tkinter
    on Apr 16, 2015
  3. ned-deily
    removed
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    on Apr 16, 2015
  4. terryjreedy commented on Apr 17, 2015

    @terryjreedy
    terryjreedy
    on Apr 17, 2015
    Member
    More actions

    Reproduced on Win7, 3.4.3, with updated import: "from tkinter import ttk". The example should serve as a test.

  5. terryjreedy
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 17, 2015
  6. serhiy-storchaka
    self-assigned this
    on Apr 17, 2015
  7. terryjreedy commented on Aug 6, 2015

    @terryjreedy
    terryjreedy
    on Aug 6, 2015
    Member
    More actions

    This looks like it should be an easy for for someone who understands tcl.call syntax. When we add ttk to Idle, I do not expect to use element_create, but maybe someone will want to to create a custom theme.

  8. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  9. serhiy-storchaka
    added a commit that references this issue on Oct 27, 2023

    pythongh-68166: Fix support of "vsapi" in ttk.Style.element_create()

    3432df2
  10. serhiy-storchaka commented on Oct 28, 2023

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 28, 2023
    Member
    More actions

    There are two ways to create new elements in Tkinter. One is by calling the elemnt_create() methods, and the other one by calling the theme_create() or theme_settings() method and using the elemnt_create key in the settings dict. In the former case it calls the ttk:style element create command directly, in the latter case it formats a script containing the ttk:style element create command and passes it as argument to the ttk:style theme create or the ttk:style theme settings command. There are enough differences between these two paths, so I expected that at least the latter works correctly. But it turned out that both ways do not work and never worked since adding this code in the stdlib. So it makes sense to consider it as a new feature rather than a bugfix. It should be documented correspondingly, and older versions should be made to raise more explicit exception when try to use the "vsapi" factory.

    It is also an opportunity to change the Python API (which never worked) to closer match the Tk API. I.e. instead of

            style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3,
                                 ('pressed', '!selected', 3),
                                 ('active', '!selected', 2),
                                 ('pressed', 'selected', 6),
                                 ('active', 'selected', 5),
                                 ('selected', 4),
                                 ('', 1))

    it should be

            style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3, [
                                 ('pressed', '!selected', 3),
                                 ('active', '!selected', 2),
                                 ('pressed', 'selected', 6),
                                 ('active', 'selected', 5),
                                 ('selected', 4),
                                 ('', 1)])

    or

            style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3, [
                                 (('pressed', '!selected'), 3),
                                 (('active', '!selected'), 2),
                                 (('pressed', 'selected'), 6),
                                 (('active', 'selected'), 5),
                                 (('selected',), 4),
                                 ((), 1)])

    or

            style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3, {
                                 ('pressed', '!selected'): 3,
                                 ('active', '!selected'): 2,
                                 ('pressed', 'selected'): 6,
                                 ('active', 'selected'): 5,
                                 ('selected',): 4,
                                 (): 1})
  11. serhiy-storchaka
    added
    type-featureA feature request or enhancementA feature request or enhancement
    3.13only security fixesonly security fixes
    on Oct 28, 2023
  12. serhiy-storchaka
    added a commit that references this issue on Oct 29, 2023

    pythongh-68166: Tkinter: Add tests and examples for element_create()

    bcd8cf2
  13. serhiy-storchaka
    added a commit that references this issue on Nov 8, 2023

    gh-68166: Tkinter: Add tests and examples for element_create() (GH-11…

    005d1e8
  14. miss-islington
    added 2 commits that reference this issue on Nov 8, 2023

    pythongh-68166: Tkinter: Add tests and examples for element_create() (p…

    7400be7

    pythongh-68166: Tkinter: Add tests and examples for element_create() (p…

    26ad143
  15. serhiy-storchaka
    added 3 commits that reference this issue on Nov 27, 2023

    gh-68166: Add support of "vsapi" in ttk.Style.element_create() (GH-11…

    4dcfd02

    [3.11] gh-68166: Tkinter: Add tests and examples for element_create() (…

    c3e5d0d

    [3.12] gh-68166: Tkinter: Add tests and examples for element_create() (…

    1cb95cd
  16. serhiy-storchaka
    closed this as completedon Nov 28, 2023
  17. aisk
    added 2 commits that reference this issue on Feb 11, 2024

    pythongh-68166: Tkinter: Add tests and examples for element_create() (p…

    c793996

    pythongh-68166: Add support of "vsapi" in ttk.Style.element_create() (p…

    019206b
  18. Glyphack
    added 2 commits that reference this issue on Sep 2, 2024

    pythongh-68166: Tkinter: Add tests and examples for element_create() (p…

    d8a34d3

    pythongh-68166: Add support of "vsapi" in ttk.Style.element_create() (p…

    7a00ef6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

3.13only security fixesonly security fixestopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.