Code Snippet: open file in external viewer from Serna
Use case: open a file (or url) in external viewer from Serna using file type association rules defined in Tools -> Preferences -> Applications dialog.
Synopsis:
Command: LaunchBrowser
Arguments:
url: string, path/url to a file.
1 2 3 4 5 6 7 8 9 10 11 | class SomeCustomPlugin(DocumentPlugin): # Some code goes here ... def openExternalBrowser(self, path): browse_info = PropertyNode("external-viewer") url_arg = PropertyNode("url", path) browse_info.appendChild(url_arg) self.executeCommandEvent("LaunchBrowser", browse_info) # And some code below ... |
document path here can be a path to local file as well as URI.