Olex2 and the PLATON for Windows Taskbar

Since the most convenient version of PLATON for Windows is packaged with the PLATON for Windows Taskbar (pwt), there isn't a simple way to launch PLATON from Olex2. This Olex2 python script modifies the pwt.ini file (default location of c:\pwt\pwt.ini) to include the path and filename of the currently open file in Olex2. One new file (pwt.py) needs to be created and two files (customScripts.py and custom.xld) need to be modified. Note: pwt cannot handle file paths that contain spaces.

pwt.py - place this file in the OLEX2_HOME\etc\scripts\ directory


import olex
import olx
import os
import popen2
from olexFunctions import OlexFunctions
OV = OlexFunctions()

Script (Windows only!) to run PWT/PLATON directly from Olex2
Assumes that PWT is installed in c:\pwt directory

def pwt(path="path", file="Error: no INS file available"):
    print "Launching PWT: %s" %file
    input = open(r"c:\pwt\pwt.ini", "r")
    firstLine = input.readline()  # discard first two lines since we're changing those
    secondLine = input.readline()
    iLines = input.readlines()

    output = open(r"c:\pwt\pwt.ini", "w")
    output.write("CurrentWorkDirectory=" + path.lower() + "\\" + "\nCurrentDataFile=" + file.lower() + "\n")
    for line in iLines:


customScripts.py - in the OLEX2_HOME\etc\scripts\ directory

Add the following line to the customScripts.py file

import pwt

custom.xld - in the top of the Olex2 directory (OLEX2_HOME)

Add the following lines at the end of the file (make sure all brackets are balanced)

<pwt help="Run PLATON (pwt)"
            <cmd1 "user filepath()">
            <cmd2 "spy.pwt('filepath()', 'filename().ins')">