本文整理汇总了Python中PyQt4.Qt.QDialogButtonBox.setStandardButtons方法的典型用法代码示例。如果您正苦于以下问题:Python QDialogButtonBox.setStandardButtons方法的具体用法?Python QDialogButtonBox.setStandardButtons怎么用?Python QDialogButtonBox.setStandardButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QDialogButtonBox
的用法示例。
在下文中一共展示了QDialogButtonBox.setStandardButtons方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_config_widget
# 需要导入模块: from PyQt4.Qt import QDialogButtonBox [as 别名]
# 或者: from PyQt4.Qt.QDialogButtonBox import setStandardButtons [as 别名]
def show_config_widget(category, name, gui=None, show_restart_msg=False,
parent=None, never_shutdown=False):
'''
Show the preferences plugin identified by category and name
:param gui: gui instance, if None a hidden gui is created
:param show_restart_msg: If True and the preferences plugin indicates a
restart is required, show a message box telling the user to restart
:param parent: The parent of the displayed dialog
:return: True iff a restart is required for the changes made by the user to
take effect
'''
from calibre.gui2 import gprefs
pl = get_plugin(category, name)
d = ConfigDialog(parent)
d.resize(750, 550)
conf_name = 'config_widget_dialog_geometry_%s_%s'%(category, name)
geom = gprefs.get(conf_name, None)
d.setWindowTitle(_('Configure ') + name)
d.setWindowIcon(QIcon(I('config.png')))
bb = QDialogButtonBox(d)
bb.setStandardButtons(bb.Apply|bb.Cancel|bb.RestoreDefaults)
bb.accepted.connect(d.accept)
bb.rejected.connect(d.reject)
w = pl.create_widget(d)
d.set_widget(w)
bb.button(bb.RestoreDefaults).clicked.connect(w.restore_defaults)
bb.button(bb.RestoreDefaults).setEnabled(w.supports_restoring_to_defaults)
bb.button(bb.Apply).setEnabled(False)
bb.button(bb.Apply).clicked.connect(d.accept)
def onchange():
b = bb.button(bb.Apply)
b.setEnabled(True)
b.setDefault(True)
b.setAutoDefault(True)
w.changed_signal.connect(onchange)
bb.button(bb.Cancel).setFocus(True)
l = QVBoxLayout()
d.setLayout(l)
l.addWidget(w)
l.addWidget(bb)
mygui = gui is None
if gui is None:
gui = init_gui()
mygui = True
w.genesis(gui)
w.initialize()
if geom is not None:
d.restoreGeometry(geom)
d.exec_()
geom = bytearray(d.saveGeometry())
gprefs[conf_name] = geom
rr = getattr(d, 'restart_required', False)
if show_restart_msg and rr:
from calibre.gui2 import warning_dialog
warning_dialog(gui, 'Restart required', 'Restart required', show=True)
if mygui and not never_shutdown:
gui.shutdown()
return rr
示例2: Wizard
# 需要导入模块: from PyQt4.Qt import QDialogButtonBox [as 别名]
# 或者: from PyQt4.Qt.QDialogButtonBox import setStandardButtons [as 别名]
class Wizard(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.resize(440, 480)
self.verticalLayout = QVBoxLayout(self)
self.widget = WizardWidget(self)
self.verticalLayout.addWidget(self.widget)
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
self.verticalLayout.addWidget(self.buttonBox)
self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
self.setModal(Qt.WindowModal)
@property
def xpath(self):
return self.widget.xpath
示例3: ProceedQuestion
# 需要导入模块: from PyQt4.Qt import QDialogButtonBox [as 别名]
# 或者: from PyQt4.Qt.QDialogButtonBox import setStandardButtons [as 别名]
class ProceedQuestion(QDialog):
ask_question = pyqtSignal(object, object, object)
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setAttribute(Qt.WA_DeleteOnClose, False)
self.setWindowIcon(QIcon(I('dialog_question.png')))
self.questions = []
self._l = l = QGridLayout(self)
self.setLayout(l)
self.icon_label = ic = QLabel(self)
ic.setPixmap(QPixmap(I('dialog_question.png')))
self.msg_label = msg = QLabel('some random filler text')
msg.setWordWrap(True)
ic.setMaximumWidth(110)
ic.setMaximumHeight(100)
ic.setScaledContents(True)
ic.setStyleSheet('QLabel { margin-right: 10px }')
self.bb = QDialogButtonBox()
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole)
self.log_button.setIcon(QIcon(I('debug.png')))
self.log_button.clicked.connect(self.show_log)
self.copy_button = self.bb.addButton(_('&Copy to clipboard'),
self.bb.ActionRole)
self.copy_button.clicked.connect(self.copy_to_clipboard)
self.action_button = self.bb.addButton('', self.bb.ActionRole)
self.action_button.clicked.connect(self.action_clicked)
self.show_det_msg = _('Show &details')
self.hide_det_msg = _('Hide &details')
self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole)
self.det_msg_toggle.clicked.connect(self.toggle_det_msg)
self.det_msg_toggle.setToolTip(
_('Show detailed information about this error'))
self.det_msg = QPlainTextEdit(self)
self.det_msg.setReadOnly(True)
self.bb.setStandardButtons(self.bb.Yes|self.bb.No)
self.bb.button(self.bb.Yes).setDefault(True)
self.checkbox = QCheckBox('', self)
l.addWidget(ic, 0, 0, 1, 1)
l.addWidget(msg, 0, 1, 1, 1)
l.addWidget(self.checkbox, 1, 0, 1, 2)
l.addWidget(self.det_msg, 2, 0, 1, 2)
l.addWidget(self.bb, 3, 0, 1, 2)
self.ask_question.connect(self.do_ask_question,
type=Qt.QueuedConnection)
def copy_to_clipboard(self, *args):
QApplication.clipboard().setText(
'calibre, version %s\n%s: %s\n\n%s' %
(__version__, unicode(self.windowTitle()),
unicode(self.msg_label.text()),
unicode(self.det_msg.toPlainText())))
self.copy_button.setText(_('Copied'))
def action_clicked(self):
if self.questions:
q = self.questions[0]
self.questions[0] = q._replace(callback=q.action_callback)
self.accept()
def accept(self):
if self.questions:
payload, callback, cancel_callback = self.questions[0][:3]
self.questions = self.questions[1:]
cb = None
if self.checkbox.isVisible():
cb = bool(self.checkbox.isChecked())
self.ask_question.emit(callback, payload, cb)
self.hide()
def reject(self):
if self.questions:
payload, callback, cancel_callback = self.questions[0][:3]
self.questions = self.questions[1:]
cb = None
if self.checkbox.isVisible():
cb = bool(self.checkbox.isChecked())
self.ask_question.emit(cancel_callback, payload, cb)
self.hide()
def do_ask_question(self, callback, payload, checkbox_checked):
if callable(callback):
args = [payload]
if checkbox_checked is not None:
args.append(checkbox_checked)
callback(*args)
self.show_question()
def toggle_det_msg(self, *args):
vis = unicode(self.det_msg_toggle.text()) == self.hide_det_msg
self.det_msg_toggle.setText(self.show_det_msg if vis else
#.........这里部分代码省略.........
示例4: Application
# 需要导入模块: from PyQt4.Qt import QDialogButtonBox [as 别名]
# 或者: from PyQt4.Qt.QDialogButtonBox import setStandardButtons [as 别名]
__copyright__ = "2012, Kovid Goyal <kovid at kovidgoyal.net>"
__docformat__ = "restructuredtext en"
from calibre.gui2 import Application
from PyQt4.Qt import QDialog, QGridLayout, QListWidget, QDialogButtonBox, QPushButton, QTimer, QIcon
app = Application([], force_calibre_style=True)
d = QDialog()
d.l = l = QGridLayout()
d.setLayout(l)
lw = QListWidget()
lw.addItem("Some text guy")
l.addWidget(lw, 0, 0, 2, 1)
bb = QDialogButtonBox()
bb.setStandardButtons(bb.Close)
bb.accepted.connect(d.accept)
bb.rejected.connect(d.reject)
b = bb.addButton("Action", bb.ActionRole)
b.setIcon(QIcon(I("wizard.png")))
l.addWidget(bb, 2, 0, 1, 2)
bb.button(bb.Close).setDefault(True)
b = QPushButton("Normal")
l.addWidget(b, 0, 1, 1, 1)
def print_button_sizes():
for b in d.findChildren(QPushButton):
print(unicode(b.text()), b.height(), b.iconSize())