pygmi 2.2.7__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygmi-2.2.7/LICENSE.txt +623 -0
- pygmi-2.2.7/MANIFEST.in +7 -0
- pygmi-2.2.7/PKG-INFO +47 -0
- pygmi-2.2.7/README.md +55 -0
- pygmi-2.2.7/README.rst +20 -0
- pygmi-2.2.7/log.txt +242 -0
- pygmi-2.2.7/pygmi/__init__.py +22 -0
- pygmi-2.2.7/pygmi/clust/__init__.py +4 -0
- pygmi-2.2.7/pygmi/clust/crisp_clust.py +708 -0
- pygmi-2.2.7/pygmi/clust/datatypes.py +65 -0
- pygmi-2.2.7/pygmi/clust/fuzzy_clust.py +906 -0
- pygmi-2.2.7/pygmi/clust/graphs.py +421 -0
- pygmi-2.2.7/pygmi/clust/graphtool.py +667 -0
- pygmi-2.2.7/pygmi/clust/menu.py +139 -0
- pygmi-2.2.7/pygmi/clust/var_ratio.py +92 -0
- pygmi-2.2.7/pygmi/clust/xie_beni.py +93 -0
- pygmi-2.2.7/pygmi/helpdocs/linepointer.png +0 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.main.html +31 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.ddisp.html +15 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.iodefs.exportkmz.html +13 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.iodefs.importpicture.html +16 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.layer.html +17 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.mext.html +44 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.misc.rangedcopy.html +16 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.param.html +37 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.prof.html +32 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.pview.html +26 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.gradients.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.tilt.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.visibility.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datagrid.html +13 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datamerge.html +11 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datareproj.html +11 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.rtp.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.ginterp.html +31 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.igrf.html +20 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.normalisation.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.smooth.html +22 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.tiltdepth.html +20 -0
- pygmi-2.2.7/pygmi/images/Help.png +0 -0
- pygmi-2.2.7/pygmi/images/bringtofront.png +0 -0
- pygmi-2.2.7/pygmi/images/cgs2.emf +0 -0
- pygmi-2.2.7/pygmi/images/delete.png +0 -0
- pygmi-2.2.7/pygmi/images/linepointer.png +0 -0
- pygmi-2.2.7/pygmi/images/logo256.ico +0 -0
- pygmi-2.2.7/pygmi/images/logo256.png +0 -0
- pygmi-2.2.7/pygmi/images/pointer.png +0 -0
- pygmi-2.2.7/pygmi/images/pygmi.png +0 -0
- pygmi-2.2.7/pygmi/images/sendtoback.png +0 -0
- pygmi-2.2.7/pygmi/main.py +1037 -0
- pygmi-2.2.7/pygmi/menu_default.py +327 -0
- pygmi-2.2.7/pygmi/misc.py +147 -0
- pygmi-2.2.7/pygmi/pfmod/__init__.py +6 -0
- pygmi-2.2.7/pygmi/pfmod/cubes.py +1488 -0
- pygmi-2.2.7/pygmi/pfmod/datatypes.py +292 -0
- pygmi-2.2.7/pygmi/pfmod/grvmag3d.py +1265 -0
- pygmi-2.2.7/pygmi/pfmod/iodefs.py +1001 -0
- pygmi-2.2.7/pygmi/pfmod/menu.py +107 -0
- pygmi-2.2.7/pygmi/pfmod/misc.py +301 -0
- pygmi-2.2.7/pygmi/pfmod/pfmod.py +248 -0
- pygmi-2.2.7/pygmi/pfmod/tab_ddisp.py +425 -0
- pygmi-2.2.7/pygmi/pfmod/tab_layer.py +490 -0
- pygmi-2.2.7/pygmi/pfmod/tab_mext.py +544 -0
- pygmi-2.2.7/pygmi/pfmod/tab_param.py +548 -0
- pygmi-2.2.7/pygmi/pfmod/tab_prof.py +946 -0
- pygmi-2.2.7/pygmi/pfmod/tab_pview.py +740 -0
- pygmi-2.2.7/pygmi/raster/IGRF11.COF +1635 -0
- pygmi-2.2.7/pygmi/raster/__init__.py +14 -0
- pygmi-2.2.7/pygmi/raster/cooper.py +718 -0
- pygmi-2.2.7/pygmi/raster/dataprep.py +1640 -0
- pygmi-2.2.7/pygmi/raster/datatypes.py +123 -0
- pygmi-2.2.7/pygmi/raster/equation_editor.py +256 -0
- pygmi-2.2.7/pygmi/raster/ginterp.py +1901 -0
- pygmi-2.2.7/pygmi/raster/graphs.py +531 -0
- pygmi-2.2.7/pygmi/raster/igrf.py +860 -0
- pygmi-2.2.7/pygmi/raster/iodefs.py +813 -0
- pygmi-2.2.7/pygmi/raster/menu.py +307 -0
- pygmi-2.2.7/pygmi/raster/normalisation.py +187 -0
- pygmi-2.2.7/pygmi/raster/show_table.py +245 -0
- pygmi-2.2.7/pygmi/raster/smooth.py +406 -0
- pygmi-2.2.7/pygmi/raster/tiltdepth.py +590 -0
- pygmi-2.2.7/pygmi/seis/__init__.py +0 -0
- pygmi-2.2.7/pygmi/seis/beachball.py +751 -0
- pygmi-2.2.7/pygmi/seis/datatypes.py +605 -0
- pygmi-2.2.7/pygmi/seis/del_rec.py +410 -0
- pygmi-2.2.7/pygmi/seis/iodefs.py +1261 -0
- pygmi-2.2.7/pygmi/seis/menu.py +136 -0
- pygmi-2.2.7/pygmi/seis/scan_imp.py +795 -0
- pygmi-2.2.7/pygmi/test/__init__.py +6 -0
- pygmi-2.2.7/pygmi/test/pfmod.py +212 -0
- pygmi-2.2.7/pygmi/test/tests.py +39 -0
- pygmi-2.2.7/pygmi/vector/__init__.py +7 -0
- pygmi-2.2.7/pygmi/vector/datatypes.py +74 -0
- pygmi-2.2.7/pygmi/vector/graphs.py +443 -0
- pygmi-2.2.7/pygmi/vector/iodefs.py +345 -0
- pygmi-2.2.7/pygmi/vector/menu.py +127 -0
- pygmi-2.2.7/pygmi.egg-info/PKG-INFO +47 -0
- pygmi-2.2.7/pygmi.egg-info/SOURCES.txt +105 -0
- pygmi-2.2.7/pygmi.egg-info/dependency_links.txt +1 -0
- pygmi-2.2.7/pygmi.egg-info/entry_points.txt +3 -0
- pygmi-2.2.7/pygmi.egg-info/not-zip-safe +1 -0
- pygmi-2.2.7/pygmi.egg-info/requires.txt +7 -0
- pygmi-2.2.7/pygmi.egg-info/top_level.txt +1 -0
- pygmi-2.2.7/quickstart.py +35 -0
- pygmi-2.2.7/setup.cfg +8 -0
- pygmi-2.2.7/setup.py +80 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Name: menu_default.py (part of PyGMI)
|
|
3
|
+
#
|
|
4
|
+
# Author: Patrick Cole
|
|
5
|
+
# E-Mail: pcole@geoscience.org.za
|
|
6
|
+
#
|
|
7
|
+
# Copyright: (c) 2013 Council for Geoscience
|
|
8
|
+
# Licence: GPL-3.0
|
|
9
|
+
#
|
|
10
|
+
# This file is part of PyGMI
|
|
11
|
+
#
|
|
12
|
+
# PyGMI is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# PyGMI is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU General Public License
|
|
23
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
+
# -----------------------------------------------------------------------------
|
|
25
|
+
""" This is the default set of menus for the main interface. It also includes
|
|
26
|
+
the about box """
|
|
27
|
+
|
|
28
|
+
from PyQt4 import QtGui, QtCore
|
|
29
|
+
import webbrowser
|
|
30
|
+
import os
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class FileMenu(object):
|
|
34
|
+
"""
|
|
35
|
+
Widget class to call the main interface
|
|
36
|
+
|
|
37
|
+
This widget class creates the raster menus to be found on the main
|
|
38
|
+
interface. Normal as well as context menus are defined here.
|
|
39
|
+
|
|
40
|
+
Attributes
|
|
41
|
+
----------
|
|
42
|
+
parent : MainWidget
|
|
43
|
+
Reference to MainWidget class found in main.py
|
|
44
|
+
"""
|
|
45
|
+
def __init__(self, parent):
|
|
46
|
+
|
|
47
|
+
self.parent = parent
|
|
48
|
+
context_menu = self.parent.context_menu
|
|
49
|
+
|
|
50
|
+
# File Menu
|
|
51
|
+
|
|
52
|
+
self.menufile = QtGui.QMenu(parent.menubar)
|
|
53
|
+
self.menufile.setTitle("File")
|
|
54
|
+
parent.menubar.addAction(self.menufile.menuAction())
|
|
55
|
+
|
|
56
|
+
# self.action_open_project = QtGui.QAction(parent)
|
|
57
|
+
# self.action_open_project.setText("Open Project")
|
|
58
|
+
# self.menufile.addAction(self.action_open_project)
|
|
59
|
+
|
|
60
|
+
# self.action_save_project = QtGui.QAction(parent)
|
|
61
|
+
# self.action_save_project.setText("Save Project")
|
|
62
|
+
# self.menufile.addAction(self.action_save_project)
|
|
63
|
+
|
|
64
|
+
self.action_exit = QtGui.QAction(parent)
|
|
65
|
+
# self.menufile.addSeparator()
|
|
66
|
+
self.action_exit.setText("Exit")
|
|
67
|
+
self.menufile.addAction(self.action_exit)
|
|
68
|
+
|
|
69
|
+
QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL("triggered()"),
|
|
70
|
+
parent.close)
|
|
71
|
+
|
|
72
|
+
# Context menus
|
|
73
|
+
context_menu['Basic'].addSeparator()
|
|
74
|
+
|
|
75
|
+
self.action_bandselect = QtGui.QAction(self.parent)
|
|
76
|
+
self.action_bandselect.setText("Select Bands")
|
|
77
|
+
context_menu['Basic'].addAction(self.action_bandselect)
|
|
78
|
+
self.action_bandselect.triggered.connect(self.bandselect)
|
|
79
|
+
|
|
80
|
+
def bandselect(self):
|
|
81
|
+
""" Select bands """
|
|
82
|
+
self.parent.launch_context_item_indata(ComboBoxBasic)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class ComboBoxBasic(QtGui.QDialog):
|
|
86
|
+
"""
|
|
87
|
+
A basic combo box application
|
|
88
|
+
|
|
89
|
+
Attributes
|
|
90
|
+
----------
|
|
91
|
+
parent : parent
|
|
92
|
+
reference to the parent routine
|
|
93
|
+
indata : dictionary
|
|
94
|
+
dictionary of input datasets
|
|
95
|
+
outdata : dictionary
|
|
96
|
+
dictionary of output datasets
|
|
97
|
+
"""
|
|
98
|
+
def __init__(self, parent=None):
|
|
99
|
+
QtGui.QDialog.__init__(self, parent)
|
|
100
|
+
|
|
101
|
+
self.parent = parent
|
|
102
|
+
self.indata = {}
|
|
103
|
+
self.outdata = {}
|
|
104
|
+
|
|
105
|
+
# create GUI
|
|
106
|
+
self.setWindowTitle('Band Selection')
|
|
107
|
+
|
|
108
|
+
self.vbox = QtGui.QVBoxLayout()
|
|
109
|
+
self.setLayout(self.vbox)
|
|
110
|
+
|
|
111
|
+
self.combo = QtGui.QListWidget()
|
|
112
|
+
self.combo.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
|
|
113
|
+
|
|
114
|
+
self.vbox.addWidget(self.combo)
|
|
115
|
+
|
|
116
|
+
self.buttonbox = QtGui.QDialogButtonBox()
|
|
117
|
+
self.buttonbox.setOrientation(QtCore.Qt.Horizontal)
|
|
118
|
+
self.buttonbox.setCenterButtons(True)
|
|
119
|
+
self.buttonbox.setStandardButtons(
|
|
120
|
+
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok)
|
|
121
|
+
|
|
122
|
+
self.vbox.addWidget(self.buttonbox)
|
|
123
|
+
|
|
124
|
+
self.buttonbox.accepted.connect(self.accept)
|
|
125
|
+
self.buttonbox.rejected.connect(self.reject)
|
|
126
|
+
|
|
127
|
+
def run(self):
|
|
128
|
+
""" runs class """
|
|
129
|
+
self.parent.scene.selectedItems()[0].update_indata()
|
|
130
|
+
my_class = self.parent.scene.selectedItems()[0].my_class
|
|
131
|
+
|
|
132
|
+
data = my_class.indata.copy()
|
|
133
|
+
|
|
134
|
+
for j in data.keys():
|
|
135
|
+
if j is 'Model3D' or j is 'Seis':
|
|
136
|
+
continue
|
|
137
|
+
|
|
138
|
+
tmp = []
|
|
139
|
+
for i in data[j]:
|
|
140
|
+
tmp.append(i.dataid)
|
|
141
|
+
self.combo.addItems(tmp)
|
|
142
|
+
|
|
143
|
+
if len(tmp) == 0:
|
|
144
|
+
return
|
|
145
|
+
|
|
146
|
+
tmp = self.exec_()
|
|
147
|
+
|
|
148
|
+
if tmp != 1:
|
|
149
|
+
return
|
|
150
|
+
|
|
151
|
+
for j in data.keys():
|
|
152
|
+
if j is 'Model3D' or j is 'Seis':
|
|
153
|
+
continue
|
|
154
|
+
atmp = [i.text() for i in self.combo.selectedItems()]
|
|
155
|
+
|
|
156
|
+
if len(atmp) > 0:
|
|
157
|
+
dtmp = []
|
|
158
|
+
for i in data[j]:
|
|
159
|
+
if i.dataid in atmp:
|
|
160
|
+
dtmp.append(i)
|
|
161
|
+
data[j] = dtmp
|
|
162
|
+
|
|
163
|
+
my_class.indata = data
|
|
164
|
+
|
|
165
|
+
if hasattr(my_class, 'data_init'):
|
|
166
|
+
my_class.data_init()
|
|
167
|
+
|
|
168
|
+
return True
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class HelpMenu(object):
|
|
172
|
+
"""
|
|
173
|
+
Widget class to call the main interface
|
|
174
|
+
|
|
175
|
+
Attributes
|
|
176
|
+
----------
|
|
177
|
+
parent : parent
|
|
178
|
+
reference to the parent routine
|
|
179
|
+
"""
|
|
180
|
+
def __init__(self, parent):
|
|
181
|
+
|
|
182
|
+
self.parent = parent
|
|
183
|
+
|
|
184
|
+
# Help Menu
|
|
185
|
+
|
|
186
|
+
self.menuhelp = QtGui.QMenu(parent.menubar)
|
|
187
|
+
parent.menubar.addAction(self.menuhelp.menuAction())
|
|
188
|
+
|
|
189
|
+
self.action_help = QtGui.QAction(self.parent)
|
|
190
|
+
self.action_about = QtGui.QAction(self.parent)
|
|
191
|
+
|
|
192
|
+
self.menuhelp.addAction(self.action_help)
|
|
193
|
+
self.menuhelp.addAction(self.action_about)
|
|
194
|
+
|
|
195
|
+
self.menuhelp.setTitle("Help")
|
|
196
|
+
self.action_help.setText("Help")
|
|
197
|
+
self.action_about.setText("About")
|
|
198
|
+
|
|
199
|
+
self.action_about.triggered.connect(self.about)
|
|
200
|
+
self.action_help.triggered.connect(self.webhelp)
|
|
201
|
+
|
|
202
|
+
def about(self):
|
|
203
|
+
""" PyGMI About Box """
|
|
204
|
+
|
|
205
|
+
msg = '''\
|
|
206
|
+
Name: PyGMI - Python Geophysical Modelling and Interpretation
|
|
207
|
+
Version: '''+self.parent.__version__+'''
|
|
208
|
+
Author: Patrick Cole
|
|
209
|
+
E-Mail: pcole@geoscience.org.za
|
|
210
|
+
|
|
211
|
+
Copyright: (c) 2015 Council for Geoscience
|
|
212
|
+
Licence: GPL-3.0
|
|
213
|
+
|
|
214
|
+
PyGMI is free software: you can redistribute it and/or modify it under
|
|
215
|
+
the terms of the GNU General Public License as published by the Free
|
|
216
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
|
217
|
+
any later version.
|
|
218
|
+
|
|
219
|
+
PyGMI is distributed in the hope that it will be useful, but
|
|
220
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
221
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
222
|
+
See the GNU General Public License for more details.
|
|
223
|
+
|
|
224
|
+
You should have received a copy of the GNU General Public License along
|
|
225
|
+
with this program. If not, see http://www.gnu.org/licenses/'''
|
|
226
|
+
|
|
227
|
+
QtGui.QMessageBox.about(self.parent, 'PyGMI', msg)
|
|
228
|
+
|
|
229
|
+
def webhelp(self):
|
|
230
|
+
""" Help File"""
|
|
231
|
+
webbrowser.open(r'http://patrick-cole.github.io/pygmi/')
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class HelpButton(QtGui.QPushButton):
|
|
235
|
+
"""
|
|
236
|
+
Help Button
|
|
237
|
+
|
|
238
|
+
Convenience class to add an image to a pushbutton
|
|
239
|
+
"""
|
|
240
|
+
def __init__(self, htmlfile=None, parent=None):
|
|
241
|
+
QtGui.QPushButton.__init__(self, parent)
|
|
242
|
+
|
|
243
|
+
self.htmlfile = htmlfile
|
|
244
|
+
|
|
245
|
+
self.ipth = os.path.dirname(__file__)+r'/images/'
|
|
246
|
+
self.setMinimumHeight(48)
|
|
247
|
+
self.setMinimumWidth(48)
|
|
248
|
+
|
|
249
|
+
self.setIcon(QtGui.QIcon(self.ipth+'help.png'))
|
|
250
|
+
self.setIconSize(self.minimumSize())
|
|
251
|
+
self.clicked.connect(self.help_docs)
|
|
252
|
+
self.setFlat(True)
|
|
253
|
+
|
|
254
|
+
def help_docs(self):
|
|
255
|
+
"""
|
|
256
|
+
Help Routine
|
|
257
|
+
"""
|
|
258
|
+
HelpDocs(self, self.htmlfile)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class HelpDocs(QtGui.QDialog):
|
|
262
|
+
"""
|
|
263
|
+
A basic combo box application
|
|
264
|
+
|
|
265
|
+
Attributes
|
|
266
|
+
----------
|
|
267
|
+
parent : parent
|
|
268
|
+
reference to the parent routine
|
|
269
|
+
indata : dictionary
|
|
270
|
+
dictionary of input datasets
|
|
271
|
+
outdata : dictionary
|
|
272
|
+
dictionary of output datasets
|
|
273
|
+
"""
|
|
274
|
+
def __init__(self, parent=None, helptxt=None):
|
|
275
|
+
QtGui.QDialog.__init__(self, parent)
|
|
276
|
+
|
|
277
|
+
self.parent = parent
|
|
278
|
+
self.indata = {}
|
|
279
|
+
self.outdata = {}
|
|
280
|
+
|
|
281
|
+
ipth = os.path.dirname(__file__)+r'/helpdocs/'
|
|
282
|
+
opth = os.getcwd()
|
|
283
|
+
|
|
284
|
+
if helptxt is None:
|
|
285
|
+
helptxt = 'No Help Available.'
|
|
286
|
+
else:
|
|
287
|
+
os.chdir(ipth)
|
|
288
|
+
itxt = open(helptxt+'.html')
|
|
289
|
+
helptxt = itxt.read()
|
|
290
|
+
itxt.close()
|
|
291
|
+
|
|
292
|
+
# create GUI
|
|
293
|
+
self.setWindowTitle('Help!')
|
|
294
|
+
|
|
295
|
+
self.vbox = QtGui.QVBoxLayout()
|
|
296
|
+
self.setLayout(self.vbox)
|
|
297
|
+
|
|
298
|
+
self.text = QtGui.QTextBrowser()
|
|
299
|
+
self.text.setOpenExternalLinks(True)
|
|
300
|
+
self.text.append(helptxt)
|
|
301
|
+
self.text.setMinimumWidth(480)
|
|
302
|
+
self.text.setMinimumHeight(360)
|
|
303
|
+
self.text.setFrameShape(QtGui.QFrame.NoFrame)
|
|
304
|
+
cursor = QtGui.QTextCursor()
|
|
305
|
+
cursor.setPosition(0)
|
|
306
|
+
self.text.setTextCursor(cursor)
|
|
307
|
+
|
|
308
|
+
ptmp = self.text.palette()
|
|
309
|
+
ptmp.setColor(0, 9, ptmp.color(10))
|
|
310
|
+
ptmp.setColor(1, 9, ptmp.color(10))
|
|
311
|
+
ptmp.setColor(2, 9, ptmp.color(10))
|
|
312
|
+
self.text.setPalette(ptmp)
|
|
313
|
+
|
|
314
|
+
self.vbox.addWidget(self.text)
|
|
315
|
+
|
|
316
|
+
self.buttonbox = QtGui.QDialogButtonBox()
|
|
317
|
+
self.buttonbox.setOrientation(QtCore.Qt.Horizontal)
|
|
318
|
+
self.buttonbox.setCenterButtons(True)
|
|
319
|
+
self.buttonbox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
|
320
|
+
|
|
321
|
+
self.vbox.addWidget(self.buttonbox)
|
|
322
|
+
|
|
323
|
+
self.buttonbox.accepted.connect(self.accept)
|
|
324
|
+
|
|
325
|
+
self.exec_()
|
|
326
|
+
|
|
327
|
+
os.chdir(opth)
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# -----------------------------------------------------------------------------
|
|
3
|
+
# Name: misc.py (part of PyGMI)
|
|
4
|
+
#
|
|
5
|
+
# Author: Patrick Cole
|
|
6
|
+
# E-Mail: pcole@geoscience.org.za
|
|
7
|
+
#
|
|
8
|
+
# Copyright: (c) 2015 Council for Geoscience
|
|
9
|
+
# Licence: GPL-3.0
|
|
10
|
+
#
|
|
11
|
+
# This file is part of PyGMI
|
|
12
|
+
#
|
|
13
|
+
# PyGMI is free software: you can redistribute it and/or modify
|
|
14
|
+
# it under the terms of the GNU General Public License as published by
|
|
15
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
16
|
+
# (at your option) any later version.
|
|
17
|
+
#
|
|
18
|
+
# PyGMI is distributed in the hope that it will be useful,
|
|
19
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
+
# GNU General Public License for more details.
|
|
22
|
+
#
|
|
23
|
+
# You should have received a copy of the GNU General Public License
|
|
24
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
25
|
+
# -----------------------------------------------------------------------------
|
|
26
|
+
""" Misc is a collection of routines which can be used in PyGMI in general.
|
|
27
|
+
|
|
28
|
+
ptimer is utility module used to simplify checking how much time has passed
|
|
29
|
+
in a program. It also outputs a message at the point when called. """
|
|
30
|
+
|
|
31
|
+
from PyQt4 import QtGui
|
|
32
|
+
import time
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
PBAR_STYLE = """
|
|
36
|
+
QProgressBar{
|
|
37
|
+
border: 2px solid grey;
|
|
38
|
+
border-radius: 5px;
|
|
39
|
+
text-align: center
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
QProgressBar::chunk {
|
|
43
|
+
background: qlineargradient(x1: 0.5, y1: 0, x2: 0.5, y2: 1, stop: 0 green, stop: 1 white);
|
|
44
|
+
width: 10px;
|
|
45
|
+
}
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
# background: qlineargradient(x1: 0.5, y1: 0, x2: 0.5, y2: 1, stop: 0 green, stop: 1 white);
|
|
49
|
+
# background-color: #05B8CC;
|
|
50
|
+
|
|
51
|
+
class PTime(object):
|
|
52
|
+
""" Main class in the ptimer module. Once activated, this class keeps track
|
|
53
|
+
of all time since activation. Times are stored whenever its methods are
|
|
54
|
+
called.
|
|
55
|
+
|
|
56
|
+
Attributes
|
|
57
|
+
----------
|
|
58
|
+
tchk : list
|
|
59
|
+
List of times generated by the time.clock routine.
|
|
60
|
+
"""
|
|
61
|
+
def __init__(self):
|
|
62
|
+
self.tchk = [time.clock()]
|
|
63
|
+
|
|
64
|
+
def since_first_call(self, msg='since first call'):
|
|
65
|
+
""" This function prints out a message and lets you know the time
|
|
66
|
+
passed since the first call.
|
|
67
|
+
|
|
68
|
+
Parameters
|
|
69
|
+
----------
|
|
70
|
+
msg : str
|
|
71
|
+
Optional message
|
|
72
|
+
"""
|
|
73
|
+
self.tchk.append(time.clock())
|
|
74
|
+
print(msg, 'at time (s):', self.tchk[-1] - self.tchk[0])
|
|
75
|
+
|
|
76
|
+
def since_last_call(self, msg='since last call'):
|
|
77
|
+
""" This function prints out a message and lets you know the time
|
|
78
|
+
passed since the last call.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
msg : str
|
|
83
|
+
Optional message"""
|
|
84
|
+
|
|
85
|
+
self.tchk.append(time.clock())
|
|
86
|
+
print(msg, 'time(s):', self.tchk[-1] - self.tchk[-2],
|
|
87
|
+
'since last call')
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class ProgressBar(QtGui.QProgressBar):
|
|
91
|
+
"""
|
|
92
|
+
Progress Bar routine which expands the QProgressBar class slightly so that
|
|
93
|
+
there is a time function as well as a convenient of calling it via an
|
|
94
|
+
iterable.
|
|
95
|
+
|
|
96
|
+
Attributes
|
|
97
|
+
----------
|
|
98
|
+
otime : integer
|
|
99
|
+
This is the original time recorded when the progress bar starts.
|
|
100
|
+
"""
|
|
101
|
+
def __init__(self, parent=None):
|
|
102
|
+
QtGui.QProgressBar.__init__(self, parent)
|
|
103
|
+
self.setMinimum(0)
|
|
104
|
+
self.setValue(0)
|
|
105
|
+
self.otime = 0
|
|
106
|
+
self.setStyleSheet(PBAR_STYLE)
|
|
107
|
+
|
|
108
|
+
def iter(self, iterable):
|
|
109
|
+
"""
|
|
110
|
+
Iterator Routine
|
|
111
|
+
"""
|
|
112
|
+
total = len(iterable)
|
|
113
|
+
self.setMaximum(total)
|
|
114
|
+
self.setMinimum(0)
|
|
115
|
+
self.setValue(0)
|
|
116
|
+
|
|
117
|
+
self.otime = time.clock()
|
|
118
|
+
time1 = self.otime
|
|
119
|
+
time2 = self.otime
|
|
120
|
+
|
|
121
|
+
n = 0
|
|
122
|
+
for obj in iterable:
|
|
123
|
+
yield obj
|
|
124
|
+
n += 1
|
|
125
|
+
|
|
126
|
+
time2 = time.clock()
|
|
127
|
+
if time2-time1 > 1:
|
|
128
|
+
self.setValue(n)
|
|
129
|
+
tleft = (total-n)*(time2-self.otime)/n
|
|
130
|
+
if tleft > 60:
|
|
131
|
+
tleft = int(tleft // 60)
|
|
132
|
+
self.setFormat('%p% '+str(tleft)+'min left')
|
|
133
|
+
else:
|
|
134
|
+
tleft = int(tleft)
|
|
135
|
+
self.setFormat('%p% '+str(tleft)+'s left')
|
|
136
|
+
QtGui.QApplication.processEvents()
|
|
137
|
+
time1 = time2
|
|
138
|
+
|
|
139
|
+
self.setFormat('%p%')
|
|
140
|
+
self.setValue(total)
|
|
141
|
+
|
|
142
|
+
def to_max(self):
|
|
143
|
+
""" Sets the progress to maximum """
|
|
144
|
+
self.setMaximum(1)
|
|
145
|
+
self.setMinimum(0)
|
|
146
|
+
self.setValue(1)
|
|
147
|
+
QtGui.QApplication.processEvents()
|