示例#1
0
    def __init__(self,
                 msg,
                 name,
                 parent,
                 config_set=dynamic,
                 icon='dialog_warning.png',
                 title=None,
                 confirm_msg=None,
                 show_cancel_button=True,
                 extra_button=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(title or _("Are you sure?"))
        self.setWindowIcon(QIcon(I(icon)))
        self.l = l = QVBoxLayout(self)
        self.h = h = QHBoxLayout()
        l.addLayout(h)

        self.icon_widget = Icon(self)
        self.icon_widget.set_icon(QIcon(I(icon)))

        self.msg = m = QLabel(self)
        m.setOpenExternalLinks(True)
        m.setMinimumWidth(350), m.setWordWrap(True), m.setObjectName("msg")
        m.setText(msg)

        h.addWidget(self.icon_widget), h.addSpacing(10), h.addWidget(m)

        self.again = a = QCheckBox(
            (confirm_msg or _("&Show this warning again")), self)
        a.setChecked(True), a.setObjectName("again")
        a.stateChanged.connect(self.toggle)
        l.addWidget(a)

        if show_cancel_button:
            buttons = QDialogButtonBox.StandardButton.Yes | QDialogButtonBox.StandardButton.No
            standard_button = QDialogButtonBox.StandardButton.Yes
        else:
            buttons = QDialogButtonBox.StandardButton.Ok
            standard_button = QDialogButtonBox.StandardButton.Ok
        self.buttonBox = bb = QDialogButtonBox(buttons, self)
        bb.setObjectName("buttonBox")
        bb.setFocus(Qt.FocusReason.OtherFocusReason)
        bb.accepted.connect(self.accept), bb.rejected.connect(self.reject)
        self.extra_button_clicked = False
        if extra_button:
            b = bb.addButton(extra_button,
                             QDialogButtonBox.ButtonRole.AcceptRole)
            b.clicked.connect(self.on_extra_button_click)
        l.addWidget(bb)

        self.name = name
        self.config_set = config_set

        self.resize(self.sizeHint())
        bb.button(standard_button).setFocus(Qt.FocusReason.OtherFocusReason)
示例#2
0
文件: main.py 项目: tletnes/calibre
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.l = l = QHBoxLayout(self)
     self.icon = Icon(self, size=ICON_SIZE)
     l.addWidget(self.icon)
     self.title = QLabel('')
     self.title.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
     l.addWidget(self.title)
     l.addStrut(25)
     self.msg = la = Message(self)
     l.addWidget(la)
     self.default_message = __appname__ + ' ' + _('version') + ' ' + \
             __version__ + ' ' + _('created by Kovid Goyal')
     self.show_plugin()
     self.show_msg()