Open Source Platform
for interconnected virtual worlds

Content Scripting Python Open Web Browser

From RexWiki

Preface

This page shows how to create a script which can be used for opening webpages for the user in their external web browser.

To use this script:

  1. Make sure server is down
  2. Add the python class from below to "\rexserver\ScriptEngines\PythonScript\Samples" folder to a file named samplewebbrowser.py
  3. Open "\rexserver\ScriptEngines\PythonScript\Samples\__init__.py" file and add samplewebbrowser.py to the end of the list
  4. Start servers
  5. Add prim, go to it's Rex tab-> Data and add the correct parameters (see below Rex data). Remember to press the Set button below the Data to set it.
  6. To the same prim define "samplewebbrowser.ShowWebPage" for it's Class Name and press enter.
  7. Stop editing the prim.
  8. Touch the prim to activate the script.


Rex data for prim opening an external webpage for the user

Go to realXtend website
http://www.realxtend.org

Parameter descriptions line by line are as follows:

  • Line 1: Message to show in the dialog
  • Line 2: URL with the protocol in front of it, only http and https are supported


Python script

The following python script should be added to a file named samplewebbrowser.py.

import rxactor
import rxavatar
import sys
import clr

class ShowWebPage(rxactor.Actor):
    def GetScriptClassName():
        return "samplewebbrowser.ShowWebPage"

    def EventTouch(self,vAvatar):
        myfreedata = self.rexGetPrimFreeData()
        paramlistlines = myfreedata.splitlines()
        self.llLoadURL(vAvatar.AgentId,paramlistlines[0],paramlistlines[1])