Investigate better way of importing libraries #118

Closed
jarvisteach opened this Issue Mar 12, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@jarvisteach
Owner

jarvisteach commented Mar 12, 2017

Saw this code in DnD:

if not getattr(master, '_tkdnd_loaded', False):
            _load_tkdnd(master)

Might be useful in appJar - load libraries on first use.

So, have two booleans ATTEMPTED/AVAILABLE - if not ATTEMPTED, try to load, if not AVAILABLE - skip.

@jarvisteach jarvisteach modified the milestones: 0.07, 0.06 Mar 12, 2017

@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Mar 15, 2017

Owner

Interestingly, imports are simply variables.

Therefore, will initialise the import libraries as None.
Then, will create import functions for on demand libraries - if the library variable is None, they will try to import. If they fail, they will set the library variable to False

Then, add the initialiser call before any time the library is accessed, then just check if the variable is not False.

Owner

jarvisteach commented Mar 15, 2017

Interestingly, imports are simply variables.

Therefore, will initialise the import libraries as None.
Then, will create import functions for on demand libraries - if the library variable is None, they will try to import. If they fail, they will set the library variable to False

Then, add the initialiser call before any time the library is accessed, then just check if the variable is not False.

jarvisteach added a commit that referenced this issue Mar 15, 2017

Improve library imports (#118)
Move *optional* library imports to their own functions.

jarvisteach added a commit that referenced this issue Mar 15, 2017

Moved more library imports (#118)
Also, added catch for DND usage…

jarvisteach added a commit that referenced this issue Mar 16, 2017

All imports now done dynamically (#118)
Had to make ajTree/Node dynamic as well, as they relied on an import…

Seems to work, although not sure if it’s pythonic…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment