本文整理汇总了Python中python_qt_binding.QtGui.QPushButton.setCheckable方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setCheckable方法的具体用法?Python QPushButton.setCheckable怎么用?Python QPushButton.setCheckable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QPushButton
的用法示例。
在下文中一共展示了QPushButton.setCheckable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [as 别名]
def __init__(self, context):
super(MultiRobotPasserGUIPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('MultiRobotPasserGUIPlugin')
# 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 ["Enable", "Disable"]:
button = QPushButton(button_text, self.widget)
button.clicked[bool].connect(self.handle_button)
button.setCheckable(True)
self.button_layout.addWidget(button)
self.buttons[button_text] = button
self.widget.setObjectName('MultiRobotPasserGUIPluginUI')
if context.serial_number() > 1:
self.widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
context.add_widget(self.widget)
self.status_subscriber = rospy.Subscriber("status", Bool, self.status_callback)
self.enable = rospy.ServiceProxy("enable", Empty)
self.disable = rospy.ServiceProxy("disable", Empty)
self.enabled = False
self.connect(self.widget, SIGNAL("update"), self.update)
示例2: MasterSyncButtonHelper
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [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
示例3: update_buttons
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [as 别名]
def update_buttons(self):
self.clean()
for index, level in enumerate(self.levels):
self.text_label.setText("Choose Level: ")
button = QPushButton(level.level_id, self._widget)
button.clicked[bool].connect(self.handle_button)
button.setCheckable(True)
self._button_layout.addWidget(button)
self.buttons.append(button)
# Subscribe to the current level we are on.
if self.status_subscriber is None:
self.status_subscriber = rospy.Subscriber("level_mux/current_level", LevelMetaData, self.process_level_status)
示例4: activateFunction
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [as 别名]
def activateFunction(self):
# Add all the necessary buttons to the subfunction layout.
clearLayoutAndFixHeight(self.subfunction_layout)
for button_text in [LocationFunction.ADD_LOCATION_AREA,
LocationFunction.EDIT_EXISTING_AREA]:
button = QPushButton(button_text, self.widget)
button.clicked[bool].connect(partial(self.startAreaEdit, button_text))
button.setCheckable(True)
self.subfunction_layout.addWidget(button)
self.edit_area_button[button_text] = button
self.edit_area_button[LocationFunction.EDIT_EXISTING_AREA].setEnabled(False)
self.subfunction_layout.addStretch(1)
# ActivateMouseHooks.
self.image.mousePressEvent = self.mousePressEvent
self.image.mouseMoveEvent = self.mouseMoveEvent
self.image.mouseReleaseEvent = self.mouseReleaseEvent
self.updateOverlay()
示例5: __init__
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [as 别名]
def __init__(self, context):
super(LogicalMarkerPlugin, self).__init__(context)
# Create an image for the original map. This will never change.
try:
self.map_yaml_file_str = rospy.get_param("~map_file")
self.data_directory = rospy.get_param("~data_directory")
except KeyError:
rospy.logfatal("~map_file and ~data_directory need to be set to use the logical marker")
return
map_image_location = getImageFileLocation(self.map_yaml_file_str)
map = loadMapFromFile(self.map_yaml_file_str)
locations_file = getLocationsFileLocationFromDataDirectory(self.data_directory)
doors_file = getDoorsFileLocationFromDataDirectory(self.data_directory)
objects_file = getObjectsFileLocationFromDataDirectory(self.data_directory)
# Give QObjects reasonable names
self.setObjectName('LogicalMarkerPlugin')
# Create QWidget
self.master_widget = QWidget()
self.master_layout = QVBoxLayout(self.master_widget)
# Main Functions - Doors, Locations, Objects
self.function_layout = QHBoxLayout()
self.master_layout.addLayout(self.function_layout)
self.function_buttons = []
self.current_function = None
for button_text in ['Locations', 'Doors', 'Objects']:
button = QPushButton(button_text, self.master_widget)
button.clicked[bool].connect(self.handle_function_button)
button.setCheckable(True)
self.function_layout.addWidget(button)
self.function_buttons.append(button)
self.function_layout.addStretch(1)
self.master_layout.addWidget(self.get_horizontal_line())
# Subfunction toolbar
self.subfunction_layout = QHBoxLayout()
clearLayoutAndFixHeight(self.subfunction_layout)
self.master_layout.addLayout(self.subfunction_layout)
self.current_subfunction = None
self.master_layout.addWidget(self.get_horizontal_line())
self.image = MapImage(map_image_location, self.master_widget)
self.master_layout.addWidget(self.image)
self.master_layout.addWidget(self.get_horizontal_line())
# Configuration toolbar
self.configuration_layout = QHBoxLayout()
clearLayoutAndFixHeight(self.configuration_layout)
self.master_layout.addLayout(self.configuration_layout)
# Add a stretch at the bottom.
self.master_layout.addStretch(1)
self.master_widget.setObjectName('LogicalMarkerPluginUI')
if context.serial_number() > 1:
self.master_widget.setWindowTitle(self.master_widget.windowTitle() + (' (%d)' % context.serial_number()))
context.add_widget(self.master_widget)
# Activate the functions
self.functions = {}
self.functions['Locations'] = LocationFunction(locations_file,
map,
self.master_widget,
self.subfunction_layout,
self.configuration_layout,
self.image)
self.functions['Doors'] = DoorFunction(doors_file,
map,
self.functions['Locations'],
self.master_widget,
self.subfunction_layout,
self.configuration_layout,
self.image)
self.functions['Objects'] = ObjectFunction(objects_file,
map,
self.functions['Locations'],
self.master_widget,
self.subfunction_layout,
self.configuration_layout,
self.image)
示例6: TimelineWidget
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [as 别名]
class TimelineWidget(QWidget):
class TimelineView(QGraphicsView):
def __init__(self, parent):
super(TimelineWidget.TimelineView, self).__init__()
self.parent = parent
def mouseReleaseEvent(self, event):
self.parent.mouse_release(event)
update = pyqtSignal()
def __init__(self, parent):
super(TimelineWidget, self).__init__()
self.parent = parent
self._layout = QHBoxLayout()
#self._view = QGraphicsView()
self._view = TimelineWidget.TimelineView(self)
self._scene = QGraphicsScene()
self._colors = [QColor('green'), QColor('yellow'), QColor('red')]
self._messages = [None for x in range(20)]
self._mq = [1 for x in range(20)]
self._view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self._view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self._view.setScene(self._scene)
self._layout.addWidget(self._view, 1)
self.pause_button = QPushButton('Pause')
self.pause_button.setCheckable(True)
self.pause_button.clicked.connect(self.pause)
self._layout.addWidget(self.pause_button)
self.setLayout(self._layout)
self.update.connect(self.redraw)
def redraw(self):
self._scene.clear()
self._scene
for i, m in enumerate(self._mq):
w = float(self._view.viewport().width())/len(self._mq)
h = self._view.viewport().height()
rect = self._scene.addRect(w*i, 0, w, h, QColor('black'), self._colors[m])
def mouse_release(self, event):
i = int(floor(event.x()/(float(self._view.viewport().width())/len(self._mq))))
msg = self._messages[i]
if msg:
self.parent.pause(msg)
if not self.pause_button.isChecked():
self.pause_button.toggle()
def resizeEvent(self, event):
self.redraw()
def get_worst(self, msg):
lvl = 0
for status in msg.status:
if status.level > lvl:
lvl = status.level
return lvl
def add_message(self, msg):
self._messages = self._messages[1:]
self._messages.append(msg)
self._mq = self._mq[1:]
try:
lvl = msg.level
except AttributeError:
lvl = self.get_worst(msg)
if lvl > 2:
lvl = 2
self._mq.append(lvl)
self.update.emit()
def pause(self, state):
if state:
self.parent.pause(self._messages[-1])
else:
self.parent.unpause()
示例7: Editor
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [as 别名]
class Editor(QMainWindow):
'''
Creates a dialog to edit a launch file.
'''
finished_signal = Signal(list)
'''
finished_signal has as parameter the filenames of the initialization and is emitted, if this
dialog was closed.
'''
def __init__(self, filenames, search_text='', parent=None):
'''
@param filenames: a list with filenames. The last one will be activated.
@type filenames: C{[str, ...]}
@param search_text: if not empty, searches in new document for first occurrence of the given text
@type search_text: C{str} (Default: C{Empty String})
'''
QMainWindow.__init__(self, parent)
self.setObjectName(' - '.join(['Editor', str(filenames)]))
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.setWindowFlags(Qt.Window)
self.mIcon = QIcon(":/icons/crystal_clear_edit_launch.png")
self._error_icon = QIcon(":/icons/crystal_clear_warning.png")
self._empty_icon = QIcon()
self.setWindowIcon(self.mIcon)
window_title = "ROSLaunch Editor"
if filenames:
window_title = self.__getTabName(filenames[0])
self.setWindowTitle(window_title)
self.init_filenames = list(filenames)
self._search_thread = None
# list with all open files
self.files = []
# create tabs for files
self.main_widget = QWidget(self)
self.verticalLayout = QVBoxLayout(self.main_widget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(1)
self.verticalLayout.setObjectName("verticalLayout")
self.tabWidget = EditorTabWidget(self)
self.tabWidget.setTabPosition(QTabWidget.North)
self.tabWidget.setDocumentMode(True)
self.tabWidget.setTabsClosable(True)
self.tabWidget.setMovable(False)
self.tabWidget.setObjectName("tabWidget")
self.tabWidget.tabCloseRequested.connect(self.on_close_tab)
self.verticalLayout.addWidget(self.tabWidget)
self.buttons = self._create_buttons()
self.verticalLayout.addWidget(self.buttons)
self.setCentralWidget(self.main_widget)
self.find_dialog = TextSearchFrame(self.tabWidget, self)
self.find_dialog.search_result_signal.connect(self.on_search_result)
self.find_dialog.replace_signal.connect(self.on_replace)
self.addDockWidget(Qt.RightDockWidgetArea, self.find_dialog)
# open the files
for f in filenames:
if f:
self.on_load_request(os.path.normpath(f), search_text)
self.readSettings()
self.find_dialog.setVisible(False)
# def __del__(self):
# print "******** destroy", self.objectName()
def _create_buttons(self):
# create the buttons line
self.buttons = QWidget(self)
self.horizontalLayout = QHBoxLayout(self.buttons)
self.horizontalLayout.setContentsMargins(4, 0, 4, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
# add the search button
self.searchButton = QPushButton(self)
self.searchButton.setObjectName("searchButton")
# self.searchButton.clicked.connect(self.on_shortcut_find)
self.searchButton.toggled.connect(self.on_toggled_find)
self.searchButton.setText(self._translate("&Find"))
self.searchButton.setToolTip('Open a search dialog (Ctrl+F)')
self.searchButton.setFlat(True)
self.searchButton.setCheckable(True)
self.horizontalLayout.addWidget(self.searchButton)
# add the replace button
self.replaceButton = QPushButton(self)
self.replaceButton.setObjectName("replaceButton")
# self.replaceButton.clicked.connect(self.on_shortcut_replace)
self.replaceButton.toggled.connect(self.on_toggled_replace)
self.replaceButton.setText(self._translate("&Replace"))
self.replaceButton.setToolTip('Open a search&replace dialog (Ctrl+R)')
self.replaceButton.setFlat(True)
self.replaceButton.setCheckable(True)
self.horizontalLayout.addWidget(self.replaceButton)
# add the goto button
self.gotoButton = QPushButton(self)
self.gotoButton.setObjectName("gotoButton")
self.gotoButton.clicked.connect(self.on_shortcut_goto)
self.gotoButton.setText(self._translate("&Goto line"))
self.gotoButton.setShortcut("Ctrl+G")
self.gotoButton.setToolTip('Open a goto dialog (Ctrl+G)')
#.........这里部分代码省略.........
示例8: MessageBox
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setCheckable [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()
#.........这里部分代码省略.........