-
Notifications
You must be signed in to change notification settings - Fork 5
/
loaderdialog.py
112 lines (96 loc) · 3.35 KB
/
loaderdialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# fileloader.py ---
#
# Filename: fileloader.py
# Description:
# Author:
# Maintainer:
# Created: Mon Feb 25 15:59:54 2013 (+0530)
# Version:
# Last-Updated: Wed May 22 12:30:14 2013 (+0530)
# By: subha
# Update #: 106
# URL:
# Keywords:
# Compatibility:
#
#
# Commentary:
#
# Dialog for loading model files
#
#
# Change log:
#
#
#
#
# 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 3, 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; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth
# Floor, Boston, MA 02110-1301, USA.
#
#
# Code:
import sys
from PyQt4 import QtGui,QtCore,Qt
import moose
import os
import posixpath
class LoaderDialog(QtGui.QFileDialog):
# Update ftypes to include new file types
ftypes='All Supported Files (*.cspace *.g *.xml *.p);; CSPACE (*.cspace);; GENESIS (*.g);; GENESIS Prototype (*.p);; NeuroML/SBML (*.xml)'
target_default = '' # The default target when loading a model
def __init__(self, *args):
self.modelpath = None
super(LoaderDialog, self).__init__(*args)
self.setNameFilter(self.tr(self.ftypes))
self.setNameFilterDetailsVisible(True)
self.setReadOnly(True)
self.setFileMode(self.ExistingFile)
# self.targetPanel = QtGui.QFrame()
# self.targetLabel = QtGui.QLabel('Model name')
# self.targetText = QtGui.QLineEdit(self.target_default)
# form = QtGui.QFormLayout()
# form.addRow(self.targetLabel, self.targetText)
# self.modelChoiceBox = QtGui.QGroupBox('Model name')
# self.replaceExistingButton = QtGui.QRadioButton('&Replace current model')
# self.mergeExistingButton = QtGui.QRadioButton('&Keep current model')
# self.replaceExistingButton.setChecked(True)
# vbox = QtGui.QVBoxLayout()
# vbox.addWidget(self.replaceExistingButton)
# vbox.addWidget(self.mergeExistingButton)
# self.modelChoiceBox.setLayout(vbox)
# self.targetPanel.setLayout(form)
# self.layout().addWidget(self.targetPanel)
# self.layout().addWidget(self.modelChoiceBox)
self.fileSelected.connect(self.fileSelectedSlot)
def fileSelectedSlot(self, fpath):
"""On selecting a file, this function will cause the target location to change to:
/model/filename_minus_extension
"""
self.modelpath = os.path.splitext(os.path.basename(str(fpath)))[0]
# def isReplace(self):
# return self.replaceExistingButton.isChecked()
# def isMerge(self):
# return self.mergeExistingButton.isChecked()
def getTargetPath(self):
return self.modelpath
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
QtGui.qApp = app
mw = LoaderDialog()
mw.show()
# mw.exec_()
sys.exit(app.exec_())
#
# fileloader.py ends here