当前位置: 首页>>代码示例>>Python>>正文


Python QRadioButton.click方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QRadioButton.click方法的典型用法代码示例。如果您正苦于以下问题:Python QRadioButton.click方法的具体用法?Python QRadioButton.click怎么用?Python QRadioButton.click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QRadioButton的用法示例。


在下文中一共展示了QRadioButton.click方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EthernetEditor

# 需要导入模块: from PyQt4.QtGui import QRadioButton [as 别名]
# 或者: from PyQt4.QtGui.QRadioButton import click [as 别名]
class EthernetEditor(QFrame):
    def __init__(self, ethernet, parent=None):
        QFrame.__init__(self, parent)

        self.ethernet = ethernet

        self.buildGUI()
        self.fillValues()

    def buildGUI(self):
        #general setup
        form = QFormLayout(self)

        self.label = OptionnalLine(hint="Optional interface name")
        form.addRow(self.tr("Interface name"), self.label)

        self.speed_group = QButtonGroup()
        self.speed_box = QGroupBox(tr("Force an ethernet speed"))
        speed_layout = QVBoxLayout(self.speed_box)

        self.speed_GFull = QRadioButton(tr("Gigabit full duplex"))
        self.speed_GHalf = QRadioButton(tr("Gigabit half duplex"))
        self.speed_100Full = QRadioButton(tr("100 Mb Full duplex"))
        self.speed_100Half = QRadioButton(tr("100 Mb Half duplex"))
        self.speed_10Full = QRadioButton(tr("10 Mb Full duplex"))
        self.speed_10Half = QRadioButton(tr("10 Mb Half duplex"))

        def toggle(value):
            if value:
                self.speed_GFull.click()

        self.speed_box.setCheckable(True)
        self.speed_box.setChecked(Qt.Unchecked)
        self.connect(self.speed_box, SIGNAL('toggled(bool)'), toggle)

        for item in (
            self.speed_GFull,
            self.speed_GHalf,
            self.speed_100Full,
            self.speed_100Half,
            self.speed_10Full,
            self.speed_10Half,
            ):
            self.speed_group.addButton(item)
            speed_layout.addWidget(item)

        form.addRow(self.speed_box)

    def fillValues(self):
        name = self.ethernet.user_label
        if name != "":
            self.label.setText(name)
            self.label.checkEmpty()
            self.label.setStyleSheet('')

        if self.ethernet.eth_auto:
            self.speed_box.setChecked(Qt.Unchecked)
            return

        self.speed_box.setChecked(Qt.Checked)
        if self.ethernet.eth_duplex == Ethernet.FULL:
            if self.ethernet.eth_speed == 10:
                button = self.speed_10Full
            elif self.ethernet.eth_speed == 100:
                button = self.speed_100Full
            else:
                button = self.speed_GFull
        else:
            if self.ethernet.eth_speed == 10:
                button = self.speed_10Half
            elif self.ethernet.eth_speed == 100:
                button = self.speed_100Half
            else:
                button = self.speed_GHalf


        button.setChecked(Qt.Checked)

    def getConfig(self):
        auto = not self.speed_box.isChecked()
        if auto:
            return True, None, None
        selection = self.speed_group.checkedButton()
        if selection is self.speed_GFull:
            return False, 1000, Ethernet.FULL
        elif self.speed_GHalf:
            return False, 1000, Ethernet.HALF
        elif self.speed_100Full:
            return False, 100, Ethernet.FULL
        elif self.speed_100Half:
            return False, 100, Ethernet.HALF
        elif self.speed_10Full:
            return False, 10, Ethernet.FULL
        elif self.speed_10Half:
            return False, 10, Ethernet.HALF

        assert False, "this selection is unknown"

    def setName(self):
        new_name = self.label.value()
#.........这里部分代码省略.........
开发者ID:maximerobin,项目名称:Ufwi,代码行数:103,代码来源:ethernet_editor.py


注:本文中的PyQt4.QtGui.QRadioButton.click方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。