bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.16k stars 53 forks source link

[BUG] Execution of examples. Possibly windows specific? #120

Closed Skogstomten closed 1 year ago

Skogstomten commented 1 year ago

Describe the bug Examples in readme.md crashes, at least on Windows.

To Reproduce Steps to reproduce the behavior (Bug template contains spelling error. Behaviour):

  1. Install with pip install pytermgui
  2. Copy any of the two code examples from the readme.md to a python file
  3. Run python path\to\file.py

Expected behavior Example to display a result like the one presented in readme.md

Actual behaviour For time display example.

python .\src\app\pytermgui.py
Traceback (most recent call last):
  File "C:\Users\henri\git\private\Company-Admin\src\app\pytermgui.py", line 3, in <module>
    import pytermgui as ptg
  File "C:\Users\henri\git\private\Company-Admin\src\app\pytermgui.py", line 10, in <module>
    ptg.tim.define("!time", macro_time)
    ^^^^^^^
AttributeError: partially initialized module 'pytermgui' has no attribute 'tim' (most likely due to a circular import). Did you mean: 'time'?

For contact form example:

python .\src\app\pytermgui.py
Traceback (most recent call last):
  File "C:\Users\henri\git\private\Company-Admin\src\app\pytermgui.py", line 1, in <module>
    import pytermgui as ptg
  File "C:\Users\henri\git\private\Company-Admin\src\app\pytermgui.py", line 24, in <module>
    with ptg.YamlLoader() as loader:
         ^^^^^^^^^^^^^^
AttributeError: partially initialized module 'pytermgui' has no attribute 'YamlLoader' (most likely due to a circular import)

System information

ptg --version
PyTermGUI version 7.4.0

System details:
    Python version: 3.11.2
    $TERM:          None
    $COLORTERM:     None
    Color support:  ColorSystem.STANDARD
    OS Platform:    Windows-10-10.0.22621-SP0

Possible cause If you have a hunch on what might be causing this, please add it here.

Possible solution If you know a way we could fix this, please add it here.

Tired-Fox commented 1 year ago

Try the examples but with python 3.10. This could be a bug with 3.11

Skogstomten commented 1 year ago

I get the same result on Python 3.10

ptg --version
PyTermGUI version 7.4.0

System details:
    Python version: 3.10.0
    $TERM:          None
    $COLORTERM:     None
    Color support:  ColorSystem.STANDARD
    OS Platform:    Windows-10-10.0.22621-SP0
(venv) PS C:\path\to\project> python src\app\pytermgui.py
Traceback (most recent call last):
  File "C:\path\to\project\src\app\pytermgui.py", line 1, in <module>
    import pytermgui as ptg
  File "C:\path\to\project\src\app\pytermgui.py", line 24, in <module>
    with ptg.YamlLoader() as loader:
AttributeError: partially initialized module 'pytermgui' has no attribute 'YamlLoader' (most likely due to a circular import)
bczsalba commented 1 year ago

What exactly is the code you are running? It works just fine for me.

Skogstomten commented 1 year ago

I've found the issue. I've unintentionally created an ambiguous reference with poor choice of filenames... Closing the issue.

bczsalba commented 1 year ago

Happens to the best of us!