Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fgcolor and bgcolor does not seem to work #11

Open
bluecmd opened this issue Aug 29, 2024 · 2 comments
Open

fgcolor and bgcolor does not seem to work #11

bluecmd opened this issue Aug 29, 2024 · 2 comments

Comments

@bluecmd
Copy link

bluecmd commented Aug 29, 2024

Using the example from the README:

from ansitable import ANSITable, Column, Cell

table = ANSITable("col1", "column 2 has a big header", "column 3")
table.row("aaaaaaaaa", 2.2, 3)
table.row("bbbbbbbbbbbbb", Cell(-5.5, bgcolor="blue"), 6, bgcolor="yellow")
table.row("ccccccc", 8.8, 9)
table.print()

Results in the following using the current master of ansitable:

[fedora]$ python3 test.py
Traceback (most recent call last):
  File "/home/bluecmd/work/linkinsane/test.py", line 7, in <module>
    table.print()
  File "/home/bluecmd/work/linkinsane/ansitable/table.py", line 828, in print
    print(str(self), file=file)
          ^^^^^^^^^
  File "/home/bluecmd/work/linkinsane/ansitable/table.py", line 870, in __str__
    text += self._row(i)  # add a row
            ^^^^^^^^^^^^
  File "/home/bluecmd/work/linkinsane/ansitable/table.py", line 788, in _row
    text += c._formatcolumn(
            ^^^^^^^^^^^^^^^^
  File "/home/bluecmd/work/linkinsane/ansitable/table.py", line 266, in _formatcolumn
    text = self.table.BG(bgcolor) + text + self.table.BG(0)
           ^^^^^^^^^^^^^
AttributeError: 'ANSITable' object has no attribute 'BG'. Did you mean: '_BG'?

It is the same issue with using fgcolor, with the error being that no attribute named FG exists.

@petercorke
Copy link
Owner

OK, I think this might be an issue with the package colored which might not be up to date. I am using v2.2.4 and there were breaking changes between v1 and v2, that got fixed in later minor releases of v2. For that reason I didn't put a version dependency in the build file, perhaps I should have.

Your example gives me:

image

@petercorke
Copy link
Owner

Fixed a bug that likely impacts on Cell(). Give it a go now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants