当前位置: 首页>>代码示例>>Python>>正文


Python NSAlert.alloc方法代码示例

本文整理汇总了Python中AppKit.NSAlert.alloc方法的典型用法代码示例。如果您正苦于以下问题:Python NSAlert.alloc方法的具体用法?Python NSAlert.alloc怎么用?Python NSAlert.alloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppKit.NSAlert的用法示例。


在下文中一共展示了NSAlert.alloc方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: displayAlert

# 需要导入模块: from AppKit import NSAlert [as 别名]
# 或者: from AppKit.NSAlert import alloc [as 别名]
def displayAlert(message, info, buttons):
	alert = NSAlert.alloc().init()
	alert.setMessageText_(message)
	alert.setInformativeText_(info)
	alert.setAlertStyle_(NSInformationalAlertStyle)
	for button in buttons:
		alert.addButtonWithTitle_(button)
	NSApp.activateIgnoringOtherApps_(True)	
	buttonPressed = alert.runModal()
	return buttonPressed
开发者ID:benwiggy,项目名称:PDFsuite,代码行数:12,代码来源:countpages.py

示例2: display_alert

# 需要导入模块: from AppKit import NSAlert [as 别名]
# 或者: from AppKit.NSAlert import alloc [as 别名]
def display_alert(title, message):
    """Display a warning alert with the given ``title`` and ``message``.

    :param str title: the big bold title
    :param str message: the body of the alert
    """
    alert = NSAlert.alloc().init()
    alert.setAlertStyle_(NSWarningAlertStyle)
    alert.setMessageText_(title)
    alert.setInformativeText_(message)
    NSApp.activateIgnoringOtherApps_(True)
    alert.runModal()
开发者ID:kennydo,项目名称:rename-archive-extension,代码行数:14,代码来源:RenameArchiveService.py

示例3: log_std

# 需要导入模块: from AppKit import NSAlert [as 别名]
# 或者: from AppKit.NSAlert import alloc [as 别名]
def log_std(msg):
	from AppKit import NSAlert, NSInformationalAlertStyle, NSRunningApplication, NSApplicationActivateIgnoringOtherApps

	# initialize
	# tip from: http://graphicsnotes.blogspot.fr/2010/01/programmatically-creating-window-in-mac.html
	NSApplication.sharedApplication()
	NSRunningApplication.currentApplication().activateWithOptions_(NSApplicationActivateIgnoringOtherApps);

	alert = NSAlert.alloc().init()
	alert.autorelease()
	alert.setAlertStyle_(NSInformationalAlertStyle)
	alert.setMessageText_(msg)
	alert.runModal()
开发者ID:ChennyBaBy,项目名称:bin-scripts,代码行数:15,代码来源:export-current-omnigraffle-canvas.py

示例4: __init__

# 需要导入模块: from AppKit import NSAlert [as 别名]
# 或者: from AppKit.NSAlert import alloc [as 别名]
    def __init__(self):
        ''' initializes an alert with custom view containing username and
            password fields with a save to keychain checkbox'''
        # Create an dialog with ok and cancel buttons
        self.alert = NSAlert.alloc().init()
        self.alert.setMessageText_('Please enter your username and password!')
        self.alert.addButtonWithTitle_('Ok')
        self.alert.addButtonWithTitle_('Cancel')

        # create the view for username and password fields
        accessory_view = NSView.alloc().initWithFrame_(NSMakeRect(0, 114, 250, 110))

        # setup username field and label
        self.username_field = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 70, 250, 22))
        username_label = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 94, 250, 20))
        username_label.setStringValue_('Username:')
        username_label.setBezeled_(False)
        username_label.setDrawsBackground_(False)
        username_label.setEditable_(False)
        username_label.setSelectable_(False)

        # setup password field and label
        self.password_field = NSSecureTextField.alloc().initWithFrame_(NSMakeRect(0, 24, 250, 22))
        password_label = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 48, 250, 20))
        password_label.setStringValue_('Password:')
        password_label.setBezeled_(False)
        password_label.setDrawsBackground_(False)
        password_label.setEditable_(False)
        password_label.setSelectable_(False)

        # setup keychain checkbox and label
        self.keychain_checkbox = NSButton.alloc().initWithFrame_(NSMakeRect(0, 0, 200, 20))
        self.keychain_checkbox.setButtonType_(NSSwitchButton)
        self.keychain_checkbox.cell().setTitle_('Save to Keychain')
        self.keychain_checkbox.cell().setBordered_(False)
        self.keychain_checkbox.cell().setEnabled_(True)
        self.keychain_checkbox.cell().setState_(True)

        # add various objects as subviews
        accessory_view.addSubview_(self.keychain_checkbox)
        accessory_view.addSubview_(username_label)
        accessory_view.addSubview_(self.username_field)
        accessory_view.addSubview_(password_label)
        accessory_view.addSubview_(self.password_field)

        # add custom view to alert dialog
        self.alert.setAccessoryView_(accessory_view)
