Happy Monday discovery:Pyzo's workspace feature can be used to interactively explore Leo's modules, functions, classes, methods and defined variables in real time. This is so cool
It is very cool, and your steps didn't quite work for me. I'm using pyzo 4.10.2 on Windows. For one thing, I don't even have an F5 command. Here is what I did:
Beyond this, I don't know much about what you can do with them so far. but it's very cool ...
def get_leo_libpath():
import leo
return leo.__path__[0]
and assign it, either in the script or in the interactive shell:
x = get_leo_libpath()
def run_console(*args, **keywords):
"""Initialize and run Leo in console mode gui"""
import sys
sys.argv.append('--gui=console')
run(*args, **keywords)
It is called like this:
import leo.core.runLeo
leo.core.runLeo.run_console()
I tried simply changing it to `leo.core.runLeo.run_console('--no-dock')` instead but that failed, so more would be needed. A path perhaps though.
Leo 6.3-devel, devel branch, build 8051ecd172
2020-04-05 05:55:36 -0500
trace: createMenuFromConfigList NO PARENT Edit Settings doHandlersForTag,callTagHandler,onCreate,build_menu
Redirection is not supported.
The kernel process exited. (1)
-matt
Thanks for the extra detail Thomas.Something like this function in runLeo.py to add command line argument might be used to invoke no-docks:
def run_console(*args, **keywords):
"""Initialize and run Leo in console mode gui"""
import sys
sys.argv.append('--gui=console')
run(*args, **keywords)
import sys
sys.argv.append('--use-docks')
leo.run()
Then CTRL-ENTER in Pyzo.
Thanks for the idea!
This looks pretty cool Matt! Kind of reminds me about the Pharo inspector[1][2], with its faceted navigation.
I don't think this will be integrated in Leo in someway (I don't
know about its live introspection capabilities), but is nice to
see such experiments.
[1] https://www.youtube.com/watch?v=_kd4FDKLVFg
[2]
http://rmod-pharo-mooc.lille.inria.fr/MOOC/Videos/W2/C019-Videos-GTInspector1-Introduction-V2-HD_720p_4Mbs.m4v
Cheers,
Offray
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/f375b799-22a0-4176-9577-34a43601d2bd%40googlegroups.com.
>>> (executing file "launchLeo.py")
Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
Not sure how to do what it is asking.
Tom
Okay, I'm playing with this, getting interesting results:
pip install pyzo
Leo 6.3-devel, devel branch, build cbb73524c3
2020-04-15 04:24:37 -0500
Note on using QApplication.exec_():
The GUI event loop is already running in the pyzo kernel, and exec_()
does not block. In most cases your app should run fine without the need
for modifications. For clarity, this is what the pyzo kernel does:
- Prevent deletion of objects in the local scope of functions leading to exec_()
- Prevent system exit right after the exec_() call
Python 3.7.7 (default, Apr 15 2020, 05:09:04) on Windows (64 bits).
This is the Pyzo interpreter with integrated event loop for PYQT5.
Using IPython 7.13.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: whos #this is before I started "launchLeo.py" with F5
Interactive namespace is empty.
In [2]: (executing file "launchLeo.py")
Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
In [3]: whos #note our workspace is now populated with stuff from Leo!
Variable Type Data/Info
----------------------------------------
leo module <module 'leo' from 'c:\\v<...>ditor\\leo\\__init__.py'>
load_locals dict n=6
runMainLoop_locals dict n=1
run_locals dict n=4
In [4]: g.commander_command('new') # naive attempt open a new file in Leo
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-c784551296f6> in <module>
----> 1 g.commander_command('new')
NameError: name 'g' is not defined
/*
Hmm, 'g' is not availible, let's try a fully qualified name, reaching down
from the 'leo' we saw from In [3]: whos :
*/
In [5]: leo.commands.commanderFileCommands.new() # so here is my question,what should I use for my argument?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-0f3e5c284e86> in <module>
----> 1 leo.commands.commanderFileCommands.new()
TypeError: new() missing 1 required positional argument: 'self'
In [6]:
Okay, I've made some progress. Turns out, I was erroneously assumed I was in an IPython shell because it had 'magics', but it was just the idle interpreter, (never spent much time in Idle). All it took was creating a new shell config, and ticking the IPython box.I'm going paste in some of the shell interaction with comments interspersed and a question.
[snip]
In [4]: g.commander_command('new') # naive attempt open a new file in Leo
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-c784551296f6> in <module>
----> 1 g.commander_command('new')
NameError: name 'g' is not defined
/*
Hmm, 'g' is not availible, let's try a fully qualified name, reaching down
from the 'leo' we saw from In [3]: whos :
*/In [5]: leo.commands.commanderFileCommands.new() # so here is my question,what should I use for my argument?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-0f3e5c284e86> in <module>
----> 1 leo.commands.commanderFileCommands.new()
TypeError: new() missing 1 required positional argument: 'self'
In [6]:
The question is at In [5] above, I guess it would be 'g.app', but 'g' isn't available, any suggestions?Doing things like this is the reason I first started looking at IPython, to provide a way to explore Leo code.
<leo.core.leoGlobals.CommanderCommand object at 0x000001FDACBE36D0>
And also in the console tab:
>>> import leo
>>> help(leo.commands.commanderFileCommands.new)
Help on function new in module leo.commands.commanderFileCommands:
new(self, event=None, gui=None)
Create a new Leo window.
I'm not sure what object is needed for self...
No, not IPython.
When I run command [4] in the Python console tab inside Leo (not the Pyzo shell), I get this: