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


Python QPushButton.setChecked方法代码示例

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


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

示例1: MasterSyncButtonHelper

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setChecked [as 别名]
class MasterSyncButtonHelper(QObject):
    '''
    This is helper class to which contains a button and can emit signals. The
    MasterSyncItem can not emit signals, but is used in QStandardModel.
    '''
    clicked = Signal(bool, str)

    NOT_SYNC = 0
    SWITCHED = 1
    SYNC = 2

    ICON_PREFIX = 'irondevil'
#  ICON_PREFIX = 'crystal_clear'

    def __init__(self, master):
        QObject.__init__(self)
        self.name = master.name
        self._master = master
        self._syncronized = MasterSyncButtonHelper.NOT_SYNC
        self.ICONS = {MasterSyncButtonHelper.SYNC: QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX),
                      MasterSyncButtonHelper.NOT_SYNC: QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX),
                      MasterSyncButtonHelper.SWITCHED: QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX)}
        self.widget = QPushButton()
#    self.widget.setFlat(True)
        self.widget.setIcon(self.ICONS[MasterSyncButtonHelper.NOT_SYNC])
        self.widget.setMaximumSize(48, 48)
        self.widget.setCheckable(True)
        self.widget.clicked.connect(self.on_sync_clicked)

    def on_sync_clicked(self, checked):
        self.set_sync_state(MasterSyncButtonHelper.SWITCHED)
        self.clicked.emit(checked, self._master.uri)

    def master(self):
        return self._master

    def get_sync_state(self):
        return self._syncronized

    def set_sync_state(self, value):
        if self._syncronized != value:
            self._syncronized = value
            if value in self.ICONS:
                self.widget.setIcon(self.ICONS[value])
                self.widget.setChecked(value == MasterSyncButtonHelper.SYNC)

    def __eq__(self, item):
        if isinstance(item, str) or isinstance(item, unicode):
            return self.master.name.lower() == item.lower()
        elif not (item is None):
            return self.master.name.lower() == item.master.name.lower()
        return False

    def __gt__(self, item):
        if isinstance(item, str) or isinstance(item, unicode):
            return self.master.name.lower() > item.lower()
        elif not (item is None):
            return self.master.name.lower() > item.master.name.lower()
        return False
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:61,代码来源:master_list_model.py

