當前位置: 首頁>>代碼示例>>Python>>正文


Python NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_方法代碼示例

本文整理匯總了Python中AppKit.NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_方法的典型用法代碼示例。如果您正苦於以下問題:Python NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_方法的具體用法?Python NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_怎麽用?Python NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppKit.NSAlert的用法示例。


在下文中一共展示了NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: alert

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_ [as 別名]
def alert(title=None, message='', ok=None, cancel=None):
    """Generate a simple alert window.

    .. versionchanged:: 0.2.0
        Providing a `cancel` string will set the button text rather than only using text "Cancel". `title` is no longer
        a required parameter.

    :param title: the text positioned at the top of the window in larger font. If ``None``, a default localized title
                  is used. If not ``None`` or a string, will use the string representation of the object.
    :param message: the text positioned below the `title` in smaller font. If not a string, will use the string
                    representation of the object.
    :param ok: the text for the "ok" button. Must be either a string or ``None``. If ``None``, a default
               localized button title will be used.
    :param cancel: the text for the "cancel" button. If a string, the button will have that text. If `cancel`
                   evaluates to ``True``, will create a button with text "Cancel". Otherwise, this button will not be
                   created.
    :return: a number representing the button pressed. The "ok" button is ``1`` and "cancel" is ``0``.
    """
    message = unicode(message)
    if title is not None:
        title = unicode(title)
    _require_string_or_none(ok)
    if not isinstance(cancel, basestring):
        cancel = 'Cancel' if cancel else None
    alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
        title, ok, cancel, None, message)
    alert.setAlertStyle_(0)  # informational style
    _log('alert opened with message: {0}, title: {1}'.format(repr(message), repr(title)))
    return alert.runModal()
開發者ID:4m1g0,項目名稱:duplicati,代碼行數:31,代碼來源:rumps.py

示例2: alert

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_ [as 別名]
def alert(title, message='', ok=None, cancel=False):
    """
    Simple alert window.
    """
    message = str(message)
    title = str(title)
    alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
        title, ok, 'Cancel' if cancel else None, None, message)
    alert.setAlertStyle_(0)  # informational style
    _log('alert opened with message: {}, title: {}'.format(repr(message), repr(title)))
    return alert.runModal()
開發者ID:philippeowagner,項目名稱:rumps,代碼行數:13,代碼來源:rumps.py

示例3: __init__

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_ [as 別名]
    def __init__(self, message, title='', default_text='', ok=None, cancel=False, dimensions=(320, 160)):
        message = str(message)
        title = str(title)
        self._default_text = default_text
        self._cancel = bool(cancel)
        self._icon = None

        self._alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
            title, ok, 'Cancel' if cancel else None, None, message)
        self._alert.setAlertStyle_(0)  # informational style

        self._textfield = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 0, *dimensions))
        self._textfield.setSelectable_(True)
        if default_text:
            self._textfield.setStringValue_(default_text)
        self._alert.setAccessoryView_(self._textfield)
開發者ID:philippeowagner,項目名稱:rumps,代碼行數:18,代碼來源:rumps.py

示例4: __init__

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_ [as 別名]
    def __init__(self, message='', title='', default_text='', ok=None, cancel=None, dimensions=(320, 160)):
        message = unicode(message)
        title = unicode(title)

        self._cancel = bool(cancel)
        self._icon = None

        _require_string_or_none(ok)
        if not isinstance(cancel, basestring):
            cancel = 'Cancel' if cancel else None

        self._alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
            title, ok, cancel, None, message)
        self._alert.setAlertStyle_(0)  # informational style

        self._textfield = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 0, *dimensions))
        self._textfield.setSelectable_(True)
        self._alert.setAccessoryView_(self._textfield)

        self.default_text = default_text
開發者ID:4m1g0,項目名稱:duplicati,代碼行數:22,代碼來源:rumps.py


注:本文中的AppKit.NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。