Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to run psse from tkinter

Hi, I'm hoping someone can help me solve this problem. My python script is working fine in Spyder IDE. But when I convert it to .exe using pyinstaller I get an error that psse dongle is missing. Thus PSSE does not even initialize. Below is the code I'm using. Really appreciate if someone could help me out.

import Tkinter as tk
import Tkconstants, tkFileDialog, tkMessageBox
import os
import sys
import datetime
PSSE_PATH = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
os.environ['PATH'] += ';' + PSSE_PATH
sys.path.append(PSSE_PATH)
import psspy
import excelpy
import redirect
redirect.psse2py()
apps = []

def update_case():
 k = apps[0]
 case_file = k.encode("utf-8")
 excelfile= r"E_PY.xlsx"
 E_PY = excelpy.workbook(excelfile, 'test', mode ='r')
 time_data = E_PY.get_cell((2,2), sheet="E_GEN")
 E_PY.close()   
 psspy.psseinit()
 psspy.case(case_file)
 execfile('mirza2.py')
 file_name_lb.config(bg ="green")
 file_name_lb["text"] = "PSSE Case File Created" 

root = tk.Tk()
#title of program
root.title("PSSE Python Project v1.0")
root.configure(bg="black")
root.iconbitmap('ng1.ico')
# save new psse base case
save_case = tk.Button(root,text="5- Update PSSE Case", padx=8, pady=5, command=update_case)
save_case.grid(row=1, column=0, sticky = "w")
root.mainloop()