Textualize / textual-plotext

A Textual widget wrapper library for Plotext
MIT License
114 stars 5 forks source link

Cannot import textual_plotext: DEFAULT_COLORS does not exist. #15

Open PlasmaHH opened 3 days ago

PlasmaHH commented 3 days ago

Trying the examplem from the readme I get:

Traceback (most recent call last):
  File "/home/plasmahh/src/python/./pl.py", line 5, in <module>
    from textual_plotext import PlotextPlot
  File "/home/plasmahh/.venv/dev/lib64/python3.11/site-packages/textual_plotext/__init__.py", line 3, in <module>
    from .plot import Plot, themes
  File "/home/plasmahh/.venv/dev/lib64/python3.11/site-packages/textual_plotext/plot.py", line 21, in <module>
    from textual.app import DEFAULT_COLORS
ImportError: cannot import name 'DEFAULT_COLORS' from 'textual.app' (/home/plasmahh/.venv/dev/lib64/python3.11/site-packages/textual/app.py)

It looks like the internals of theming of textual changed...

Additionally when I re-create that DEFAULT_COLORS like it was in older versions I get some "ScatterApp object has no attribute dark" error, it seems also that the dark/light mode detection has changed.

Zaloog commented 3 days ago

Hi @PlasmaHH yes right, with the new theme system in textual it broke some of textual-plotext internals. Darren already created a PR for that. Until that is merged and a new release is created, you could reference that branch for textual-plotext installation https://github.com/Textualize/textual-plotext/tree/update-for-theme-system to already have the fixes in place

PlasmaHH commented 3 days ago

Alright. Until that is done I will keep my workaround which is like:

textual.app.DEFAULT_COLORS = {  "dark" : textual.design.ColorSystem(....) }
import textual_plotext

because I can't require people using my app to install things from git ;)