diff options
author | Jayaram Pai | 2014-05-19 11:02:57 +0530 |
---|---|---|
committer | Jayaram Pai | 2014-05-19 11:02:57 +0530 |
commit | 8377256e7d90aa7ba1cb51f6164e99f81e2eb53c (patch) | |
tree | 5afcc8e82d7f7d4f6fbff900520bd8f05eb343ca /OSCAD/modelEditor/exportModel.py | |
download | FreeEDA-8377256e7d90aa7ba1cb51f6164e99f81e2eb53c.tar.gz FreeEDA-8377256e7d90aa7ba1cb51f6164e99f81e2eb53c.tar.bz2 FreeEDA-8377256e7d90aa7ba1cb51f6164e99f81e2eb53c.zip |
initial commit
Diffstat (limited to 'OSCAD/modelEditor/exportModel.py')
-rwxr-xr-x | OSCAD/modelEditor/exportModel.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/OSCAD/modelEditor/exportModel.py b/OSCAD/modelEditor/exportModel.py new file mode 100755 index 0000000..1249197 --- /dev/null +++ b/OSCAD/modelEditor/exportModel.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# exportModel.py is a python script to export a component model to the library. It developed for OSCAD software. It is written by Yogesh Dilip Save (yogessave@gmail.com). +# Copyright (C) 2012 Yogesh Dilip Save, FOSS Project, IIT Bombay. +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +from setPath import OSCAD_HOME +from Tkinter import * +from Tkinter import * +import template +import tkMessageBox +import os.path +import os +import Pmw +from string import maketrans + +class ExportModel(): + """Class for exporting the model to the model library""" + def __init__(self,parent): + self.parent=parent + self.modelName="" + # Collect model information available in the project directory + fileList=os.listdir(".") + modelList=[] + + for fileName in fileList: + if "lib" in fileName: + modelList.append(fileName) + + # Create the dialog. + self.dialog = Pmw.SelectionDialog(parent, + title = 'Model Selector', + buttons = ('OK', 'Cancel'), + defaultbutton = 'OK', + scrolledlist_labelpos = 'n', + label_text = 'Please select the model', + scrolledlist_items=modelList, + command = self.apply, + ) + self.dialog.pack(fill = 'both', expand=1, padx=5, pady=5) + self.dialog.activate() + + # ProtGocol when window is deleted. + self.dialog.protocol("WM_DELETE_WINDOW",self.cancel) + + def apply(self,result): + sels = self.dialog.getcurselection() + if result=="OK": + if len(sels) == 0: + print 'You clicked on', result, '(no selection)' + return + else: + self.modelName=sels[0] + self.status=1 + else: + self.status=0 + self.dialog.withdraw() + # Put focus back to the parent window + self.parent.focus_set() + # Destroy child window + self.dialog.deactivate() + +# Action taken when cancel pressed + def cancel(self, event=None, status=0): + # Catch the status + self.status=status + # Put focus back to the parent window + self.parent.focus_set() + # Destroy child window + self.destroy() + +if __name__=='__main__': + root=Tk() + model= ExportModel(root,"xxx") + mainloop() + |