Code Monkey home page Code Monkey logo

Comments (2)

RedFantom avatar RedFantom commented on June 22, 2024

Thank you for opening this issue!

As far as I understand it, the code is not at fault, exactly, but there may be some unclarity. The only way I could find to reproduce your issue is to insert an item in the following manner, modified from example_checkboxtreeview.py:

tree = CheckboxTreeview(root)
tree.pack()

tree.insert("", "end", "1", text="1", tags=("hello","world"))
tree.insert("1", "end", "11", text="11", tags=("hello"))

This produces the error on Python 3.8:

Traceback (most recent call last):
  File "/home/user/Source/ttkwidgets/examples/example_checkboxtreeview.py", line 15, in <module>
    tree.insert("1", "end", "11", text="11", tags="hello")
  File "/home/user/Source/ttkwidgets/ttkwidgets/checkboxtreeview.py", line 172, in insert
    kw["tags"] += (tag,)
TypeError: can only concatenate str (not "tuple") to str

However, I think that the way Python handles the declaration of tuples is the cause of the confusion here. ("hello") is not a tuple, it is a string:

>>> ("hello")
'hello'

whereas ("hello",) is a tuple:

>>> ("hello",)
('hello',)

This is so that string declarations can be made to easily span multiple lines in Python by wrapping them in parentheses.

Therefore, the argument to tags should always be wrapped in parentheses and, if it contains only a single element, the element must be followed by a comma.

If this is not what you are seeing, please let me know, because then it could be a proper bug that needs to be fixed. Of course, without seeing the whole code, I cannot determine with certainty that this is the cause of the confusion, but it is my best guess. I hope this helps you!

from ttkwidgets.

WinEunuuchs2Unix avatar WinEunuuchs2Unix commented on June 22, 2024

Indeed I was sloppy and was not declaring a tuple by appending , after a single string tuple. Sorry for newbie question. Thank you for the great answer!

from ttkwidgets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.