示例2: __init__

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setChecked [as 别名]
    def __init__(self, context):
        super(MultiRobotPatrollerPlugin, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('MultiRobotPatrollerPlugin')

        # Create QWidget
        self.widget = QWidget()
        self.master_layout = QVBoxLayout(self.widget)

        self.buttons = []
        self.button_layout = QHBoxLayout()
        self.master_layout.addLayout(self.button_layout)
        for button_text in ["Play", "Pause"]:
            button = QPushButton(button_text, self.widget)
            button.clicked[bool].connect(self.handle_button)
            button.setCheckable(True)
            self.button_layout.addWidget(button)
            if button_text == "Pause":
                button.setChecked(True)
            self.buttons.append(button)

        self.text_labels = {}

        self.widget.setObjectName('MultiRobotPatrollerPluginUI')
        if context.serial_number() > 1:
            self.widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
        context.add_widget(self.widget)

        self.points = rospy.get_param("points")
        self.flip_direction = rospy.get_param("flip_direction")

        self.available_robots = []
        self.global_start_counter = 0
        self.global_forward = True

        self.available_robot_subscriber = rospy.Subscriber("/available_robots", AvailableRobotArray,
                                                           self.available_robot_callback)

        self.robot_goals = {}
        self.paused = True

        self.connect(self.widget, SIGNAL("update"), self.update)
开发者ID:utexas-bwi,项目名称:segbot_rocon,代码行数:44,代码来源:plugins.py

示例3: Editor

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setChecked [as 别名]

#.........这里部分代码省略.........
        self.horizontalLayout.addWidget(self.gotoButton)
        # add a tag button
        self.tagButton = self._create_tag_button(self)
        self.horizontalLayout.addWidget(self.tagButton)
        # add spacer
        spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # add line number label
        self.pos_label = QLabel()
        self.horizontalLayout.addWidget(self.pos_label)
        # add spacer
        spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # add save button
        self.saveButton = QPushButton(self)
        self.saveButton.setObjectName("saveButton")
        self.saveButton.clicked.connect(self.on_saveButton_clicked)
        self.saveButton.setText(self._translate("&Save"))
        self.saveButton.setShortcut("Ctrl+S")
        self.saveButton.setToolTip('Save the changes to the file (Ctrl+S)')
        self.saveButton.setFlat(True)
        self.horizontalLayout.addWidget(self.saveButton)
        return self.buttons

    def keyPressEvent(self, event):
        '''
        Enable the shortcats for search and replace
        '''
        if event.key() == Qt.Key_Escape:
            self.reject()
        elif event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_F:
            if self.tabWidget.currentWidget().hasFocus():
                if not self.searchButton.isChecked():
                    self.searchButton.setChecked(True)
                else:
                    self.on_toggled_find(True)
            else:
                self.searchButton.setChecked(not self.searchButton.isChecked())
        elif event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_R:
            if self.tabWidget.currentWidget().hasFocus():
                if not self.replaceButton.isChecked():
                    self.replaceButton.setChecked(True)
                else:
                    self.on_toggled_replace(True)
            else:
                self.replaceButton.setChecked(not self.replaceButton.isChecked())
        else:
            event.accept()
            QMainWindow.keyPressEvent(self, event)

    def _translate(self, text):
        if hasattr(QApplication, "UnicodeUTF8"):
            return QApplication.translate("Editor", text, None, QApplication.UnicodeUTF8)
        else:
            return QApplication.translate("Editor", text, None)

    def readSettings(self):
        if nm.settings().store_geometry:
            settings = nm.settings().qsettings(nm.settings().CFG_GUI_FILE)
            settings.beginGroup("editor")
            maximized = settings.value("maximized", 'false') == 'true'
            if maximized:
                self.showMaximized()
            else:
                self.resize(settings.value("size", QSize(800, 640)))
                self.move(settings.value("pos", QPoint(0, 0)))
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:70,代码来源:editor.py

示例4: MessageBox

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setChecked [as 别名]
class MessageBox(QDialog):

    NoIcon = 0
    Information = 1
    Warning = 2
    Critical = 3
    Question = 4

    NoButton = 0
    Ok = 1         # An "OK" button defined with the AcceptRole .
    Open = 2       # A "Open" button defined with the AcceptRole .
    Save = 4       # A "Save" button defined with the AcceptRole .
    Cancel = 8     # A "Cancel" button defined with the RejectRole .
    Close = 16     # A "Close" button defined with the RejectRole .
    Discard = 32   # A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole .
    Apply = 64     # An "Apply" button defined with the ApplyRole .
    Reset = 128    # A "Reset" button defined with the ResetRole .
    RestoreDefaults = 256  # A "Restore Defaults" button defined with the ResetRole .
    Help = 512       # A "Help" button defined with the HelpRole .
    SaveAll = 1024   # A "Save All" button defined with the AcceptRole .
    Yes = 2048       # A "Yes" button defined with the YesRole .
    YesToAll = 4096  # A "Yes to All" button defined with the YesRole .
    No = 8192        # A "No" button defined with the NoRole .
    NoToAll = 16384  # A "No to All" button defined with the NoRole .
    Abort = 32768    # An "Abort" button defined with the RejectRole .
    Retry = 65536    # A "Retry" button defined with the AcceptRole .
    Ignore = 131072  # An "Ignore" button defined with the AcceptRole .
    Avoid = 262144   # An "'Don't show again'" button defined with the HelpRole, returns a default AcceptButton .

    def __init__(self, icon, title, text, detailed_text="", buttons=Cancel | Ok, parent=None):
        QDialog.__init__(self, parent=parent)
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowTitleHint)
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint & ~Qt.WindowMinimizeButtonHint)
        self.setObjectName('MessageBox')
        self._use_checkbox = True
        self.text = text
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
        # create icon
        pixmap = None
        if icon == self.NoIcon:
            pass
        elif icon == self.Question:
            pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxQuestion)
        elif icon == self.Information:
            pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxInformation)
        elif icon == self.Warning:
            pixmap = QPixmap(":icons/crystal_clear_warning_56.png")
        elif icon == self.Critical:
            pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxCritical)
        spacerItem = QSpacerItem(10, 60, QSizePolicy.Minimum, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.icon_label = QLabel()
        if pixmap is not None:
            self.icon_label.setPixmap(pixmap)
        self.icon_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.horizontalLayout.addWidget(self.icon_label)
        spacerItem = QSpacerItem(10, 60, QSizePolicy.Minimum, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # add message
        self.message_label = QLabel(text)
        self.message_label.setWordWrap(True)
        self.message_label.setScaledContents(True)
        self.message_label.setOpenExternalLinks(True)
        self.horizontalLayout.addWidget(self.message_label)
        self.verticalLayout.addLayout(self.horizontalLayout)

        # create buttons
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setObjectName("buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)

        self._accept_button = None
        self._reject_button = None
        self._buttons = buttons
        self._create_buttons(buttons)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.verticalLayout.addWidget(self.buttonBox)

        if detailed_text:
            self.btn_show_details = QPushButton(self.tr('Details...'))
            self.btn_show_details.setCheckable(True)
            self.btn_show_details.setChecked(True)
            self.btn_show_details.toggled.connect(self.on_toggled_details)
            self.buttonBox.addButton(self.btn_show_details, QDialogButtonBox.ActionRole)
            # create area for detailed text
            self.textEdit = textEdit = QTextEdit(self)
            textEdit.setObjectName("textEdit")
            textEdit.setReadOnly(True)
            textEdit.setText(detailed_text)
            # textEdit.setVisible(False)
            self.verticalLayout.addWidget(self.textEdit)
        self.resize(480, self.verticalLayout.totalSizeHint().height())
        buttons_in_box = self.buttonBox.buttons()
#.........这里部分代码省略.........
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:103,代码来源:detailed_msg_box.py


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