Trying to Display a Help File (Help.jpg)
-
I have tried this method to display a help file for the user. I get no error message and the screen flashes like something is happening but the picture is not open in the browser as I expected.
Any Suggestions?def dowelHelp self.k2_Tools_help_Path @helpfile = "K2_ToolsDowelHelp.jpg" fullpath = File.join(@base_path,@rel_path,@helpfile) UI.openURL(fullpath) end #def dowelHelp
Keith
-
I believe it needs to be a URL to work at all, and on a mac, it also needs to be a .html to open in the browser...
i.e. this opens in 'Preview' not 'Safari' [ mac image viewer ]UI.openURL("file;///Users/johns_iMac/Desktop/400px-Lion_Rampant.png")
but this opens in 'Safari'
UI.openURL("file;///Users/johns_iMac/Desktop/!a_test/testhtml.html")
'
john -
Assuming the path to the actual file is correctly formed...
TryUI.openURL("file:///#{fullpath}")
which should then open the file in its default application.
An image-file will NOT open in a web-browser unless that web-browser is set as the default application for that image-file type.
Of course you could write a short .html file instead, and then that can simply load the specific image-file, and then the .html file will open in the user's default web-browser... -
Well I wrote a htlm file and placed it in the same dir as the Dowel help file and when I click on the htlm file the Help picture opens. However I have not yet accomplished this from inside my ruby script.
def dowelHelp UI.openURL("file;///K2WS_Tools/k2ws_DowelHelp.html") UI.messagebox("Dowel Help Complete") end #def dowelHelp
This does not produce an error message and the UI.messagebox following the open file displays so the code completes running but no help file picture.
Suggestions
Thanks
Keith -
B_U_T...
That is NOT the full path to the file !
UI.openURL("file:///K2WS_Tools/k2ws_DowelHelp.html")
It needs to be something more like:
UI.openURL("file:///**C:/Users/UserName/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/**K2WS_Tools/k2ws_DowelHelp.html")
[depending on the SketchUp version]
The find the path to the folder use__FILE__
dir=File.dirname(__FILE__)
will return the folder the 'calling plugin file' is in...
Either the tool's subfolder or the Plugins folder itself, depending on the location of it... -
This is what finally worked:
def dowelHelp dowel_help_File = File.join(File.dirname(__FILE__),"K2_ToolsSupportFiles","k2ws_DowelHelp.html") UI.openURL("file;///#{dowel_help_File}") UI.messagebox("Dowel Help Complete " + dowel_help_File.to_s) end #def dowelHelp
The html file was:
<!DOCTYPE html> <html> <body> <p> <img src="K2_ToolsDowelHelp.png" > </p> </body> </html>
Thanks
Keith
Advertisement