本文整理汇总了Python中PySide.QtGui.QFormLayout.setContentsMargins方法的典型用法代码示例。如果您正苦于以下问题:Python QFormLayout.setContentsMargins方法的具体用法?Python QFormLayout.setContentsMargins怎么用?Python QFormLayout.setContentsMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QFormLayout
的用法示例。
在下文中一共展示了QFormLayout.setContentsMargins方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide.QtGui import QFormLayout [as 别名]
# 或者: from PySide.QtGui.QFormLayout import setContentsMargins [as 别名]
def __init__(self, parameter, parent=None):
_ParameterWidget.__init__(self, parameter, parent)
# Widgets
self._lbl_u = QLabel('u')
self._lbl_u.setStyleSheet("color: blue")
self._txt_u = MultiNumericalLineEdit()
self._lbl_v = QLabel('v')
self._lbl_v.setStyleSheet("color: blue")
self._txt_v = MultiNumericalLineEdit()
self._lbl_w = QLabel('w')
self._lbl_w.setStyleSheet("color: blue")
self._txt_w = MultiNumericalLineEdit()
# Layouts
layout = QFormLayout()
layout.setContentsMargins(0, 0, 0, 0)
if sys.platform == 'darwin': # Fix for Mac OS
layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
layout.addRow(self._lbl_u, self._txt_u)
layout.addRow(self._lbl_v, self._txt_v)
layout.addRow(self._lbl_w, self._txt_w)
self.setLayout(layout)
# Signals
self.valuesChanged.connect(self._onChanged)
self.validationRequested.connect(self._onChanged)
self._txt_u.textChanged.connect(self.valuesChanged)
self._txt_v.textChanged.connect(self.valuesChanged)
self._txt_w.textChanged.connect(self.valuesChanged)
self.validationRequested.emit()
示例2: _initUI
# 需要导入模块: from PySide.QtGui import QFormLayout [as 别名]
# 或者: from PySide.QtGui.QFormLayout import setContentsMargins [as 别名]
def _initUI(self):
# Widgets
self._rb_delimited = QRadioButton('Delimited')
self._rb_delimited.setChecked(False)
self._lbl_elevation = QLabel("Elevation")
self._lbl_elevation.setStyleSheet("color: blue")
self._txt_elevation = _AngleRangeWidget(_DelimitedDetector.elevation_rad)
self._txt_elevation.setEnabled(False)
self._txt_elevation.setRequired(False)
self._lbl_azimuth = QLabel('Azimuth')
self._lbl_azimuth.setStyleSheet("color: blue")
self._txt_azimuth = _AngleRangeWidget(_DelimitedDetector.azimuth_rad)
self._txt_azimuth.setEnabled(False)
self._txt_azimuth.setRequired(False)
self._rb_annular = QRadioButton('Annular')
self._rb_annular.setChecked(True)
self._lbl_takeoffangle = QLabel('Take-off angle')
self._lbl_takeoffangle.setStyleSheet("color: blue")
param_takeoffangle = \
AngleParameter(validators=range_validator(0.0, HALFPI),
doc='Take-off angle from the x-y plane')
param_takeoffangle._name = 'takeoffangle'
self._txt_takeoffangle = AngleParameterWidget(param_takeoffangle)
self._lbl_opening = QLabel('Opening')
self._lbl_opening.setStyleSheet("color: blue")
param_opening = \
AngleParameter(validators=range_validator(0.0, HALFPI, False),
doc='Opening angle from the take-off angle (above and below)')
param_opening._name = 'opening'
self._txt_opening = AngleParameterWidget(param_opening)
# Layouts
layout = _DetectorWidget._initUI(self)
layout.addRow(self._rb_delimited)
sublayout = QFormLayout()
sublayout.setContentsMargins(10, 0, 0, 0)
if sys.platform == 'darwin': # Fix for Mac OS
sublayout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
sublayout.addRow(self._lbl_elevation, self._txt_elevation)
sublayout.addRow(self._lbl_azimuth, self._txt_azimuth)
layout.addRow(sublayout)
layout.addRow(self._rb_annular)
sublayout = QFormLayout()
sublayout.setContentsMargins(10, 0, 0, 0)
if sys.platform == 'darwin': # Fix for Mac OS
sublayout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
sublayout.addRow(self._lbl_takeoffangle, self._txt_takeoffangle)
sublayout.addRow(self._lbl_opening, self._txt_opening)
layout.addRow(sublayout)
# Signals
self._rb_delimited.toggled.connect(self._onToggle)
self._rb_annular.toggled.connect(self._onToggle)
return layout
示例3: __init__
# 需要导入模块: from PySide.QtGui import QFormLayout [as 别名]
# 或者: from PySide.QtGui.QFormLayout import setContentsMargins [as 别名]
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
# Global form layout
form = QFormLayout()
form.setContentsMargins(0, 0, 0, 0)
# Header box containing label and icon
hbox = QHBoxLayout()
hbox.setSpacing(0)
hbox.setContentsMargins(0, 0, 0, 0)
header = QFrame()
header.setFrameStyle(QFrame.Panel | QFrame.Sunken)
header.setStyleSheet("QWidget { background-color: white; color: black;}")
header_text = QLabel("<b>" + _("Clacks Infrastructure") + "</b><br>" + "v%s" % VERSION)
header_text.setStyleSheet("QWidget { background-color: white; color: black; border: 0; margin: 0; padding: 3;}")
header_text.setAlignment(Qt.AlignLeft | Qt.AlignTop)
hbox.addWidget(header_text, 1)
header_image = QLabel()
header_image.setStyleSheet("QWidget { background-color: white; color: black; border: 0; margin: 0; padding: 0;}")
header_image.setAlignment(Qt.AlignRight | Qt.AlignTop)
bg = QPixmap(resource_filename("clacks.client", "data/secure-card.png"))
header_image.setPixmap(bg)
hbox.addWidget(header_image)
header.setLayout(hbox)
form.addRow(header)
# Dialog headline
headline = QLabel(_("Please enter the credentials of an administrative user to join this client."))
headline.setWordWrap(True)
headline.setStyleSheet("QLabel { padding: 3; }")
form.addRow(headline)
# Separator
line = QFrame()
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
form.addRow(line)
# Input fields for user and password
ll = QGridLayout()
userLabel = QLabel("User name")
self.userEdit = QLineEdit(self)
passwordLabel = QLabel("Password")
self.passwordEdit = QLineEdit(self)
self.passwordEdit.setEchoMode(QLineEdit.Password)
# Add focus key handler for line edits
kpe = FocusNextOnReturn(self)
self.userEdit.installEventFilter(kpe)
aor = AcceptOnReturn(self)
self.passwordEdit.installEventFilter(aor)
# Place widgets in layout
ll.addWidget(userLabel, 0, 0)
ll.addWidget(self.userEdit, 0, 1)
ll.addWidget(passwordLabel, 1, 0)
ll.addWidget(self.passwordEdit, 1, 1)
ll.setContentsMargins(3, 3, 3, 3)
form.addRow(ll)
# Separator
line2 = QFrame()
line2.setFrameShape(QFrame.HLine)
line2.setFrameShadow(QFrame.Sunken)
form.addRow(line2)
# OK button
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
form.addRow(buttonBox)
buttonBox.accepted.connect(self.accept)
# Finalize the window
self.setLayout(form)
self.setMinimumSize(400, 150)
self.setWindowTitle('Join client')
self.setGeometry((QApplication.desktop().width() - self.sizeHint().width()) / 2,
(QApplication.desktop().height() - self.sizeHint().height()) / 2,
self.sizeHint().width(), self.sizeHint().height())
# Disable close
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.CustomizeWindowHint | Qt.Window | Qt.WindowTitleHint)