本文整理匯總了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)