本文整理汇总了Python中configuration.Appconfig.Appconfig类的典型用法代码示例。如果您正苦于以下问题:Python Appconfig类的具体用法?Python Appconfig怎么用?Python Appconfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Appconfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, dir=None):
QtGui.QWidget.__init__(self)
self.obj_validation = Validation()
self.obj_appconfig = Appconfig()
self.projDir = dir
self.projName = os.path.basename(self.projDir)
self.ngspiceNetlist = os.path.join(self.projDir,self.projName+".cir.out")
self.modelicaNetlist = os.path.join(self.projDir,self.projName+".mo")
self.map_json = Appconfig.modelica_map_json
self.grid = QtGui.QGridLayout()
self.FileEdit = QtGui.QLineEdit()
self.FileEdit.setText(self.ngspiceNetlist)
self.grid.addWidget(self.FileEdit, 0, 0)
self.browsebtn = QtGui.QPushButton("Browse")
self.browsebtn.clicked.connect(self.browseFile)
self.grid.addWidget(self.browsebtn, 0, 1)
self.convertbtn = QtGui.QPushButton("Convert")
self.convertbtn.clicked.connect(self.callConverter)
self.grid.addWidget(self.convertbtn, 2, 1)
self.loadOMbtn = QtGui.QPushButton("Load OMEdit")
self.loadOMbtn.clicked.connect(self.callOMEdit)
self.grid.addWidget(self.loadOMbtn, 3, 1)
#self.setGeometry(300, 300, 350, 300)
self.setLayout(self.grid)
self.show()
示例2: __init__
def __init__(self,*args):
"""
Initialize main Application window
"""
#Calling __init__ of super class
QtGui.QMainWindow.__init__(self,*args)
#Creating require Object
self.obj_workspace = Workspace.Workspace()
self.obj_Mainview = MainView()
self.obj_kicad = Kicad(self.obj_Mainview.obj_dockarea)
self.obj_appconfig = Appconfig()
self.obj_validation = Validation()
#Initialize all widget
self.setCentralWidget(self.obj_Mainview)
self.initToolBar()
self.setGeometry(self.obj_appconfig._app_xpos,
self.obj_appconfig._app_ypos,
self.obj_appconfig._app_width,
self.obj_appconfig._app_heigth)
self.setWindowTitle(self.obj_appconfig._APPLICATION)
self.showMaximized()
self.setWindowIcon(QtGui.QIcon('res/images/logo.png'))
#self.show()
self.systemTrayIcon = QtGui.QSystemTrayIcon(self)
self.systemTrayIcon.setIcon(QtGui.QIcon('res/images/logo.png'))
self.systemTrayIcon.setVisible(True)
示例3: __init__
def __init__(self):
QtGui.QWidget.__init__(self)
self.obj_appconfig = Appconfig()
self.treewidget = QtGui.QTreeWidget()
self.window= QtGui.QVBoxLayout()
header = QtGui.QTreeWidgetItem(["Projects","path"])
self.treewidget.setHeaderItem(header)
self.treewidget.setColumnHidden(1,True)
#CSS
self.treewidget.setStyleSheet(" \
QTreeView { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \
QTreeView::branch:has-siblings:!adjoins-item { border-image: url(../../images/vline.png) 0; } \
QTreeView::branch:has-siblings:adjoins-item { border-image: url(../../images/branch-more.png) 0; } \
QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: url(../../images/branch-end.png) 0; } \
QTreeView::branch:has-children:!has-siblings:closed, \
QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(../../images/branch-closed.png); } \
QTreeView::branch:open:has-children:!has-siblings, \
QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(../../images/branch-open.png); } \
")
for parents, children in self.obj_appconfig.project_explorer.items():
os.path.join(parents)
if os.path.exists(parents):
pathlist= parents.split(os.sep)
parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1],parents])
for files in children:
childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
self.window.addWidget(self.treewidget)
self.treewidget.doubleClicked.connect(self.openProject)
self.treewidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.treewidget.customContextMenuRequested.connect(self.openMenu)
self.setLayout(self.window)
self.show()
示例4: body
def body(self):
self.obj_Appconfig = Appconfig()
self.openDir = self.obj_Appconfig.default_workspace["workspace"]
#print "default workspace is now 1", self.openDir
self.projDir=QtGui.QFileDialog.getExistingDirectory(self,"open",self.openDir)
if self.obj_validation.validateOpenproj(self.projDir) == True:
#print "Pass open project test"
#self.obj_Appconfig = Appconfig()
self.obj_Appconfig.current_project['ProjectName'] = str(self.projDir)
if os.path.isdir(self.projDir):
print "true"
for dirs, subdirs, filelist in os.walk(self.obj_Appconfig.current_project["ProjectName"]):
directory = dirs
files = filelist
self.obj_Appconfig.project_explorer[dirs] = filelist
json.dump(self.obj_Appconfig.project_explorer, open(self.obj_Appconfig.dictPath,'w'))
self.obj_Appconfig.print_info('Open Project called')
self.obj_Appconfig.print_info('Current Project is ' + self.projDir)
return dirs, filelist
else:
#print "Failed open project test"
self.obj_Appconfig.print_error("The project doesn't contain .proj file. Please select the proper directory else you won't be able to perform any operation")
reply = QtGui.QMessageBox.critical(None, "Error Message",'''<b> Error: The project doesn't contain .proj file.</b><br/>
<b>Please select the proper project directory else you won't be able to perform any operation</b>''',QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel)
if reply == QtGui.QMessageBox.Ok:
self.body()
self.obj_Appconfig.print_info('Open Project called')
self.obj_Appconfig.print_info('Current Project is ' + self.projDir)
elif reply == QtGui.QMessageBox.Cancel:
self.obj_Appconfig.print_info('No Project opened')
else:
pass
示例5: __init__
def __init__(self,fpath,projectName):
QtGui.QMainWindow.__init__(self)
self.fpath = fpath#+".cir.out"
self.projectName = projectName
self.obj_appconfig = Appconfig()
print "Path : ",self.fpath
print "Project Name : ",self.projectName
self.obj_appconfig.print_info('Ngspice simulation is called : ' + self.fpath)
self.obj_appconfig.print_info('PythonPlotting is called : ' + self.fpath)
self.combo = []
self.combo1 = []
self.combo1_rev = []
#Creating Frame
self.createMainFrame()
示例6: ProjectExplorer
class ProjectExplorer(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.obj_appconfig = Appconfig()
self.treewidget = QtGui.QTreeWidget()
self.window= QtGui.QVBoxLayout()
header = QtGui.QTreeWidgetItem(["Projects","path"])
self.treewidget.setHeaderItem(header)
self.treewidget.setColumnHidden(1,True)
#CSS
self.treewidget.setStyleSheet(" \
QTreeView { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \
QTreeView::branch:has-siblings:!adjoins-item { border-image: url(../../images/vline.png) 0; } \
QTreeView::branch:has-siblings:adjoins-item { border-image: url(../../images/branch-more.png) 0; } \
QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: url(../../images/branch-end.png) 0; } \
QTreeView::branch:has-children:!has-siblings:closed, \
QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(../../images/branch-closed.png); } \
QTreeView::branch:open:has-children:!has-siblings, \
QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(../../images/branch-open.png); } \
")
for parents, children in self.obj_appconfig.project_explorer.items():
os.path.join(parents)
if os.path.exists(parents):
pathlist= parents.split(os.sep)
parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1],parents])
for files in children:
childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
self.window.addWidget(self.treewidget)
self.treewidget.doubleClicked.connect(self.openProject)
self.treewidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.treewidget.customContextMenuRequested.connect(self.openMenu)
self.setLayout(self.window)
self.show()
def addTreeNode(self, parents, children):
os.path.join(parents)
pathlist= parents.split(os.sep)
parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1], parents])
for files in children:
childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
def openMenu(self, position):
indexes = self.treewidget.selectedIndexes()
if len(indexes) > 0:
level = 0
index = indexes[0]
while index.parent().isValid():
index = index.parent()
level += 1
menu = QtGui.QMenu()
if level == 0:
deleteproject = menu.addAction(self.tr("Remove Project"))
deleteproject.triggered.connect(self.removeProject)
refreshproject= menu.addAction(self.tr("Refresh"))
refreshproject.triggered.connect(self.refreshProject)
elif level == 1:
openfile = menu.addAction(self.tr("Open"))
openfile.triggered.connect(self.openProject)
menu.exec_(self.treewidget.viewport().mapToGlobal(position))
def openProject(self):
self.indexItem =self.treewidget.currentIndex()
filename= self.indexItem.data().toString()
self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
self.obj_appconfig.print_info('The current project is ' + self.filePath)
self.textwindow = QtGui.QWidget()
self.textwindow.setMinimumSize(600, 500)
self.textwindow.setGeometry(QtCore.QRect(400,150,400,400))
self.textwindow.setWindowTitle(filename)
self.text = QtGui.QTextEdit()
self.save = QtGui.QPushButton('Save and Exit')
self.save.setDisabled(True)
self.windowgrid = QtGui.QGridLayout()
if (os.path.isfile(str(self.filePath)))== True:
self.fopen = open(str(self.filePath), 'r')
lines = self.fopen.read()
self.text.setText(lines)
QtCore.QObject.connect(self.text,QtCore.SIGNAL("textChanged()"), self.enable_save)
vbox_main = QtGui.QVBoxLayout(self.textwindow)
vbox_main.addWidget(self.text)
vbox_main.addWidget(self.save)
self.save.clicked.connect(self.save_data)
#self.connect(exit,QtCore.SIGNAL('close()'), self.onQuit)
self.textwindow.show()
else:
self.obj_appconfig.current_project["ProjectName"]= str(self.filePath)
def enable_save(self):
#.........这里部分代码省略.........
示例7: __init__
def __init__(self,parent=None):
super(Workspace, self).__init__()
self.obj_appconfig = Appconfig()
#Initializing Workspace directory for project
self.initWorkspace()
示例8: Workspace
class Workspace(QtGui.QWidget):
"""
This class creates Workspace GUI.
"""
def __init__(self,parent=None):
super(Workspace, self).__init__()
self.obj_appconfig = Appconfig()
#Initializing Workspace directory for project
self.initWorkspace()
def initWorkspace(self):
#print "Calling workspace"
self.mainwindow = QtGui.QVBoxLayout()
self.split = QtGui.QSplitter()
self.split.setOrientation(QtCore.Qt.Vertical)
self.grid = QtGui.QGridLayout()
self.note = QtGui.QTextEdit(self)
self.workspace_label = QtGui.QLabel(self)
self.workspace_loc = QtGui.QLineEdit(self)
self.note.append(self.obj_appconfig.workspace_text)
self.workspace_label.setText("Workspace:")
self.workspace_loc.setText(self.obj_appconfig.home)
#Buttons
self.browsebtn = QtGui.QPushButton('Browse')
self.browsebtn.clicked.connect(self.browseLocation)
self.okbtn = QtGui.QPushButton('OK')
self.okbtn.clicked.connect(self.createWorkspace)
self.cancelbtn = QtGui.QPushButton('Cancel')
self.cancelbtn.clicked.connect(self.defaultWorkspace)
#Layout
self.grid.addWidget(self.note, 0,0,1,15)
self.grid.addWidget(self.workspace_label, 2,1)
self.grid.addWidget(self.workspace_loc,2,2,2,12)
self.grid.addWidget(self.browsebtn, 2,14)
self.grid.addWidget(self.okbtn, 4,13)
self.grid.addWidget(self.cancelbtn, 4,14)
self.setGeometry(QtCore.QRect(500,250,400,400))
self.setMaximumSize(4000, 200)
self.setWindowTitle("eSim")
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.note.setReadOnly(True)
self.setWindowIcon(QtGui.QIcon('../../images/logo.png'))
self.setLayout(self.grid)
self.show()
def defaultWorkspace(self):
print "Default location selected"
self.imp_var=1
self.obj_appconfig.print_info('Default workspace selected : ' + self.obj_appconfig.default_workspace["workspace"])
self.close()
var_appView.show()
time.sleep(1)
var_appView.splash.close()
def close(self, *args, **kwargs):
self.window_open_close=1
self.close_var=1
#with var_cond:
# var_cond.notify()
return QtGui.QWidget.close(self, *args, **kwargs)
def returnWhetherClickedOrNot(self,appView):
global var_appView
var_appView=appView
def createWorkspace(self):
print "Create workspace is called"
self.create_workspace = str(self.workspace_loc.text())
self.obj_appconfig.print_info('Workspace : ' + self.create_workspace)
#Checking if Workspace already exist or not
if os.path.isdir(self.create_workspace):
print "Already present"
self.obj_appconfig.default_workspace["workspace"] = self.create_workspace
else:
os.mkdir(self.create_workspace)
self.obj_appconfig.default_workspace["workspace"] = self.create_workspace
self.imp_var=1
self.close()
var_appView.show()
time.sleep(1)
var_appView.splash.close()
def browseLocation(self):
print "Browse Location called"
#.........这里部分代码省略.........
示例9: plotWindow
class plotWindow(QtGui.QMainWindow):
def __init__(self,fpath,projectName):
QtGui.QMainWindow.__init__(self)
self.fpath = fpath#+".cir.out"
self.projectName = projectName
self.obj_appconfig = Appconfig()
print "Path : ",self.fpath
print "Project Name : ",self.projectName
self.obj_appconfig.print_info('Ngspice simulation is called : ' + self.fpath)
self.obj_appconfig.print_info('PythonPlotting is called : ' + self.fpath)
self.combo = []
self.combo1 = []
self.combo1_rev = []
#Creating Frame
self.createMainFrame()
def createMainFrame(self):
self.mainFrame = QtGui.QWidget()
self.dpi = 100
self.fig = Figure((7.0, 7.0), dpi=self.dpi)
#Creating Canvas which will figure
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self.mainFrame)
self.axes = self.fig.add_subplot(111)
self.navToolBar = NavigationToolbar(self.canvas, self.mainFrame)
#LeftVbox hold navigation tool bar and canvas
self.left_vbox = QtGui.QVBoxLayout()
self.left_vbox.addWidget(self.navToolBar)
self.left_vbox.addWidget(self.canvas)
#right VBOX is main Layout which hold right grid(bottom part) and top grid(top part)
self.right_vbox = QtGui.QVBoxLayout()
self.right_grid = QtGui.QGridLayout()
self.top_grid = QtGui.QGridLayout()
#Get DataExtraction Details
self.obj_dataext = DataExtraction()
self.plotType = self.obj_dataext.openFile(self.fpath)
self.obj_dataext.computeAxes()
self.a = self.obj_dataext.numVals()
self.chkbox=[]
########### Generating list of colors :
self.full_colors = ['r','b','g','y','c','m','k']#,(0.4,0.5,0.2),(0.1,0.4,0.9),(0.4,0.9,0.2),(0.9,0.4,0.9)]
self.color = []
for i in range(0,self.a[0]-1):
if i%7 == 0:
self.color.append(self.full_colors[0])
elif (i-1)%7 == 0:
self.color.append(self.full_colors[1])
elif (i-2)%7 == 0:
self.color.append(self.full_colors[2])
elif (i-3)%7 == 0:
self.color.append(self.full_colors[3])
elif (i-4)%7 == 0:
self.color.append(self.full_colors[4])
elif (i-5)%7 == 0:
self.color.append(self.full_colors[5])
elif (i-6)%7 == 0:
self.color.append(self.full_colors[6])
###########Color generation ends here
#Total number of voltage source
self.volts_length = self.a[1]
self.analysisType = QtGui.QLabel()
self.top_grid.addWidget(self.analysisType,0,0)
self.listNode = QtGui.QLabel()
self.top_grid.addWidget(self.listNode,1,0)
self.listBranch = QtGui.QLabel()
self.top_grid.addWidget(self.listBranch,self.a[1]+2,0)
for i in range(0,self.a[1]):#a[0]-1
self.chkbox.append(QtGui.QCheckBox(self.obj_dataext.NBList[i]))
self.chkbox[i].setStyleSheet('color')
self.chkbox[i].setToolTip('<b>Check To Plot</b>' )
self.top_grid.addWidget(self.chkbox[i],i+2,0)
self.colorLab = QtGui.QLabel()
self.colorLab.setText('____')
self.colorLab.setStyleSheet(self.colorName(self.color[i])+'; font-weight = bold;')
self.top_grid.addWidget(self.colorLab,i+2,1)
for i in range(self.a[1],self.a[0]-1):#a[0]-1
self.chkbox.append(QtGui.QCheckBox(self.obj_dataext.NBList[i]))
self.chkbox[i].setToolTip('<b>Check To Plot</b>' )
self.top_grid.addWidget(self.chkbox[i],i+3,0)
self.colorLab = QtGui.QLabel()
self.colorLab.setText('____')
self.colorLab.setStyleSheet(self.colorName(self.color[i])+'; font-weight = bold;')
self.top_grid.addWidget(self.colorLab,i+3,1)
self.clear = QtGui.QPushButton("Clear")
self.warnning = QtGui.QLabel()
self.funcName = QtGui.QLabel()
self.funcExample = QtGui.QLabel()
self.plotbtn = QtGui.QPushButton("Plot")
#.........这里部分代码省略.........
示例10: OpenModelicaEditor
class OpenModelicaEditor(QtGui.QWidget):
def __init__(self, dir=None):
QtGui.QWidget.__init__(self)
self.obj_validation = Validation()
self.obj_appconfig = Appconfig()
self.projDir = dir
self.projName = os.path.basename(self.projDir)
self.ngspiceNetlist = os.path.join(self.projDir,self.projName+".cir.out")
self.modelicaNetlist = os.path.join(self.projDir,self.projName+".mo")
self.map_json = Appconfig.modelica_map_json
self.grid = QtGui.QGridLayout()
self.FileEdit = QtGui.QLineEdit()
self.FileEdit.setText(self.ngspiceNetlist)
self.grid.addWidget(self.FileEdit, 0, 0)
self.browsebtn = QtGui.QPushButton("Browse")
self.browsebtn.clicked.connect(self.browseFile)
self.grid.addWidget(self.browsebtn, 0, 1)
self.convertbtn = QtGui.QPushButton("Convert")
self.convertbtn.clicked.connect(self.callConverter)
self.grid.addWidget(self.convertbtn, 2, 1)
self.loadOMbtn = QtGui.QPushButton("Load OMEdit")
self.loadOMbtn.clicked.connect(self.callOMEdit)
self.grid.addWidget(self.loadOMbtn, 3, 1)
#self.setGeometry(300, 300, 350, 300)
self.setLayout(self.grid)
self.show()
def browseFile(self):
self.ngspiceNetlist = QtGui.QFileDialog.getOpenFileName(self, 'Open Ngspice file', BROWSE_LOCATION)
self.FileEdit.setText(self.ngspiceNetlist)
def callConverter(self):
try:
### TODO
self.cmd1 = "python ../ngspicetoModelica/NgspicetoModelica.py " + self.ngspiceNetlist + ' ' + self.map_json
#self.obj_workThread1 = Worker.WorkerThread(self.cmd1)
#self.obj_workThread1.start()
convert_process = Popen(self.cmd1, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
error_code = convert_process.stdout.read()
if not error_code:
self.msg = QtGui.QMessageBox()
self.msg.setText("Ngspice netlist successfully converted to OpenModelica netlist")
self.obj_appconfig.print_info("Ngspice netlist successfully converted to OpenModelica netlist")
self.msg.exec_()
else:
self.err_msg = QtGui.QErrorMessage()
self.err_msg.showMessage('Unable to convert NgSpice netlist to Modelica netlist. Check the netlist :'+ error_code)
self.err_msg.setWindowTitle("Ngspice to Modelica conversion error")
self.obj_appconfig.print_error(error_code)
except Exception as e:
self.msg = QtGui.QErrorMessage()
self.msg.showMessage('Unable to convert NgSpice netlist to Modelica netlist. Check the netlist :'+str(e))
self.msg.setWindowTitle("Ngspice to Modelica conversion error")
def callOMEdit(self):
if self.obj_validation.validateTool("OMEdit"):
self.cmd2 = "OMEdit " + self.modelicaNetlist
self.obj_workThread2 = Worker.WorkerThread(self.cmd2)
self.obj_workThread2.start()
print "OMEdit called"
self.obj_appconfig.print_info("OMEdit called")
else:
self.msg = QtGui.QMessageBox()
self.msgContent = "There was an error while opening OMEdit.<br/>\
Please make sure OpenModelica is installed in your system. <br/>\
To install it on Linux : Go to <a href=https://www.openmodelica.org/download/download-linux>OpenModelica Linux</a> and install nigthly build release.<br/>\
To install it on Windows : Go to <a href=https://www.openmodelica.org/download/download-windows>OpenModelica Windows</a> and install latest version.<br/>"
self.msg.setTextFormat(QtCore.Qt.RichText)
self.msg.setText(self.msgContent)
self.msg.setWindowTitle("Missing OpenModelica")
self.obj_appconfig.print_info(self.msgContent)
self.msg.exec_()
示例11: Application
class Application(QtGui.QMainWindow):
global project_name
"""
Its our main window of application
"""
def __init__(self,*args):
"""
Initialize main Application window
"""
#Calling __init__ of super class
QtGui.QMainWindow.__init__(self,*args)
#Creating require Object
self.obj_workspace = Workspace.Workspace()
self.obj_Mainview = MainView()
self.obj_kicad = Kicad(self.obj_Mainview.obj_dockarea)
self.obj_appconfig = Appconfig()
self.obj_validation = Validation()
#Initialize all widget
self.setCentralWidget(self.obj_Mainview)
self.initToolBar()
self.setGeometry(self.obj_appconfig._app_xpos,
self.obj_appconfig._app_ypos,
self.obj_appconfig._app_width,
self.obj_appconfig._app_heigth)
self.setWindowTitle(self.obj_appconfig._APPLICATION)
self.showMaximized()
self.setWindowIcon(QtGui.QIcon('res/images/logo.png'))
#self.show()
self.systemTrayIcon = QtGui.QSystemTrayIcon(self)
self.systemTrayIcon.setIcon(QtGui.QIcon('res/images/logo.png'))
self.systemTrayIcon.setVisible(True)
def initToolBar(self):
"""
This function initialize Tool Bar
"""
#Top Tool bar
self.newproj = QtGui.QAction(QtGui.QIcon('res/images/newProject.png'),'<b>New Project</b>',self)
self.newproj.setShortcut('Ctrl+N')
self.newproj.triggered.connect(self.new_project)
#self.newproj.connect(self.newproj,QtCore.SIGNAL('triggered()'),self,QtCore.SLOT(self.new_project()))
self.openproj = QtGui.QAction(QtGui.QIcon('res/images/openProject.png'),'<b>Open Project</b>',self)
self.openproj.setShortcut('Ctrl+O')
self.openproj.triggered.connect(self.open_project)
self.closeproj = QtGui.QAction(QtGui.QIcon('res/images/closeProject.png'),'<b>Close Project</b>',self)
self.closeproj.setShortcut('Ctrl+X')
self.closeproj.triggered.connect(self.close_project)
self.wrkspc = QtGui.QAction(QtGui.QIcon('res/images/workspace.ico'),'<b>Change Workspace</b>',self)
self.wrkspc.setShortcut('Ctrl+W')
self.wrkspc.triggered.connect(self.wrkspc_change)
self.helpfile = QtGui.QAction(QtGui.QIcon('res/images/helpProject.png'),'<b>Help</b>',self)
self.helpfile.setShortcut('Ctrl+H')
self.helpfile.triggered.connect(self.help_project)
self.topToolbar = self.addToolBar('Top Tool Bar')
self.topToolbar.addAction(self.newproj)
self.topToolbar.addAction(self.openproj)
self.topToolbar.addAction(self.closeproj)
self.topToolbar.addAction(self.wrkspc)
self.topToolbar.addAction(self.helpfile)
self.spacer = QtGui.QWidget()
self.spacer.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
self.topToolbar.addWidget(self.spacer)
self.logo = QtGui.QLabel()
self.logopic = QtGui.QPixmap(os.path.join('res/images','fosseeLogo.png'))
self.logopic = self.logopic.scaled(QSize(150,150),QtCore.Qt.KeepAspectRatio)
self.logo.setPixmap(self.logopic)
self.logo.setStyleSheet("padding:0 15px 0 0;")
self.topToolbar.addWidget(self.logo)
#Left Tool bar Action Widget
self.kicad = QtGui.QAction(QtGui.QIcon('res/images/kicad.png'),'<b>Open Schematic</b>',self)
self.kicad.triggered.connect(self.obj_kicad.openSchematic)
self.conversion = QtGui.QAction(QtGui.QIcon('res/images/ki-ng.png'),'<b>Convert Kicad to Ngspice</b>',self)
self.conversion.triggered.connect(self.obj_kicad.openKicadToNgspice)
self.ngspice = QtGui.QAction(QtGui.QIcon('res/images/ngspice.png'), '<b>Simulation</b>', self)
self.ngspice.triggered.connect(self.open_ngspice)
self.model = QtGui.QAction(QtGui.QIcon('res/images/model.png'),'<b>Model Editor</b>',self)
self.model.triggered.connect(self.open_modelEditor)
self.subcircuit=QtGui.QAction(QtGui.QIcon('res/images/subckt.png'),'<b>Subcircuit</b>',self)
self.subcircuit.triggered.connect(self.open_subcircuit)
self.nghdl = QtGui.QAction(QtGui.QIcon('res/images/nghdl.png'), '<b>Nghdl</b>', self)
self.nghdl.triggered.connect(self.open_nghdl)
self.omedit = QtGui.QAction(QtGui.QIcon('res/images/omedit.png'),'<b>Modelica Converter</b>',self)
self.omedit.triggered.connect(self.open_OMedit)
#.........这里部分代码省略.........
示例12: ModelEditorclass
class ModelEditorclass(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.savepathtest = '../deviceModelLibrary'
self.obj_appconfig = Appconfig()
self.newflag=0
self.layout = QtGui.QVBoxLayout()
self.splitter= QtGui.QSplitter()
self.grid= QtGui.QGridLayout()
self.splitter.setOrientation(QtCore.Qt.Vertical)
self.modeltable = QtGui.QTableWidget()
self.newbtn = QtGui.QPushButton('New')
self.newbtn.setToolTip('<b>Creating new Model Library</b>')
self.newbtn.clicked.connect(self.opennew)
self.editbtn = QtGui.QPushButton('Edit')
self.editbtn.setToolTip('<b>Editing current Model Library</b>')
self.editbtn.clicked.connect(self.openedit)
self.savebtn = QtGui.QPushButton('Save')
self.savebtn.setToolTip('<b>Saves the Model Library</b>')
self.savebtn.setDisabled(True)
self.savebtn.clicked.connect(self.savemodelfile)
self.removebtn = QtGui.QPushButton('Remove')
self.removebtn.setHidden(True)
self.removebtn.clicked.connect(self.removeparameter)
self.addbtn = QtGui.QPushButton('Add')
self.addbtn.setHidden(True)
self.addbtn.clicked.connect(self.addparameters)
self.uploadbtn = QtGui.QPushButton('Upload')
self.uploadbtn.setToolTip('<b>Uploading external .lib file to eSim</b>')
self.uploadbtn.clicked.connect(self.converttoxml)
self.grid.addWidget(self.newbtn, 1,2)
self.grid.addWidget(self.editbtn, 1,3)
self.grid.addWidget(self.savebtn, 1,4)
self.grid.addWidget(self.uploadbtn, 1,5)
self.grid.addWidget(self.removebtn, 8,4)
self.grid.addWidget(self.addbtn, 5,4)
self.radiobtnbox = QtGui.QButtonGroup()
self.diode = QtGui.QRadioButton('Diode')
self.diode.setDisabled(True)
self.bjt = QtGui.QRadioButton('BJT')
self.bjt.setDisabled(True)
self.mos = QtGui.QRadioButton('MOS')
self.mos.setDisabled(True)
self.jfet = QtGui.QRadioButton('JFET')
self.jfet.setDisabled(True)
self.igbt = QtGui.QRadioButton('IGBT')
self.igbt.setDisabled(True)
self.magnetic = QtGui.QRadioButton('Magnetic Core')
self.magnetic.setDisabled(True)
self.radiobtnbox.addButton(self.diode)
self.diode.clicked.connect(self.diode_click)
self.radiobtnbox.addButton(self.bjt)
self.bjt.clicked.connect(self.bjt_click)
self.radiobtnbox.addButton(self.mos)
self.mos.clicked.connect(self.mos_click)
self.radiobtnbox.addButton(self.jfet)
self.jfet.clicked.connect(self.jfet_click)
self.radiobtnbox.addButton(self.igbt)
self.igbt.clicked.connect(self.igbt_click)
self.radiobtnbox.addButton(self.magnetic)
self.magnetic.clicked.connect(self.magnetic_click)
self.types= QtGui.QComboBox()
self.types.setHidden(True)
self.grid.addWidget(self.types,2,2,2,3)
self.grid.addWidget(self.diode, 3,1)
self.grid.addWidget(self.bjt,4,1)
self.grid.addWidget(self.mos,5,1)
self.grid.addWidget(self.jfet,6,1)
self.grid.addWidget(self.igbt,7,1)
self.grid.addWidget(self.magnetic,8,1)
self.setLayout(self.grid)
self.show()
'''To create New Model file '''
def opennew(self):
self.addbtn.setHidden(True)
try:
self.removebtn.setHidden(True)
self.modeltable.setHidden(True)
except:
pass
os.chdir(self.savepathtest)
text, ok = QtGui.QInputDialog.getText(self, 'New Model','Enter Model Name:')
if ok:
self.newflag=1
self.diode.setDisabled(False)
self.bjt.setDisabled(False)
self.mos.setDisabled(False)
self.jfet.setDisabled(False)
self.igbt.setDisabled(False)
self.magnetic.setDisabled(False)
self.modelname = (str(text))
else:
pass
#.........这里部分代码省略.........
示例13: __init__
def __init__(self):
super(NewProjectInfo, self).__init__()
self.obj_validation = Validation()
self.obj_appconfig = Appconfig()
示例14: NewProjectInfo
class NewProjectInfo(QtGui.QWidget):
"""
This class is called when User create new Project.
"""
def __init__(self):
super(NewProjectInfo, self).__init__()
self.obj_validation = Validation()
self.obj_appconfig = Appconfig()
def createProject(self,projName):
"""
This function create Project related directories and files
"""
#print "Create Project Called"
self.projName= projName
self.workspace = self.obj_appconfig.default_workspace['workspace']
#self.projName = self.projEdit.text()
self.projName = str(self.projName).rstrip().lstrip() #Remove leading and trailing space
self.projDir = os.path.join(self.workspace,str(self.projName))
#Validation for newProject
if self.projName == "":
self.reply = "NONE"
else:
self.reply = self.obj_validation.validateNewproj(str(self.projDir))
#Checking Validations Response
if self.reply == "VALID":
print "Validated : Creating project directory"
#create project directory
try:
os.mkdir(self.projDir)
self.close()
self.projFile = os.path.join(self.projDir,self.projName+".proj")
f = open(self.projFile,"w")
except:
#print "Some Thing Went Wrong"
self.msg = QtGui.QErrorMessage(self)
self.msg.showMessage('Unable to create project. Please make sure you have write permission on '+self.workspace)
self.msg.setWindowTitle("Error Message")
f.write("schematicFile " + self.projName+".sch\n")
f.close()
#Now Change the current working project
newprojlist = []
#self.obj_appconfig = Appconfig()
self.obj_appconfig.current_project['ProjectName'] = self.projDir
newprojlist.append(self.projName+'.proj')
self.obj_appconfig.project_explorer[self.projDir] = newprojlist
self.obj_appconfig.print_info('New project created : ' + self.projName)
self.obj_appconfig.print_info('Current project is : ' + self.projDir)
json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
return self.projDir, newprojlist
elif self.reply == "CHECKEXIST":
#print "Project already exist"
self.msg = QtGui.QErrorMessage(self)
self.msg.showMessage('The project "'+self.projName+'" already exist.Please select the different name or delete existing project')
self.msg.setWindowTitle("Error Message")
elif self.reply == "CHECKNAME":
#print "Name is not proper"
self.msg = QtGui.QErrorMessage(self)
self.msg.showMessage('The project name should not contain space between them')
self.msg.setWindowTitle("Error Message")
elif self.reply == "NONE":
#print "Empty Project Name"
self.msg = QtGui.QErrorMessage(self)
self.msg.showMessage('The project name cannot be empty')
self.msg.setWindowTitle("Error Message")
def cancelProject(self):
self.close()
示例15: Application
class Application(QtGui.QMainWindow):
global project_name
"""
Its our main window of application
"""
def __init__(self,*args):
"""
Initialize main Application window
"""
#Calling __init__ of super class
QtGui.QMainWindow.__init__(self,*args)
#Creating require Object
self.obj_workspace = Workspace.Workspace()
self.obj_Mainview = MainView()
self.obj_kicad = Kicad(self.obj_Mainview.obj_dockarea)
self.obj_appconfig = Appconfig()
#Initialize all widget
self.setCentralWidget(self.obj_Mainview)
self.initToolBar()
self.setGeometry(self.obj_appconfig._app_xpos,
self.obj_appconfig._app_ypos,
self.obj_appconfig._app_width,
self.obj_appconfig._app_heigth)
self.setWindowTitle(self.obj_appconfig._APPLICATION)
self.showMaximized()
self.setWindowIcon(QtGui.QIcon('../../images/logo.png'))
#self.show()
def initToolBar(self):
"""
This function initialize Tool Bar
"""
#Top Tool bar
self.newproj = QtGui.QAction(QtGui.QIcon('../../images/newProject.png'),'<b>New Project</b>',self)
self.newproj.setShortcut('Ctrl+N')
self.newproj.triggered.connect(self.new_project)
#self.newproj.connect(self.newproj,QtCore.SIGNAL('triggered()'),self,QtCore.SLOT(self.new_project()))
self.openproj = QtGui.QAction(QtGui.QIcon('../../images/openProject.png'),'<b>Open Project</b>',self)
self.openproj.setShortcut('Ctrl+O')
self.openproj.triggered.connect(self.open_project)
self.exitproj = QtGui.QAction(QtGui.QIcon('../../images/closeProject.png'),'<b>Exit</b>',self)
self.exitproj.setShortcut('Ctrl+X')
self.exitproj.triggered.connect(self.exit_project)
self.helpfile = QtGui.QAction(QtGui.QIcon('../../images/helpProject.png'),'<b>Help</b>',self)
self.helpfile.setShortcut('Ctrl+H')
self.helpfile.triggered.connect(self.help_project)
self.topToolbar = self.addToolBar('Top Tool Bar')
self.topToolbar.addAction(self.newproj)
self.topToolbar.addAction(self.openproj)
self.topToolbar.addAction(self.exitproj)
self.topToolbar.addAction(self.helpfile)
self.spacer = QtGui.QWidget()
self.spacer.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
self.topToolbar.addWidget(self.spacer)
self.logo = QtGui.QLabel()
self.logopic = QtGui.QPixmap(os.path.join(os.path.abspath('../..'),'images','fosseeLogo.png'))
self.logopic = self.logopic.scaled(QSize(150,150),QtCore.Qt.KeepAspectRatio)
self.logo.setPixmap(self.logopic)
self.logo.setStyleSheet("padding:0 15px 0 0;")
self.topToolbar.addWidget(self.logo)
#Left Tool bar Action Widget
self.kicad = QtGui.QAction(QtGui.QIcon('../../images/kicad.png'),'<b>Open Schematic</b>',self)
self.kicad.triggered.connect(self.obj_kicad.openSchematic)
self.conversion = QtGui.QAction(QtGui.QIcon('../../images/ki-ng.png'),'<b>Convert Kicad to Ngspice</b>',self)
self.conversion.triggered.connect(self.obj_kicad.openKicadToNgspice)
self.ngspice = QtGui.QAction(QtGui.QIcon('../../images/ngspice.png'), '<b>Simulation</b>', self)
self.ngspice.triggered.connect(self.open_ngspice)
self.footprint = QtGui.QAction(QtGui.QIcon('../../images/footprint.png'),'<b>Footprint Editor</b>',self)
self.footprint.triggered.connect(self.obj_kicad.openFootprint)
self.pcb = QtGui.QAction(QtGui.QIcon('../../images/pcb.png'),'<b>PCB Layout</b>',self)
self.pcb.triggered.connect(self.obj_kicad.openLayout)
self.model = QtGui.QAction(QtGui.QIcon('../../images/model.png'),'<b>Model Editor</b>',self)
self.model.triggered.connect(self.open_modelEditor)
self.subcircuit=QtGui.QAction(QtGui.QIcon('../../images/subckt.png'),'<b>Subcircuit</b>',self)
self.subcircuit.triggered.connect(self.open_subcircuit)
#Adding Action Widget to tool bar
self.lefttoolbar = QtGui.QToolBar('Left ToolBar')
self.addToolBar(QtCore.Qt.LeftToolBarArea, self.lefttoolbar)
self.lefttoolbar.addAction(self.kicad)
self.lefttoolbar.addAction(self.conversion)
self.lefttoolbar.addAction(self.ngspice)
self.lefttoolbar.addAction(self.footprint)
self.lefttoolbar.addAction(self.pcb)
#.........这里部分代码省略.........