[new] function to modify project/event rootpath (called on loading project)
This commit is contained in:
parent
8dabfb41d8
commit
39f9238a06
23
PyLoT.py
23
PyLoT.py
@ -1138,9 +1138,16 @@ class MainWindow(QMainWindow):
|
|||||||
Initiate GUI widgets in case of changed or newly added events.
|
Initiate GUI widgets in case of changed or newly added events.
|
||||||
'''
|
'''
|
||||||
nitems = self.eventBox.count()
|
nitems = self.eventBox.count()
|
||||||
if len(self.project.eventlist) == 0 or not self.data_check():
|
is_data = self.data_check()
|
||||||
|
if len(self.project.eventlist) == 0 or not is_data:
|
||||||
print('No events to init.')
|
print('No events to init.')
|
||||||
self.clearWaveformDataPlot()
|
self.clearWaveformDataPlot()
|
||||||
|
if not is_data:
|
||||||
|
new_path, modifypath = self.user_modify_path('Event folders not found! ')
|
||||||
|
if modifypath:
|
||||||
|
self.modify_project_path(new_path)
|
||||||
|
self.init_events(True)
|
||||||
|
self.setDirty(True)
|
||||||
return
|
return
|
||||||
self.eventBox.setEnabled(True)
|
self.eventBox.setEnabled(True)
|
||||||
self.fill_eventbox()
|
self.fill_eventbox()
|
||||||
@ -1151,6 +1158,12 @@ class MainWindow(QMainWindow):
|
|||||||
self.refreshEvents()
|
self.refreshEvents()
|
||||||
tabindex = self.tabs.currentIndex()
|
tabindex = self.tabs.currentIndex()
|
||||||
|
|
||||||
|
def user_modify_path(self, reason=''):
|
||||||
|
dialog = QtGui.QInputDialog(parent=self)
|
||||||
|
new_path, executed = dialog.getText(self, 'Change Project rootpath',
|
||||||
|
'{}Rename project path {}:'.format(reason, self.project.rootpath))
|
||||||
|
return new_path, executed
|
||||||
|
|
||||||
def data_check(self):
|
def data_check(self):
|
||||||
paths_exist = [os.path.exists(event.path) for event in self.project.eventlist]
|
paths_exist = [os.path.exists(event.path) for event in self.project.eventlist]
|
||||||
if all(paths_exist):
|
if all(paths_exist):
|
||||||
@ -1162,6 +1175,14 @@ class MainWindow(QMainWindow):
|
|||||||
print('Unable to find certain event paths:{}'.format(info_str))
|
print('Unable to find certain event paths:{}'.format(info_str))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def modify_project_path(self, new_rootpath):
|
||||||
|
self.project.rootpath = new_rootpath
|
||||||
|
for event in self.project.eventlist:
|
||||||
|
event.rootpath = new_rootpath
|
||||||
|
event.path = os.path.join(event.rootpath, event.datapath, event.database, event.pylot_id)
|
||||||
|
event.path = event.path.replace('\\', '/')
|
||||||
|
event.path = event.path.replace('//', '/')
|
||||||
|
|
||||||
def fill_eventbox(self, event=None, eventBox=None, select_events='all'):
|
def fill_eventbox(self, event=None, eventBox=None, select_events='all'):
|
||||||
'''
|
'''
|
||||||
(Re)fill the selected eventBox (type = QtGui.QComboBox).
|
(Re)fill the selected eventBox (type = QtGui.QComboBox).
|
||||||
|
@ -1 +1 @@
|
|||||||
4918-dirty
|
8dab-dirty
|
||||||
|
Loading…
Reference in New Issue
Block a user