Here is the Leonine script:
'''Instantiate the pyzo file browser inside Leo.'''
#
# Part 1: The import shim.
import pyzo.core.menu as menu # Needed to import pyzoFileBrowser.
assert menu
import pyzo.tools.pyzoFileBrowser as fb
from pyzo.core.main import loadIcons
#
# Part 2: Instantiate the browser.
loadIcons()
# Sets pyzo.icons. Required to instantiate PyzoFileBrowser.
w = fb.PyzoFileBrowser(parent=None)
# Instantiate a file browser.
g.app.scriptDict ['file_browser'] = w
# Save a reference to the window so it won't disappear.
#
# Part 3: Init the browser.
w.setPath(g.os_path_dirname(g.app.loadDir))
# Tell it what to look at. (The leo-editor/leo directory)
w.setStyleSheet("background: #657b83;")
# Use a dark background.
#
# Part 4: Monkey patch double-clicks.
tree = w._browsers[0]._tree
def double_click_callback(event, self=tree):
# From Tree.mouseDoubleClickEvent
item = self.itemAt(event.x(), event.y())
# item is a tree.DirItem or tree.FileItem
# item._proxy is a DirProxy or FileProxy.
g.trace(item)
g.trace(item._proxy)
tree.mouseDoubleClickEvent = double_click_callback
#
# Part 5: Show the browser.
w.show()
And here are some traces when double-clicking various items:
double_click_callback <pyzo.tools.pyzoFileBrowser.tree.DirItem object at
0x0000011E4B78AC18>
double_click_callback <DirProxy "C:\leo.repo\leo-editor\leo\doc">
double_click_callback <pyzo.tools.pyzoFileBrowser.tree.FileItem object at
0x0000011E4B381F78>
double_click_callback <FileProxy
"C:\leo.repo\leo-editor\leo\doc\leo_rst.css">
*Summary*
This project was unexpectedly easy. All sources remain unchanged, but one
callback was monkey-patched.
The pyzoFileBrowser package has the most complex source code, but the other
tools windows interact with shells. We'll see about running them next.
Edward
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.