danilo2 Posted September 10, 2009 Share Posted September 10, 2009 Hi! This is my tool function on the shelve (it reads rss and display links on the stage. When this function is pasted into hou.session module it works, but I want to make the same only from the tool. So everything works ok apart of opening browser with links. The bottom commented line makes this error. How to fix it? Thank you:) # The webbrowser module is distributed with Python. The feedloader module # is part of this example and its code is listed below. import webbrowser import feedloader use_help_browser = False links = [] def openLink(index): """Open the URL for a given link index.""" openURL(links[index][1]) def openURL(url): """Open a given URL in the browser.""" if use_help_browser: # If a help browser is already open, use it. desktop = hou.ui.curDesktop() browser = desktop.paneTabOfType(hou.paneTabType.HelpBrowser) if browser is None: browser = desktop.createFloatingPane(hou.paneTabType.HelpBrowser) browser.setUrl(url) else: webbrowser.open_new(url) def createObjects(): """Load the RSS feed and create objects containing the titles. When you click on the objects, they'll open the link in the browser. """ # Load from an RSS feed into the links global variable, storing # (title, url) tuples. global links links = feedloader.loadLinks() # Delete all the existing objects in /obj. for child in hou.node("/obj").children(): child.destroy() y_pos = 0 for index in range(len(links)): text, url = links[index] geo = hou.node("/obj").createNode("geo", run_init_scripts=False) font = geo.createNode("font") font.parm("text").set(text) color = geo.createNode("color") color.setFirstInput(font) color.parmTuple("color").set((1, 1, 1)) color.setDisplayFlag(True) geo.parm("ty").set(y_pos) y_pos -= 2 #HERE I WANT TO CALL THE OpenLink FUNCTION OF THIS TOOL, NOT HOU SESSION. #geo.parm("pickscript").set('python -c "hou.session.openLink(%d)"' % index) hou.node("/obj").layoutChildren() createObjects() Quote Link to comment Share on other sites More sharing options...
graham Posted September 10, 2009 Share Posted September 10, 2009 You can't actually access and call code from inside a shelf tool except when the tool is running. To do what you want you would be best to put all your code inside a module and then call that whenever you need it. Quote Link to comment Share on other sites More sharing options...
danilo2 Posted September 10, 2009 Author Share Posted September 10, 2009 (edited) Thank you nut when I'm trying todo so: geo.parm("pickscript").set('feedloader.goToLink()') in the place I've orewiously showed, only error occured (after selecting the text) that Houdini doesn't see the feedloader (uknow command feedloader.goToLink).... hmm How should i make it working? Edited September 10, 2009 by danilo2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.