本文整理汇总了Python中python_qt_binding.QtGui.QPushButton.isChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.isChecked方法的具体用法?Python QPushButton.isChecked怎么用?Python QPushButton.isChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QPushButton
的用法示例。
在下文中一共展示了QPushButton.isChecked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TimelineWidget
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import isChecked [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()
示例2: Editor
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import isChecked [as 别名]
#.........这里部分代码省略.........
self.gotoButton.setFlat(True)
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)))