开发者ID:kylecrawshaw,项目名称:ShareMounter,代码行数:49,代码来源:PyDialog.py

示例5: initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_

# 需要导入模块: from AppKit import NSAlert [as 别名]
# 或者: from AppKit.NSAlert import alloc [as 别名]
    def initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_(self,
        messageText="", informativeText="", alertStyle=NSInformationalAlertStyle, buttonTitlesValues=[], parentWindow=None, resultCallback=None):

        self = super(BaseMessageDialog, self).init()
        self.retain()
        self._resultCallback = resultCallback
        self._buttonTitlesValues = buttonTitlesValues
        #
        alert = NSAlert.alloc().init()
        alert.setMessageText_(messageText)
        alert.setInformativeText_(informativeText)
        alert.setAlertStyle_(alertStyle)
        for buttonTitle, value in buttonTitlesValues:
            alert.addButtonWithTitle_(buttonTitle)
        self._value = None
        if parentWindow is None:
            code = alert.runModal()
            self._translateValue(code)
        else:
            alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(parentWindow, self, "alertDidEnd:returnCode:contextInfo:", 0)
        return self
开发者ID:schriftgestalt,项目名称:vanilla,代码行数:23,代码来源:dialogs.py

示例6: initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_

# 需要导入模块: from AppKit import NSAlert [as 别名]
# 或者: from AppKit.NSAlert import alloc [as 别名]
 def initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_(self,
         messageText="",
         informativeText="", 
         alertStyle=NSInformationalAlertStyle,
         buttonTitlesValues=None,
         parentWindow=None,
         resultCallback=None):
     if buttonTitlesValues is None:
         buttonTitlesValues = []
     self = super(BaseMessageDialog, self).init()
     self.retain()
     self._resultCallback = resultCallback
     self._buttonTitlesValues = buttonTitlesValues
     #
     alert = NSAlert.alloc().init()
     alert.setMessageText_(messageText)
     alert.setInformativeText_(informativeText)
     alert.setAlertStyle_(alertStyle)
     for buttonTitle, value in buttonTitlesValues:
         alert.addButtonWithTitle_(buttonTitle)
     self._value = None
     code = alert.runModal()
     self._translateValue(code)
     return self
开发者ID:anthrotype,项目名称:robofab,代码行数:26,代码来源:dialogs_fontlab_legacy2.py

示例7: __init__

# 需要导入模块: from AppKit import NSAlert [as 别名]
# 或者: from AppKit.NSAlert import alloc [as 别名]
 def __init__(self, title, message):
     self.nsalert = NSAlert.alloc().init()
     self.nsalert.setAlertStyle_(NSInformationalAlertStyle)
     self.nsalert.setMessageText_(title)
     self.nsalert.setInformativeText_(message)
开发者ID:xoconusco,项目名称:verano16,代码行数:7,代码来源:osx_panel.py


注:本文中的AppKit.NSAlert.alloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。