当前位置: 首页>>代码示例>>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;未经允许,请勿转载。