Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have a python code works for PSSE32 I want it for PSSE33, what should I change in this code?

Here is the first lines, I think I need to do something with glade (GUI).

import gtk from gtk import * import gtk.glade from gtk.glade import * import os import gtk.gdk import string import time import shutil import pango

RootPath = "D:\personal\ThreeWTool\"

result = os.path.exists(RootPath)

PSSE_Path = "D:\Progra~1\PTI\PSSE33"

MustPath = "D:\Program Files\PTI\MUST 10.2\Program"
if result != True: RootPath = "C:\personal\ThreeWTool\" PSSE
Path = "C:\Program Files (x86)\PTI\PSSE33" Must_Path = "C:\Program Files\PTI\MUST 10.2\Program"

import sys,copy,winsound if not os.path.exists('C:\Program Files (x86)\PTI\PSSE33\'): os.listdir('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSLIB') sys.path.append('C:\GTK\lib') os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSLIB' os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSBIN' os.environ['PATH'] += ';C:\GTK\lib' else: os.listdir('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSLIB') sys.path.append('C:\GTK\lib') os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSLIB' os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSBIN' os.environ['PATH'] += ';C:\GTK\lib'

import psspy i,f=psspy.getbatdefaults() ierr=psspy.psseinit(100000)

class ProfileClass: def init(self): pass

def CWD(filename): # current working directory length = len(filename) k = length while k: k -=1 if filename[k] == '/' or filename[k] == '\': break try: os.chdir(filename[:k]) except: os.chdir(RootPath)

class Application: def init(self): self.xml = gtk.glade.XML("glade/3WTool.glade") nameFuncMap = {} for key in dir(self.class): nameFuncMap[key] = getattr(self,key) self.xml.signal_autoconnect(nameFuncMap) self.Load() gtk.main()

    def Load(self):
        profilename = RootPath+"options.txt" 

        try:
            os.chdir(RootPath)
        except:
            os.mkdir(RootPath)

        try:
            f = open(profilename,"r")
            contents=f.read()
            f.close()
            eachline = contents.split("\n")
            self.xml.get_widget("3WLabel").set_text(eachline[1])
            self.xml.get_widget("InputCLabel").set_text(eachline[2])
            self.xml.get_widget("IdevLabel").set_text(eachline[3])
            self.xml.get_widget("OutputCLabel").set_text(eachline[4])
            SelectAnswer = {"Yes":0,"No":1}
            self.xml.get_widget("CreateCLabel").set_active(SelectAnswer[eachline[5]])

PSSE_Path=eachline[8]

Must_Path=eachline[9]

        except:
            f = open(profilename,"w")
            contents=[]
            contents.append("Three Winding Conversion Tool Version 1\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")

contents.append(PSSE_Path+"\n")

contents.append(Must_Path+"\n")

            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            f.writelines(contents)
            f.close()
            f = open(profilename,"r")
            contents=f.readline()
            f.close()

        os.chdir(RootPath)

I have a python code works for PSSE32 I want it for PSSE33, what should I change in this code?

Here is the first lines, I think I need to do something with glade (GUI).

[code] import gtk from gtk import * import gtk.glade from gtk.glade import * import os import gtk.gdk import string import time import shutil import pango

RootPath = "D:\personal\ThreeWTool\"

result = os.path.exists(RootPath)

PSSE_Path = "D:\Progra~1\PTI\PSSE33"

MustPath = "D:\Program Files\PTI\MUST 10.2\Program"
if result != True: RootPath = "C:\personal\ThreeWTool\" PSSE
Path = "C:\Program Files (x86)\PTI\PSSE33" Must_Path = "C:\Program Files\PTI\MUST 10.2\Program"

import sys,copy,winsound if not os.path.exists('C:\Program Files (x86)\PTI\PSSE33\'): os.listdir('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSLIB') sys.path.append('C:\GTK\lib') os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSLIB' os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSBIN' os.environ['PATH'] += ';C:\GTK\lib' else: os.listdir('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program Files (x86)\PTI\PSSE33\PSSLIB') sys.path.append('C:\GTK\lib') os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSLIB' os.environ['PATH'] += ';C:\Program Files (x86)\PTI\PSSE33\PSSBIN' os.environ['PATH'] += ';C:\GTK\lib'

import psspy i,f=psspy.getbatdefaults() ierr=psspy.psseinit(100000)

class ProfileClass: def init(self): pass

def CWD(filename): # current working directory length = len(filename) k = length while k: k -=1 if filename[k] == '/' or filename[k] == '\': break try: os.chdir(filename[:k]) except: os.chdir(RootPath)

class Application: def init(self): self.xml = gtk.glade.XML("glade/3WTool.glade") nameFuncMap = {} for key in dir(self.class): nameFuncMap[key] = getattr(self,key) self.xml.signal_autoconnect(nameFuncMap) self.Load() gtk.main()

    def Load(self):
        profilename = RootPath+"options.txt" 

        try:
            os.chdir(RootPath)
        except:
            os.mkdir(RootPath)

        try:
            f = open(profilename,"r")
            contents=f.read()
            f.close()
            eachline = contents.split("\n")
            self.xml.get_widget("3WLabel").set_text(eachline[1])
            self.xml.get_widget("InputCLabel").set_text(eachline[2])
            self.xml.get_widget("IdevLabel").set_text(eachline[3])
            self.xml.get_widget("OutputCLabel").set_text(eachline[4])
            SelectAnswer = {"Yes":0,"No":1}
            self.xml.get_widget("CreateCLabel").set_active(SelectAnswer[eachline[5]])

PSSE_Path=eachline[8]

Must_Path=eachline[9]

        except:
            f = open(profilename,"w")
            contents=[]
            contents.append("Three Winding Conversion Tool Version 1\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            contents.append("\n")

contents.append(PSSE_Path+"\n")

contents.append(Must_Path+"\n")

            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            f.writelines(contents)
            f.close()
            f = open(profilename,"r")
            contents=f.readline()
            f.close()

        os.chdir(RootPath)
os.chdir(RootPath)  [/code]

I have a python code works for PSSE32 I want it for PSSE33, what should I change in this code?

Here is the first lines, I think I need something to do something with glade (GUI).(GUI) at the middle of the code.

[code]

import gtk
from gtk import *
import gtk.glade
from gtk.glade import *
import os
import gtk.gdk
import string
import time
import shutil
import pango

pango RootPath = "D:\personal\ThreeWTool\"

"D:\\personal\\ThreeWTool\\" result = os.path.exists(RootPath)

os.path.exists(RootPath) PSSE_Path = "D:\Progra~1\PTI\PSSE33"

MustPath "D:\\Progra~1\\PTI\\PSSE33" Must_Path = "D:\Program Files\PTI\MUST 10.2\Program"
if result != True: RootPath = "C:\personal\ThreeWTool\" PSSE
Path = "C:\Program "C:\\personal\\ThreeWTool\\" PSSE_Path = "C:\\Program Files (x86)\PTI\PSSE33" (x86)\\PTI\\PSSE33" Must_Path = "C:\Program Files\PTI\MUST 10.2\Program"

"C:\\Program Files\\PTI\\MUST 10.2\\Program" import sys,copy,winsound if not os.path.exists('C:\Program os.path.exists('C:\\Program Files (x86)\PTI\PSSE33\'): os.listdir('C:\Program (x86)\\PTI\\PSSE33\\'): os.listdir('C:\\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program (x86)\\PTI\\PSSE33\\PSSBIN') sys.path.append('C:\\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program (x86)\\PTI\\PSSE33\\PSSBIN') sys.path.append('C:\\Program Files (x86)\PTI\PSSE33\PSSLIB') sys.path.append('C:\GTK\lib') (x86)\\PTI\\PSSE33\\PSSLIB') sys.path.append('C:\\GTK\\lib') os.environ['PATH'] += ';C:\Program ';C:\\Program Files (x86)\PTI\PSSE33\PSSLIB' (x86)\\PTI\\PSSE33\\PSSLIB' os.environ['PATH'] += ';C:\Program ';C:\\Program Files (x86)\PTI\PSSE33\PSSBIN' (x86)\\PTI\\PSSE33\\PSSBIN' os.environ['PATH'] += ';C:\GTK\lib' ';C:\\GTK\\lib' else: os.listdir('C:\Program os.listdir('C:\\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program (x86)\\PTI\\PSSE33\\PSSBIN') sys.path.append('C:\\Program Files (x86)\PTI\PSSE33\PSSBIN') sys.path.append('C:\Program (x86)\\PTI\\PSSE33\\PSSBIN') sys.path.append('C:\\Program Files (x86)\PTI\PSSE33\PSSLIB') sys.path.append('C:\GTK\lib') (x86)\\PTI\\PSSE33\\PSSLIB') sys.path.append('C:\\GTK\\lib') os.environ['PATH'] += ';C:\Program ';C:\\Program Files (x86)\PTI\PSSE33\PSSLIB' (x86)\\PTI\\PSSE33\\PSSLIB' os.environ['PATH'] += ';C:\Program ';C:\\Program Files (x86)\PTI\PSSE33\PSSBIN' (x86)\\PTI\\PSSE33\\PSSBIN' os.environ['PATH'] += ';C:\GTK\lib'

';C:\\GTK\\lib' import psspy i,f=psspy.getbatdefaults() _i,_f=psspy.getbatdefaults() ierr=psspy.psseinit(100000)

class ProfileClass: def init(self): pass

__init__(self): pass def CWD(filename): # current working directory length = len(filename) k = length while k: k -=1 if filename[k] == '/' or filename[k] == '\': '\\': break try: os.chdir(filename[:k]) except: os.chdir(RootPath)

os.chdir(RootPath) class Application: def init(self): __init__(self): self.xml = gtk.glade.XML("glade/3WTool.glade") nameFuncMap = {} for key in dir(self.class): dir(self.__class__): nameFuncMap[key] = getattr(self,key) self.xml.signal_autoconnect(nameFuncMap) self.Load() gtk.main()

gtk.main()

        def Load(self):
         profilename = RootPath+"options.txt" 

         try:
             os.chdir(RootPath)
         except:
             os.mkdir(RootPath)

         try:
             f = open(profilename,"r")
             contents=f.read()
             f.close()
             eachline = contents.split("\n")
             self.xml.get_widget("3WLabel").set_text(eachline[1])
             self.xml.get_widget("InputCLabel").set_text(eachline[2])
             self.xml.get_widget("IdevLabel").set_text(eachline[3])
             self.xml.get_widget("OutputCLabel").set_text(eachline[4])
             SelectAnswer = {"Yes":0,"No":1}
             self.xml.get_widget("CreateCLabel").set_active(SelectAnswer[eachline[5]])

PSSE_Path=eachline[8]

Must_Path=eachline[9]

#                PSSE_Path=eachline[8]
#                Must_Path=eachline[9]                
            except:
             f = open(profilename,"w")
             contents=[]
             contents.append("Three Winding Conversion Tool Version 1\n")
             contents.append("\n")
             contents.append("\n")
             contents.append("\n")
             contents.append("\n")
             contents.append("\n")
             contents.append("\n")
#                contents.append(PSSE_Path+"\n")
#                contents.append(Must_Path+"\n")
                contents.append("\n")
                contents.append("\n")
                contents.append("\n")
                f.writelines(contents)
                f.close()
                f = open(profilename,"r")
                contents=f.readline()
                f.close()

            os.chdir(RootPath)

contents.append(PSSE_Path+"\n")

contents.append(Must_Path+"\n")

            contents.append("\n")
            contents.append("\n")
            contents.append("\n")
            f.writelines(contents)
            f.close()
            f = open(profilename,"r")
            contents=f.readline()
            f.close()

        os.chdir(RootPath)  [/code]