Discussion:
[Pyzo] Access selected file/folder from FileBrowser plugin
s***@gmail.com
2017-10-08 10:21:57 UTC
Permalink
I am looking for a way to access the currently selected file/folder in the FileBrowser plugin, from another plugin.

I don't want to reinvent the wheel, since my plugin requires a file/folder to be selected and FileBrowser plugin is already built-in and was thinking of using it to achieve my goals.

Is that possible and is there a more elegant solution?

Thanks
--
You received this message because you are subscribed to the Google Groups "Pyzo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyzo+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Almar Klein
2017-10-08 13:48:17 UTC
Permalink
Hi,

Yes, the file browser plugin has a path() and setPath() method. It als
has a signal that gets emitted when the path changes, but its currenly
buried at filebrowserplugin._tree.dirChanged. We can move/proxy it to
the main class if you need it.

- Almar
Post by s***@gmail.com
I am looking for a way to access the currently selected file/folder in the FileBrowser plugin, from another plugin.
I don't want to reinvent the wheel, since my plugin requires a file/folder to be selected and FileBrowser plugin is already built-in and was thinking of using it to achieve my goals.
Is that possible and is there a more elegant solution?
Thanks
--
You received this message because you are subscribed to the Google Groups "Pyzo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyzo+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
s***@gmail.com
2017-10-08 19:25:31 UTC
Permalink
Hi Almar,

Thanks for the quick reply, at first glance path() and setPath() approach seem to work. I'll try to look some more into it and keep you posted.

Best regards
Sasa
--
You received this message because you are subscribed to the Google Groups "Pyzo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyzo+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
s***@gmail.com
2017-10-09 17:51:15 UTC
Permalink
Hi Almar,

Thank you very much. It works.

Code snippet:

import pyzo

file_browswer = pyzo.toolManager.getTool('pyzofilebrowser')
browser = file_browswer.children()[0]
browser_tree = browser.children()[2]

# snip

def setAppDirectory(self):
path = browser_tree.selectedItems()[0].path()
if os.path.isdir(path):
self._app_dir_line.setText(path)
# snip

def setAppMainFile(self):
path = browser_tree.selectedItems()[0].path()
if os.path.isfile(path):
if path.endswith('.py'):
self._app_main_file_line.setText(path)

Best regards
Sasa
--
You received this message because you are subscribed to the Google Groups "Pyzo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyzo+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...