本文整理汇总了Python中guidata.qt.QtGui.QGridLayout.setAlignment方法的典型用法代码示例。如果您正苦于以下问题:Python QGridLayout.setAlignment方法的具体用法?Python QGridLayout.setAlignment怎么用?Python QGridLayout.setAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类guidata.qt.QtGui.QGridLayout
的用法示例。
在下文中一共展示了QGridLayout.setAlignment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import setAlignment [as 别名]
def __init__(self, item, parent_layout):
super(TabGroupWidget, self).__init__(item, parent_layout)
self.tabs = QTabWidget()
items = item.item.group
self.widgets = []
for item in items:
if item.get_prop_value("display", parent_layout.instance,
"hide", False):
continue
item.set_prop("display", embedded=True)
widget = parent_layout.build_widget(item)
frame = QFrame()
label = widget.item.get_prop_value("display", "label")
icon = widget.item.get_prop_value("display", "icon", None)
if icon is not None:
self.tabs.addTab(frame, get_icon(icon), label)
else:
self.tabs.addTab(frame, label)
layout = QGridLayout()
layout.setAlignment(Qt.AlignTop)
frame.setLayout(layout)
widget.place_on_grid(layout, 0, 0, 1)
try:
widget.get()
except Exception:
print("Error building item :", item.item._name)
raise
self.widgets.append(widget)
示例2: setup_instance
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import setAlignment [as 别名]
def setup_instance(self, instance):
"""Construct main layout"""
grid = QGridLayout()
grid.setAlignment(Qt.AlignTop)
self.layout.addLayout(grid)
self.edit_layout.append( self.layout_factory( instance, grid) )
示例3: FloatArrayWidget
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import setAlignment [as 别名]
class FloatArrayWidget(AbstractDataSetWidget):
"""
FloatArrayItem widget
"""
def __init__(self, item, parent_layout):
super(FloatArrayWidget, self).__init__(item, parent_layout)
_label = item.get_prop_value("display", "label")
self.groupbox = self.group = QGroupBox(_label)
self.layout = QGridLayout()
self.layout.setAlignment(Qt.AlignLeft)
self.groupbox.setLayout(self.layout)
self.first_line, self.dim_label = get_image_layout("shape.png",
_("Number of rows x Number of columns"))
edit_button = QPushButton(get_icon("arredit.png"), "")
edit_button.setToolTip(_("Edit array contents"))
edit_button.setMaximumWidth(32)
self.first_line.addWidget(edit_button)
self.layout.addLayout(self.first_line, 0, 0)
self.min_line, self.min_label = get_image_layout("min.png",
_("Smallest element in array"))
self.layout.addLayout(self.min_line, 1, 0)
self.max_line, self.max_label = get_image_layout("max.png",
_("Largest element in array"))
self.layout.addLayout(self.max_line, 2, 0)
edit_button.clicked.connect(self.edit_array)
self.arr = None # le tableau si il a été modifié
self.instance = None
def edit_array(self):
"""Open an array editor dialog"""
parent = self.parent_layout.parent
label = self.item.get_prop_value("display", "label")
try:
# Spyder 3
from spyderlib.widgets.variableexplorer import arrayeditor
except ImportError:
# Spyder 2
from spyderlib.widgets import arrayeditor
editor = arrayeditor.ArrayEditor(parent)
if editor.setup_and_check(self.arr, title=label):
if editor.exec_():
self.update(self.arr)
def get(self):
"""Override AbstractDataSetWidget method"""
self.arr = numpy.array(self.item.get(), copy=False)
if self.item.get_prop_value("display", "transpose"):
self.arr = self.arr.T
self.update(self.arr)
def update(self, arr):
"""Override AbstractDataSetWidget method"""
shape = arr.shape
if len(shape) == 1:
shape = (1,) + shape
dim = " x ".join( [ str(d) for d in shape ])
self.dim_label.setText(dim)
format = self.item.get_prop_value("display", "format")
minmax = self.item.get_prop_value("display", "minmax")
try:
if minmax == "all":
mint = format % arr.min()
maxt = format % arr.max()
elif minmax == "columns":
mint = ", ".join([format % arr[r,:].min()
for r in range(arr.shape[0])])
maxt = ", ".join([format % arr[r,:].max()
for r in range(arr.shape[0])])
else:
mint = ", ".join([format % arr[:, r].min()
for r in range(arr.shape[1])])
maxt = ", ".join([format % arr[:, r].max()
for r in range(arr.shape[1])])
except (TypeError, IndexError):
mint, maxt = "-", "-"
self.min_label.setText(mint)
self.max_label.setText(maxt)
def set(self):
"""Override AbstractDataSetWidget method"""
if self.item.get_prop_value("display", "transpose"):
value = self.value().T
else:
value = self.value()
self.item.set(value)
def value(self):
return self.arr
def place_on_grid(self, layout, row, label_column, widget_column,
row_span=1, column_span=1):
"""Override AbstractDataSetWidget method"""
layout.addWidget(self.group, row, label_column, row_span, column_span+1)