當前位置: 首頁>>代碼示例>>Python>>正文


Python QFormLayout.setContentsMargins方法代碼示例

本文整理匯總了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()
開發者ID:pymontecarlo,項目名稱:pymontecarlo-gui,代碼行數:37,代碼來源:beam.py

示例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
開發者ID:pymontecarlo,項目名稱:pymontecarlo-gui,代碼行數:66,代碼來源:detector.py

示例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)
開發者ID:gonicus,項目名稱:clacks,代碼行數:90,代碼來源:qt_gui.py


注:本文中的PySide.QtGui.QFormLayout.setContentsMargins方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。