jarvisteach / appJar

Simple Tkinter GUIs in Python
http://appJar.info
Other
615 stars 68 forks source link

Suppress warnings when using addTree #593

Closed projectbtle closed 4 years ago

projectbtle commented 4 years ago

Bug Report


Warnings are logged to console even when appJar's log level is set to CRITICAL, when using addTree.

Context


I am trying to create a tree from an XML file using addTree. The tree creation works fine (great new addition, by the way!), but warning messages are logged to the console, despite the log level being set to CRITICAL.

Expected Behaviour


No warning messages when log level is set to CRITICAL.

Actual Behaviour


The following warning messages are logged:

Warning: config.IdleConf.GetThemeDict -
 problem retrieving theme element 'context-foreground'
 from theme 'DarkTheme'.
 returning default color: '#000000'

 Warning: config.IdleConf.GetThemeDict -
 problem retrieving theme element 'context-background'
 from theme 'DarkTheme'.
 returning default color: '#ffffff'

I tried suppressing appJar's logging using logging.getLogger('appJar').setLevel(logging.CRITICAL) , which suppresses all other messages from appJar, but not the warnings above. I suspect they are generated by an external library (idlelib?).

Any error messages produced by appJar


The warning messages above.

Sample code, demonstrating the issue


app = gui()
tree = """
<test>
    <test1 />
</test>
"""
app.addTree(
    'MyTree',
    tree,
    rowspan = 1
)
app.go()

What steps are needed to reproduce the bug


Run the above code as a standalone script.

Version Information


appJar: 0.94.0 Python: 3.7.3 TCL: 8.6, TK: 8.6 Platform: Windows

jarvisteach commented 4 years ago

Have had a quick look - this is generated by config.py which is part of idlelib, see here line 230.

I don't get these errors on Mac, and hadn't seen them before on Windows - so I guess they are new theme colours being requested, that aren't in the theme dictionary...

I guess an issue could be raised on idlelib, but I'm not sure how else to prevent it?

projectbtle commented 4 years ago

Right now I'm doing the following:

import io
from contextlib import redirect_stderr

f = io.StringIO()
with redirect_stderr(f):
    app.addTree(
        'MyTree',
        tree,
        rowspan=1
    )
f = None

This suppresses the warnings, but isn't a particularly elegant solution.

jarvisteach commented 4 years ago

I've put a note on the appJar limitations page

But, don't think I'll make any changes...