added QStackedWidget as an option in gui_frame.py, a varient of QTabWidget
This commit is contained in:
44
guiframe.py
44
guiframe.py
@@ -1699,8 +1699,8 @@ class GUIFrame(QWidget):
|
||||
rblist[_idx].toggled.emit(True)
|
||||
return line
|
||||
'''
|
||||
|
||||
def qtab_wgt(self, key, irow, wgt_grid):
|
||||
|
||||
def qtab_wgt(self, key, irow, wgt_grid, stacked=False):
|
||||
|
||||
if key in self.settings.data["Expert"].keys():
|
||||
top_key = "Expert"
|
||||
@@ -1749,7 +1749,7 @@ class GUIFrame(QWidget):
|
||||
self.sender().tabBar().setTabTextColor(i, QColor("black"))
|
||||
self.parent.input_parameters[key] = sender_tab
|
||||
|
||||
qtab_widget = QTabWidget()
|
||||
qtab_widget = QTabWidget() if not stacked else QStackedWidget()
|
||||
qtab_widget_dict = {}
|
||||
itab = 0
|
||||
longest_title = "short"
|
||||
@@ -1868,8 +1868,11 @@ class GUIFrame(QWidget):
|
||||
qw.setFixedHeight(tab_height)
|
||||
qtab_widget_dict[itab] = qw
|
||||
qtab_widget_dict[itab].title = title
|
||||
qtab_widget.addTab(qtab_widget_dict[itab], title)
|
||||
|
||||
if not stacked:
|
||||
qtab_widget.addTab(qtab_widget_dict[itab], title)
|
||||
else:
|
||||
qtab_widget.addWidget(qtab_widget_dict[itab])
|
||||
|
||||
itab += 1
|
||||
qtab_widget.qtab_widget_dict = qtab_widget_dict
|
||||
|
||||
@@ -1886,7 +1889,7 @@ class GUIFrame(QWidget):
|
||||
param_width = fm.maxWidth() * len(longest_title)
|
||||
meas_line.setMaximumWidth(int(param_width*0.5))
|
||||
|
||||
qtab_widget.setContentsMargins(0, 40, 0, 0)
|
||||
qtab_widget.setContentsMargins(0, 0, 0, 0)
|
||||
qtab_widget.currentChanged.connect(on_tab_change)
|
||||
_default_idx = self.settings.data[top_key][key]["data"]["value"]
|
||||
qtab_widget.setCurrentIndex(_default_idx)
|
||||
@@ -1895,7 +1898,8 @@ class GUIFrame(QWidget):
|
||||
|
||||
final_wgt = QWidget()
|
||||
final_lo = QGridLayout()
|
||||
final_wgt.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
final_wgt.setContentsMargins(0, 0, 0, 0) #0, 40, 0, 0
|
||||
final_lo.addWidget(meas_label, 0, 0, 1, 2,
|
||||
Qt.AlignmentFlag(Qt.AlignLeft|Qt.AlignVCenter))
|
||||
final_lo.addWidget(meas_line, 0, 2, 1, 2,
|
||||
@@ -2200,8 +2204,8 @@ class GUIFrame(QWidget):
|
||||
line.addItems(value)
|
||||
line.setFixedHeight(26)
|
||||
line.currentTextChanged.connect(combo_cb)
|
||||
line.setCurrentIndex(0)
|
||||
line.currentTextChanged.emit(value[0])
|
||||
line.setCurrentIndex(2)
|
||||
line.currentTextChanged.emit(value[2])
|
||||
value_for_width = max(value, key=len)
|
||||
|
||||
fm = QFontMetricsF(line.font())
|
||||
@@ -2764,11 +2768,29 @@ class GUIFrame(QWidget):
|
||||
|
||||
wgt_grid.addWidget(line, a, b, c, d,
|
||||
Qt.AlignLeft | Qt.AlignVCenter)
|
||||
elif buddy == "QStackedWidget".upper():
|
||||
#print("buddy/label", buddy, label, key, value, flush=True)
|
||||
line, qtab = self.qtab_wgt(key, irow, wgt_grid, stacked=True)
|
||||
|
||||
if self.grid_loc:
|
||||
a = self.grid_loc[0]
|
||||
b = self.grid_loc[1]
|
||||
c = self.grid_loc[2]
|
||||
d = self.grid_loc[3]
|
||||
else:
|
||||
a = irow
|
||||
b = 0
|
||||
c = 1
|
||||
d = 4
|
||||
|
||||
wgt_grid.addWidget(line, a, b, c, d,
|
||||
Qt.AlignLeft | Qt.AlignVCenter)
|
||||
else:
|
||||
wgt_list = ["QCheckBox", "QComboBox", "QDoubleSpinBox", "QFrame",
|
||||
"QHLine", "QLabel", "QLineEdit", "QLineRead",
|
||||
"QRadioButton", "QSpinBox", "QTabWidget","QVLine",
|
||||
"QPhaseStackedWidget", "QEnergyStackedWidget"]
|
||||
"QRadioButton", "QSpinBox", "QStackedWiodget",
|
||||
"QTabWidget","QVLine", "QPhaseStackedWidget",
|
||||
"QEnergyStackedWidget"]
|
||||
print("Widget {0} is not Supported".format(buddy))
|
||||
print("Supported widgets are: {0}".format(wgt_list))
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user