Skip to content

Commit

Permalink
nicer handling of tabWidget by using currentWidget instead of current…
Browse files Browse the repository at this point in the history
…Index
  • Loading branch information
JannickWeisshaupt committed Jul 24, 2018
1 parent 9e7259e commit fd93691
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ def __init__(self, parent=None, *args, **kwargs):
self.info_window = InfoWindow(parent=self)

self.tabWidget = QtGui.QTabWidget()
self.tabWidget.currentChanged.connect(self.tab_is_changed)
self.tabWidget.currentChanged.connect(lambda: self.tabWidget.currentWidget().do_select_event())
self.layout.addWidget(self.tabWidget)

self.status_bar = StatusBar()
Expand Down Expand Up @@ -2791,9 +2791,6 @@ def crystal_structure(self, value):

self.brillouin_window.set_path(self.dft_engine_window.band_structure_points)

def tab_is_changed(self, i):
self.list_of_tabs[i].do_select_event()

def make_new_project(self):
folder_name = QtGui.QFileDialog().getExistingDirectory(parent=self,options=QtGui.QFileDialog.ShowDirsOnly)

Expand Down Expand Up @@ -2887,7 +2884,7 @@ def load_project(self, *args, **kwargs):
self.error_dialog.showMessage(err_msg)
else:
self.dft_engine_window.update_all()
self.tab_is_changed(self.tabWidget.currentIndex())
self.tabWidget.currentWidget().do_select_event()
self.setWindowTitle("OpenDFT - " + self.project_directory)
self.project_loaded = True
self.configure_buttons()
Expand Down Expand Up @@ -3206,12 +3203,12 @@ def check_engine(self, tasks):
self.dft_engine_window.abort_bool = False
return
elif esc_handler.is_engine_running(tasks=tasks):
selected_tab_index = self.tabWidget.currentIndex()
if self.list_of_tabs[selected_tab_index] == self.scf_window:
current_widget = self.tabWidget.currentWidget()
if current_widget == self.scf_window:
self.scf_data = esc_handler.read_scf_status()
if self.scf_data is not None:
self.scf_window.scf_widget.plot(self.scf_data)
elif self.list_of_tabs[selected_tab_index] == self.info_window:
elif current_widget == self.info_window:
self.info_window.do_select_event()
QtCore.QTimer.singleShot(500, lambda: self.check_engine(tasks))
self.status_bar.set_engine_status(True, tasks=tasks)
Expand Down

0 comments on commit fd93691

Please sign in to comment.