Skip to content

Tkinter - _tkinter.TclError: invalid boolean operator in tag search expression #143070

@ThingamabobsCoding

Description

@ThingamabobsCoding

Bug report

Bug description:

Due to the naming convention in tkinter, which adds an prefix "!" to the widget name, there is an error dropped when using the name as a tag.
This would be easy to fix by just not adding signs that can be interpreted as logical expressions.
It would work more intuitively and I can't think of a scenario where a change in the naming convention would ruin someones day.

Thread on StackOverflow

import tkinter as tk

root = tk.Tk()
cnvs = tk.Canvas(root)
cnvs.pack()
labl = tk.Label(cnvs, text='hello world')
laid = cnvs.create_window(0,0,window=labl,anchor='nw', tags=str(labl))
tags = cnvs.gettags(laid)
cnvs.find_withtag(tags)
root.mainloop()

CPython versions tested on:

3.11

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions